Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Font.Draw With Rows / Columns (Text.Locate())?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Fexter




PostPosted: Tue May 01, 2012 9:21 pm   Post subject: Font.Draw With Rows / Columns (Text.Locate())?

What is it you are trying to achieve?
I want to be able to center text that I enter. I found a way to do this with Text.Locate(), but I need to be able to have this work for Font.Draw() as I have a special font that I am using other than the normal put font.

What is the problem you are having?
I can't seem to find a way to use rows and columns, and pixels make it a lot tougher to center the text.


Describe what you have tried to solve this problem
I have tried checking the Turing Documentation for something that would work with this.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


procedure center (text:string)
    Text.Locate(12, 40 - length(text) div 2) % Center the text location
    put text % I want to change this to Font.Draw() for my specific font
end center

center("Hello World!")



Please specify what version of Turing you are using
Turing 4.1.1.
Sponsor
Sponsor
Sponsor
sponsor
Amarylis




PostPosted: Tue May 01, 2012 9:37 pm   Post subject: Re: Font.Draw With Rows / Columns (Text.Locate())?

If you're looking for the very center of the window, then it'd be something like this

Turing:

Font.Draw (maxx div 2 - length(text) div 2, maxy div 2, font, black)
Fexter




PostPosted: Tue May 01, 2012 9:53 pm   Post subject: RE:Font.Draw With Rows / Columns (Text.Locate())?

@Amarylis
I've tried that several times, and it's never worked (The letters seem to have different lengths -- For example, the letter R is longer than l). However, Font.Width() seems to work with what I want, so I can use that.. Very Happy
Amarylis




PostPosted: Tue May 01, 2012 10:17 pm   Post subject: RE:Font.Draw With Rows / Columns (Text.Locate())?

..Whoops, confused length with Font.Width
evildaddy911




PostPosted: Wed May 02, 2012 2:35 pm   Post subject: Re: Font.Draw With Rows / Columns (Text.Locate())?

ive had that same problem, so i made this procedure

Turing:
procedure centerfont (text:string, x, y, font, color:int)
Font.Draw (text, x - Font.Width (text, font) div 2, y, font, color)
end centerfont


the x is where the center of the text is located
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: