`clear()`

Clear the drawing canvas

`clear(x, y, width, height)`

Clear the region of the drawing canvas denoted by the rectangle with origin (x,y) and of size (width,height)

`save()`

Save the state of the drawing canvas

`restore()`

Restore the state of the drawing canvas

`locate(x, y)`

Move the text cursor to point (x,y)

`write(string)`

Draw text string at current text cursor. Text cursor will then move down to the line.

`write(string, x, y)`

Move the text cursor to position (x,y) then draw text string.

`fontSize(size)`

Set the font size

`paper(color)`

Set the background color to `color`

`pen()`

Turn the pen (i.e. shape outline) on.

`pen(color)`

Set the pen color to `color`

and turns the pen on.

`pen(color, lineWidth)`

Set the pen color to `color`

and line width to `lineWidth', and turns the pen on.

`lineWidth(width)`

Set the outline's lineWidth to `width`

`fill()`

Turn fill on.

`fill(color)`

Set the fill color to `color`

and turns fill on.

`noPen()`

Turn the pen off

`noFill()`

Turn fill off

`moveTo(x, y)`

Move the line drawing position to (x,y)

`lineTo(x, y)`

Draws a line from the current drawing position to (x,y). The current line drawing position is updated to (x,y)

`line(x1, y1, x2, y2)`

Draw a line from (x1,y1) to (x2,y2). The current line drawing position is updated to (x2,y2)

`arc(cx, cy, radius, startAngle, endAngle)`

Draws the arc of a circle centred at (cx,cy) having radius `radius`

between the angles of `startAngle`

and `endAngle`

.

`arc(cx, cy, radius, startAngle, endAngle, antiClockwise)`

Draws the arc of a circle centred at (cx,cy) having radius `radius`

between the angles of `startAngle`

and `endAngle`

. If `antiClockwise`

is true, the arc will be drawn in the reverse direction.

`circle(cx, cy, radius)`

Draws a circle centred at (cx,cy) with radius `radius`

.

`rectangle(x, y, width, height)`

Draws a rectangle at position (x,y) with the given `width`

and `height`

.

`square(x, y, size)`

Draws a square at position (x,y) with sides of size `size`

.

`quad(x1, y1, x2, y2, x3, y3, x4, y4)`

Draw a quadrilateral with the 4 given points.

`triangle(x1, y1, x2, y2, x3, y3)`

Draw a triangle with the 3 given points.

`translate(x, y)`

`scale(x, y),`

`rotate(angle)`

`identity()`

`transform(m11, m12, m21, m22, dx, dy)`

`setTransform(m11, m12, m21, m22, dx, dy)`

`rgb(r, g, b)`

Create a colour string with the given components for red, green and blue respectively. Each of `r`

, `g`

and `b`

should be numbers between 0 and 255 inclusive.

`rgb(r, g, b, a)`

Create a colour string with the given components for red, green, blue and alpha (transparency) respectively. Each of `r`

, `g`

and `b`

should be numbers between 0 and 255 inclusive. `a`

should be a number between 0 and 1.

`hsl(h, s, l)`

Create a colour string with the given components for hue, saturation and lightness respectively. `h`

should be a number between 0 and 360, and `s`

and `l`

should be numbers between 0 and 1.

`hsl(h, s, l, a)`

Create a colour string with the given components for hue, saturation, lightness and alpha (transparency) respectively. `h`

should be a number between 0 and 360, and `s`

, `l`

and `a`

should be numbers between 0 and 1.

`random()`

Generates a random number between 0 and 1.

`random(max)`

Generates a whole random number between 0 and `max`

.

`random(min, max)`

Generates a whole random number between `min`

and `max`

.

`abs(x)`

Calculates the absolute value of `x`

.

`ceil(x)`

Calculates the ceiling of `x`

.

`floor(x)`

Calculates the floor of `x`

.

`round(x)`

Rounds `x`

to the nearest whole number.

`exp(x)`

Calculates E^x

`log(x)`

Calculates the natural logarithm (base E) of `x`

`pow(x, y)`

Calculates `x`

to the power of `y`

.

`cos(x)`

Calculates the cosine of `x`

, where `x`

is an angle expressed in radians.

`sin(x)`

Calculates the sine of `x`

, where `x`

is an angle expressed in radians.

`tan(x)`

Calculates the tangent of `x`

, where `x`

is an angle expressed in radians.

`acos(x)`

Calculates the arccosine of `x`

, where `x`

is an angle expressed in radians.

`asin(x)`

Calculates the arcsine of `x`

, where `x`

is an angle expressed in radians.

`atan(x)`

Calculates the arctangent of `x`

, where `x`

is an angle expressed in radians.

`atan2(y, x)`

Calculates the arctangent of the quotient of `y`

and `x`

.

`sq(x)`

Calculates `x`

squared.

`sqrt(x)`

Calculates the square root of `x`

.

`lerp(start, stop, position)`

`clamp(x, min, max)`