Basic Functions in Processing

Setting up a canvas

Sets the size of the window/canvas where your drawing will appear.

size(width, height)

Setting the background colour of the canvas

Sets the background to a grayscale colour.

background([0…255])

Drawing a line

Draws a straight line on the canvas.

line(x1, y1, x2, y2)

Drawing a triangle

Draws a 3-sided shape on the canvas.

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

Drawing 4-sided shapes

Draws any quadrilateral on the canvas.

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

Draws a rectangle on the canvas.

rect(x, y, width, height)

Drawing an ellipse

Draws an ellipse on the canvas.

ellipse(x, y, width, height)