Difference between revisions of "Legacy:Font/drawText"

From Spherical
Jump to: navigation, search
(Created.)
Line 1: Line 1:
 
+
Draw (write) a line of text on the screen using the specified font.
 
 
{{{preamble}}}
 
  
 
__TOC__
 
__TOC__
  
 
==Usage==
 
==Usage==
{{Usage|returns={{{returns}}}|object={{{object}}}|func={{{function}}}|params={{{params}}}}}
+
{{Usage|object=Font|func=drawText|params=x, y}}
  
* '''param1''' type. param1 description
+
* '''x''' Integer. The x position on the screen where the text starts drawing.
* '''param2''' type. param2 description
+
* '''y''' Integer. The y position of the text on the screen.
* '''paramN''' type. paramN description
 
  
 
==Examples==
 
==Examples==
(examples with syntaxhighlighted code)
+
{{template:col-begin}}
 +
{{template:col-break|width=20%}}
 +
<syntaxhighlight>
 +
var font = GetSystemFont();
 +
font.drawtext(10, 10, "I am a line of text.");
 +
 
 +
FlipScreen();
 +
GetKey();
 +
</syntaxhighlight>
 +
 
 +
{{template:col-break}}
 +
 
 +
<syntaxhighlight>
 +
//Load the font to use
 +
//Draw it
 +
 
 +
//Now display it on the screen
 +
//Now wait for user interaction
 +
</syntaxhighlight>
 +
 
 +
{{template:col-end}}
  
 
==Notes==
 
==Notes==
(notes)
+
* Using \n for new lines doesn't work with this function. drawText() is meant purely for drawing ''single line'' of text.
 +
* The line width is infinite, so you can easily go past the screen width if your line is too long.
  
 
==See also==
 
==See also==
* see also
+
* [[API:GetSystemFont|GetSystemFont]]()
* see also
+
* [[API:FlipScreen|FlipScreen]]()
* see also
+
* [[API:GetKey|GetKey]]()
* etc
 

Revision as of 09:55, 23 June 2013

Draw (write) a line of text on the screen using the specified font.

Usage

Font.drawText(x, y);


  • x Integer. The x position on the screen where the text starts drawing.
  • y Integer. The y position of the text on the screen.

Examples

var font = GetSystemFont();
font.drawtext(10, 10, "I am a line of text.");

FlipScreen();
GetKey();

//Load the font to use
//Draw it

//Now display it on the screen
//Now wait for user interaction

Notes

  • Using \n for new lines doesn't work with this function. drawText() is meant purely for drawing single line of text.
  • The line width is infinite, so you can easily go past the screen width if your line is too long.

See also