Game Development Reference
In-Depth Information
Here's the syntax for drawing a circle:
ellipse(50,50,20,20)
And here's the syntax for drawing a ellipse:
ellipse(100,100,20,50)
As mentioned, there are four ellipse modes that allow you to draw ellipses in various different ways:
CENTER : In this mode, the parameters are the center x,y-coordinates, followed by
the x and y diameters. This is the mode used in the previous example.
RADIUS : This mode uses the center x,y-coordinates, followed by the x and y radii ,
instead of the diameters.
CORNER : This mode takes the x,y-coordinates of the lower-left corner of the
ellipse, followed by the width and height. The ellipse 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
ellipse, followed by the upper-right corner of the ellipse. The ellipse is drawn in
the bounding rectangle as specified by the arguments.
ellipseMode(RADIUS)
ellipse(100,200,50,50)
ellipseMode(CORNER)
ellipse(200,100,50,50)
ellipseMode(CORNERS)
ellipse(200,200,50,50)
Drawing Rectangles
The function for drawing rectangles is the rect function. It takes four arguments, which, as with
ellipses, depend on the mode in which the rectangle is being drawn. In CENTER mode, the arguments
are the starting x,y-coordinates, followed by the width and height of the rectangle.
rect(10,10,300,100) -- draws a rectangle that is 300×100 and positions it at 10,10
Following are the four modes for drawing rectangles:
CENTER : This mode takes as parameters the center x,y-coordinates, followed by
the width and the height.
RADIUS : The mode takes the center x,y-coordinates, followed by half the width
and height.
 
Search WWH ::




Custom Search