Basic Drawing Commands
- circle(x, y, r) -- Draw the circle centered at (x,y) with radius r.
- line(x1,y1,x2,y2) -- Draw a line from point (x1,y1) to (x2,y2).
- line(x1,y1,x2,y2,x3,y3,...) -- Draw line segments from (x1,y1) to (x2,y2), and then from (x2,y2) to (x3,y3), and so on.
- linewidth(n) -- Set the line width to n pixels.
- rect(x1,y1,w,h) -- Draw rectangle with upper left corner at (x,y) with width w and height h.
- fillrect(x1,y1,x2,y2) -- Fill rectangle with upper left corner at (x,y) with width w and height h.
- ellipse(x, y, rx, ry) -- Draw an ellipse with center (x,y), horizontal radius rx, and vertical radius ry.
- point(x,y) -- Draw a circle at (x,y) whose radius is the linewidth.
- arc(x, y, r, a, b) -- Draw the arc of the circle centered at (x,y) with radius r starting at angle a and continuing to angle b in a clockwise direction.
- triangle(x1,y1,x2,y2,x3,y3) -- Draw triangle with vertices (x1,y1), (x2,y2), and (x3,y3).
- quad(x1,y1,x2,y2,x3,y3,x4,y4) -- Draw quadrilateral with vertices (x1,y1), (x2,y2), (x3,y3), and (x4,y4).
- fill() -- Fill the last drawn shape.
Basic Color Commands
- color(c) -- Set the line color to c.
- color(r,g,b) -- Set the line color to have RGB values of r, g, and b.
- color(r,g,b,a) -- Set the line color to have RGB values of r, g, and b, and alpha value of a.
- fillcolor(c) -- Set the fill color to c.
- fillcolor(r,g,b) -- Set the fill color to have RGB values of r, g, and b.
- fillcolor(r,g,b,a) -- Set the fill color to have RGB values of r, g, and b, and alpha value of a.
Canvas Commands
- size(w,h) -- Set the canvas width to w pixels and the height to h pixels.
- clear() -- Clear the canvas.
Transformations and Such
- clip() -- Causes all subsequent drawing to be clipped inside the last figure drawn.
- translate(x,y) -- Move the origin of the drawing canvas to the point (x,y) relative to the current origin.
- scale(s) -- Cause all drawing to be scaled by s from the point of the call forward.
- scale(x,y) -- Cause all drawing to be scaled by x horizontally and y vertically from the point of the call forward.
- rotate(n) -- Rotate the axis by n degrees clockwise.
- save() -- Save the state of the drawing canvas to be restored at a later time.
- restore() -- Undo all of the changes in scale, rotation, color, etc. to the drawing canvas back to the last save.
Text Stuff
- font(x) -- Set the font of the canvas to x. The variable x should be something like, "20px" or "20px times" or "bold 20px times".
- filltext(t, x, y) -- Write the text t at the point (x,y) filling in the characters.
- stroketext(t, x, y) -- Write the text t at the point (x,y) outlining the characters.
- aligntext(s) -- Specify how text is aligned with the point (x,y) in a command such as "filltext(t,x,y)". The argument s should be "left", "right", "center", "start", or "end".
- valigntext(x) -- Specify how text is aligned vertically with the point (x,y) in a command such as "filltext(t,x,y)". The argument s should be "top", "bottom", "middle", "alphabetic", or "hanging".
Image Stuff
- copyImageData(R,G,B,A) -- This copies the canvas RGB and alpha values to arrays R, G, B, and A. R, G, B, and A should be arrays.
- drawImage(i, x, y, w, h, r) -- Places the image i on the canvas centered at (x,y) with width w and height h. If r is included, the image will be rotated by r degrees.
Other
- measuretext(t) -- This will return the length of the text t if it were printed on the canvas.
- floodfill(x,y) -- Fills the region of the canvas containing the point (x,y) with the current fill color.
- shadowblur(n) -- Causes a shadow of width n pixels to be drawn around all subsequent figures.
- shadowcolor(s) -- Sets the color of the shadow for shadow blur to s.
- rgb(r,g,b) -- Returns the color with RGB values r, g, and b.
- rgba(r,g,b,a) -- Returns the color with RGB values r, g, and b and alpha value a.