SUPPORTED COMMANDS

DRAWING

setColor(color) — set pen color (red, #FF00FF, etc.)

drawCircle(x, y, r) — filled circle at (x,y) radius r

drawRect(x, y, w, h) — filled rectangle at (x,y) size w×h

drawLine(x1, y1, x2, y2) — line from (x1,y1) to (x2,y2)

drawEllipse(x, y, radiusx, radiusy) — draws an ellipse at (x, y) 

drawTri(x1, y1, x2, y2, x3, y3) — draws a triangle at (x1, y1, x2, y2, x3, y3) 

strokeCircle(x, y, r) — outlines a circle at (x,y) radius r

drawQuad(x1, y1, x2, y2, x3, y3, x4, y4) — draw a quad with all points given

strokeTri(x1, y1, x2, y2, x3, y3) — outlines a triangle at (x1, y1, x2, y2, x3, y3)

strokeRect(x, y, w, h) — outlines a rectangle at (x,y) size w×h

strokeEllipse(x, y, rx, ry) — outlines an ellipse at x and y, with an x radius and y radius.

drawText("Text", x, y) — draws said Text at (x, y) 

setFont("size 'font name'") — example: setFont("16px 'Arial'")

setLineWidth(width) — sets the line width for all the stroke shapes and the line.

clear() — clear canvas
    

OUTPUT

print("text") — print text to console
    

CONTROL FLOW

for var = start to end { ... } — loop inclusive

while condition { ... } - repeats only while condition is met

loop { ... } — loop a section of code forever

wait(ms) — waits a certain amount of milliseconds
    

VARIABLES & ARRAYS

VarName = expression — assign variable (supports math, functions, etc.)

myArray = [1, 2, 3] — create an array

print(myArray[0]) — access array index

myArray[1] = 42 — assign value to index

FUNCTIONS

function myFunc(a, b) {
  // code block using a and b
}

myFunc(5, 10) — call function with arguments

Supports arrays, variables, math expressions in arguments

UTILITY FUNCTIONS

These are tested but not debugged.

random(min, max) — random float between min and max

randInt(min, max) — random integer between min and max (inclusive)

clamp(val, min, max) — restricts val to be between min and max

lerp(a, b, t) — linear interpolate from a to b by t (0 ≤ t ≤ 1)

INPUT FUNCTIONS

mouseX() — returns current mouse X position
mouseY() — returns current mouse Y position

mouseIsDown() — true if any mouse button is held
mouseWasPressed() — true only on the frame a mouse button was pressed

COMMENTS

// comment — single-line comment
    

SUPPORTED MATH FUNCTIONS

Math.sin,
Math.cos,
Math.tan,
Math.asin,
Math.acos,
Math.atan,
Math.atan2,
Math.sqrt,
Math.abs,
Math.floor,
Math.ceil,
Math.round,
Math.PI,
Math.E,
Math.pow,
Math.exp,
Math.log,
Math.max,
Math.min,
    

SUPPORTED FONTS

Arial Verdana Helvetica Georgia Times New Roman Lucida Console Trebuchet MS Impact Comic Sans MS Monospace Sans-serif Serif Cursive Fantasy

SUPPORTED COLORS

red orange yellow green blue cyan black white brown maroon olive lime teal navy silver gray purple magenta pink coral gold salmon beige chocolate crimson darkblue darkcyan darkgreen darkmagenta darkorange darkred darkviolet deeppink deepskyblue dodgerblue firebrick forestgreen gainsboro ghostwhite goldenrod greenyellow honeydew hotpink indianred indigo khaki lavender lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow limegreen linen mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite oldlace olivedrab orange_red orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru plum powderblue rosybrown royalblue saddlebrown sandybrown seagreen seashell sienna skyblue slateblue slategray snow springgreen steelblue tan thistle tomato turquoise violet wheat whitesmoke yellowgreen