Module draw2D
Draw2D: simple drawing primitives for 2D graphics
Functions
| bounds (left, bottom, right, top) | Define the coordinate space of the window | 
| blend (mode) | Enable or disable blending call blend(false) to disable blending | 
| push () | Store the current transformation until the next pop() Caches the current transform matrix into the matrix stack, and pushes a new copy of the matrix onto the top. | 
| pop () | Restore the transformation from the previous push() Discards the current transformation matrix and restores the previous matrix from the matrix stack. | 
| translate (x, y) | Move the coordinate system origin to x, y (modifies the transformation matrix) | 
| scale (x, y) | Scale the coordinate system (modifies the transformation matrix) | 
| rotate (a) | Rotate the coordinate system around the origin (modifies the transformation matrix) | 
| point (x, y) | Draw a point at position x,y | 
| line (x1, y1, x2, y2) | Draw a line from x1,y1 to x2,y2 | 
| rect (x, y, w, h) | Draw a rectangle at the point (x, y) with width w and height h | 
| quad (x1, y1, x2, y2, x3, y3, x4, y4) | Draw a quad over four points | 
| ellipse (x, y, w, h) | Draw an ellipse at the point (x, y) with horizontal diameter w and vertical diameter h | 
| circle (x, y, d) | Draw an ellipse at the point (x, y) with horizontal diameter d | 
| arc (x, y, s, e, w, h) | Draw an arc at the point (x, y) with horizontal diameter d | 
| color (red, green, blue, alpha) | Set the rendering color | 
| loadImage (name) | Load an image to draw | 
| image (img, x, y, w, h) | Draw an image at the point (x, y) with width w and height h | 
Functions
- bounds (left, bottom, right, top)
- 
    Define the coordinate space of the window
    Parameters:- left the X-coordinate value of the left edge of the window (default -1)
- bottom the Y-coordinate value of the bottom edge of the window (default -1)
- right the X-coordinate value of the right edge of the window (default 1)
- top the Y-coordinate value of the top edge of the window (default 1)
 
- blend (mode)
- 
    Enable or disable blending
 call blend(false) to disable blending
    Parameters:- mode blend mode (optional, default true)
 
- push ()
- Store the current transformation until the next pop() Caches the current transform matrix into the matrix stack, and pushes a new copy of the matrix onto the top. Note that the stack is limited in size (typically 32 items).
- pop ()
- Restore the transformation from the previous push() Discards the current transformation matrix and restores the previous matrix from the matrix stack.
- translate (x, y)
- 
    Move the coordinate system origin to x, y
 (modifies the transformation matrix)
    Parameters:- x coordinate of new origin
- y coordinate of new origin
 
- scale (x, y)
- 
    Scale the coordinate system
 (modifies the transformation matrix)
    Parameters:- x horizontal factor
- y vertical factor
 
- rotate (a)
- 
    Rotate the coordinate system around the origin
 (modifies the transformation matrix)
    Parameters:- a the angle (in radians) to rotate
 
- point (x, y)
- 
    Draw a point at position x,y
    Parameters:- x coordinate of center (optional, defaults to 0)
- y coordinate of center (optional, defaults to 0)
 
- line (x1, y1, x2, y2)
- 
    Draw a line from x1,y1 to x2,y2
    Parameters:- x1 start coordinate
- y1 start coordinate
- x2 end coordinate (optional, defaults to 0)
- y2 end coordinate (optional, defaults to 0)
 
- rect (x, y, w, h)
- 
    Draw a rectangle at the point (x, y) with width w and height h
    Parameters:- x coordinate of center (optional, defaults to 0)
- y coordinate of center (optional, defaults to 0)
- w width (optional, defaults to 1)
- h height (optional, defaults to 1)
 
- quad (x1, y1, x2, y2, x3, y3, x4, y4)
- 
    Draw a quad over four points
    Parameters:- x1 coordinate of first point (optional, defaults to 0)
- y1 coordinate of first point (optional, defaults to 0)
- x2 coordinate of second point (optional, defaults to 1)
- y2 coordinate of second point (optional, defaults to 0)
- x3 coordinate of third point (optional, defaults to 1)
- y3 coordinate of third point (optional, defaults to 1)
- x4 coordinate of fourth point (optional, defaults to 0)
- y4 coordinate of fourth point (optional, defaults to 1)
 
- ellipse (x, y, w, h)
- 
    Draw an ellipse at the point (x, y) with horizontal diameter w and vertical diameter h
    Parameters:- x coordinate of center (optional, defaults to 0)
- y coordinate of center (optional, defaults to 0)
- w horizontal diameter (optional, defaults to 1)
- h vertical diameter (optional, defaults to w)
 
- circle (x, y, d)
- 
    Draw an ellipse at the point (x, y) with horizontal diameter d
    Parameters:- x coordinate of center (optional, defaults to 0)
- y coordinate of center (optional, defaults to 0)
- d diameter (optional, defaults to 1)
 
- arc (x, y, s, e, w, h)
- 
    Draw an arc at the point (x, y) with horizontal diameter d
    Parameters:- x coordinate of center (optional, defaults to 0)
- y coordinate of center (optional, defaults to 0)
- s start angle (optional, defaults to -pi/2)
- e end angle (optional, defaults to pi/2)
- w horizontal radius (optional, defaults to 1)
- h vertical radius (optional, defaults to w)
 
- color (red, green, blue, alpha)
- 
    Set the rendering color
    Parameters:- red value from 0 to 1 (optional, default 0)
- green value from 0 to 1 (optional, default 0)
- blue value from 0 to 1 (optional, default 0)
- alpha (opacity) value from 0 to 1 (optional, default 1)
 
- loadImage (name)
- 
    Load an image to draw
    Parameters:- name the image file name/path
 Returns:- 
        image object
    
 
- image (img, x, y, w, h)
- 
    Draw an image at the point (x, y) with width w and height h
    Parameters:- img the image to use (created by loadImage())
- x coordinate of center (optional, defaults to 0)
- y coordinate of center (optional, defaults to 0)
- w width (optional, defaults to 1)
- h height (optional, defaults to 1)