Author |
Message |
mike200015
|
Posted: Sun Jan 30, 2005 7:30 pm Post subject: Centre Text?! |
|
|
Is there any way to centre text automatically instead of trial and error of trying to change the coordinates ?? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mr. T
|
Posted: Sun Jan 30, 2005 7:33 pm Post subject: (No subject) |
|
|
no |
|
|
|
|
|
person
|
Posted: Sun Jan 30, 2005 7:48 pm Post subject: (No subject) |
|
|
i think there is, since a standard text screen, is 25 rows by 80 columns, so the centre is (1,40) |
|
|
|
|
|
ssr
|
Posted: Sun Jan 30, 2005 7:58 pm Post subject: (No subject) |
|
|
well, u can put the text in middle by doing something like index
first count how many chars are there
then div them by 2
locate (1,maxcol div 2 - the number of char div 2)
put the text
And there u go
Also, u can chaneg the size of thee output window by doing somethign liek
setscreen("graphics:x;y")
yep adn there u go
8) |
|
|
|
|
|
ssr
|
|
|
|
|
basketball4ever
|
Posted: Sun Jan 30, 2005 8:09 pm Post subject: (No subject) |
|
|
code: | var len : int := length ("Hello World")
locate (1, (maxcol - len) div 2)
put "Hello World" .. |
hope it helps...
first u calculate how many letters are in ur string... and set it as a variable, so basically hello world has 11 characters.
Then in ur locate, you have 1 (being the row) then have the max col of the screen, minus the length, so in a default screen... (80-11) then div 2... = the center will be the center leter of ur text, in this case, a space. |
|
|
|
|
|
ssr
|
Posted: Sun Jan 30, 2005 8:14 pm Post subject: (No subject) |
|
|
srry made a mistake ,
subtract first then div
srry
basketball4ever is right, its the same thing as I said
and hopefully it helps! |
|
|
|
|
|
mike200015
|
Posted: Sun Jan 30, 2005 11:17 pm Post subject: (No subject) |
|
|
hey, yea thanx .. both of those helped me
but what i dont understand is why you use maxcol?.. isnt that maximum colour? what does that have to do with centring text? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
mike200015
|
Posted: Sun Jan 30, 2005 11:20 pm Post subject: (No subject) |
|
|
o wait.. never mind.. i figured it out.. its maximum column not colour lol
and also how would you incorporate that into Font.Draw , since i usually use that rather than jus the regular put |
|
|
|
|
|
Bacchus
|
Posted: Sun Jan 30, 2005 11:23 pm Post subject: (No subject) |
|
|
no maxcol is for the maximum column, for the maximum color its maxcolor close but no cigar. they use maxcol because the text (even when you use locatxy) gets printed in the row and column specified (nearest row and column for locatexy) except if you dont use locatexy or locate then it starts at the maxrow (or is it row 1? which one is the top lol, i dunno i never use locate ) and either decreases or increases by one, depending on which is the top maxrow or 1 lol. rows go across and column go up and down. but you probably kno this so ive just wasted my time explaining.... meh |
|
|
|
|
|
mike200015
|
Posted: Sun Jan 30, 2005 11:31 pm Post subject: (No subject) |
|
|
lol.. yea knew some of that.. but watever.. thanx anyway |
|
|
|
|
|
Bacchus
|
Posted: Sun Jan 30, 2005 11:55 pm Post subject: (No subject) |
|
|
lol im bored so i went a bit in depth |
|
|
|
|
|
Cervantes
|
Posted: Mon Jan 31, 2005 8:26 am Post subject: (No subject) |
|
|
mike200015 wrote: and also how would you incorporate that into Font.Draw , since i usually use that rather than jus the regular put
It's the same idea. THINK! |
|
|
|
|
|
ssr
|
Posted: Mon Jan 31, 2005 8:07 pm Post subject: (No subject) |
|
|
Yep, but instead of using maxcol adn maxrow, u use maxx and maxy because font draw are measured in pixels instead of rows and columns! |
|
|
|
|
|
basketball4ever
|
Posted: Mon Jan 31, 2005 8:13 pm Post subject: (No subject) |
|
|
ssr wrote: Yep, but instead of using maxcol adn maxrow, u use maxx and maxy because font draw are measured in pixels instead of rows and columns!
unless you're using locatexy go see my tutorial on basic text stuff |
|
|
|
|
|
|