Game Development Reference
In-Depth Information
CORNER : This mode takes the x,y-coordinates of the lower-left corner of the
rectangle, followed by the width and height. The rectangle is drawn in the
bounding rectangle as specified by the arguments.
CORNERS : This mode takes the x,y-coordinates of the lower-left corner of the
rectangle, followed by the absolute coordinates of the upper-right corner, rather
than the width and height. The rectangle is drawn in the bounding rectangle as
specified by the arguments.
The following snippets provide examples of the preceding modes:
rectMode(CENTER)
rect(100,100,50,50)
rectMode(RADIUS)
rect(100,200,50,50)
rectMode(CORNER)
rect(100,100,50,50)
rectMode(CORNERS)
rect(100,200,50,50)
Drawing Text
The function to draw text onto the screen is text . It takes three arguments: the text itself, and the
position in x- and y-coordinates where the text needs to be displayed.
text("This is sample text", 10,200)
There are other functions that help to set the attributes of the text being displayed, like the font name
and size. The following function creates the text and also returns the width and the height of the text
that was created:
w, h = textSize("Hello World")
print(w, h)
Drawing Modes
The text function also has two drawing modes that specify how the arguments passed are parsed
and the text is displayed:
CENTER : In this mode, the text is centered around the x,y-coordinates passed to
the text function for drawing. This is the default text-drawing mode.
CORNERS : In this mode, the x,y-coordinates passed to the text function specify
the lower-left corner of the text.
Text Alignment
The text when drawn can be aligned as either of the alignments, LEFT , RIGHT , or CENTER . The default
text alignment setting is LEFT .
 
Search WWH ::




Custom Search