Skip to main content

Drawing Shapes

For drawing shapes into the screen using code.


color

Get and/or set the active color.

colorId = color(colorId?)
ParameterTypeDefaultNote
colorId?numberactive colorinteger in range [0, 15].
ReturnTypeNote
colorIdnumberinteger in range [0, 15].

clear

Clear the screen and fills it with a specific color, useful when clearing the screen for a new frame.

clear(colorId?)
ParameterTypeDefaultNote
colorId?numberactive colorinteger in range [0, 15].

point

Draw a point on the screen.

point(x, y, colorId?)
ParameterTypeDefaultNote
xnumber⚠️ required
ynumber⚠️ required
colorId?numberactive colorinteger in range [0, 15].

points

Draw multiple points on the screen.

points(coords, colorId?)
ParameterTypeDefaultNote
coordsnumber[]⚠️ requiredthe coordinates of the points,
must contain an even number of elements.
colorId?numberactive colorinteger in range [0, 15].

line

Draw a line on the screen.

line(x1, y1, x2, y2, colorId?)
ParameterTypeDefaultNote
x1number⚠️ required
y1number⚠️ required
x2number⚠️ required
y2number⚠️ required
colorId?numberactive colorinteger in range [0, 15].

lines

Draw multiple lines on the screen.

line(coords, colorId?)
ParameterTypeDefaultNote
coordsnumber[]⚠️ requiredthe coordinates of the line vertices,
must contain an even number of elements.
colorId?numberactive colorinteger in range [0, 15].

circle

Draw a circle on the screen.

circle(centerX, centerY, radius, filled?, colorId?)
ParameterTypeDefaultNote
centerXnumber⚠️ required
centerYnumber⚠️ required
radiusnumber⚠️ required
filled?booleanfalsewhether to be filled or only an outline.
colorId?numberactive colorinteger in range [0, 15].

ellipse

Draw an ellipse on the screen.

ellipse(centerX, centerY, radiusX, radiusY, filled?, colorId?)
ParameterTypeDefaultNote
centerXnumber⚠️ required
centerYnumber⚠️ required
radiusXnumber⚠️ required
radiusYnumber⚠️ required
filled?booleanfalsewhether to be filled or only an outline.
colorId?numberactive colorinteger in range [0, 15].

triangle

Draw a triangle on the screen.

triangle(x1, y1, x2, y2, x3, y3, filled?, colorId?)
ParameterTypeDefaultNote
x1number⚠️ requiredfirst vertex.
y1number⚠️ requiredfirst vertex.
x2number⚠️ requiredsecond vertex.
y2number⚠️ requiredsecond vertex.
x3number⚠️ requiredthird vertex.
y3number⚠️ requiredthird vertex.
filled?booleanfalsewhether to be filled or only an outline.
colorId?numberactive colorinteger in range [0, 15].

rectangle

Draw a rectangle on the screen.

rect(x, y, width, height, filled?, colorId?)
ParameterTypeDefaultNote
xnumber⚠️ required
ynumber⚠️ required
widthnumber⚠️ required
heightnumber⚠️ required
filled?booleanfalsewhether to be filled or only an outline.
colorId?numberactive colorinteger in range [0, 15].

polygon

Draw a polygon on the screen.

polygon(vertices, filled?, colorId?)
ParameterTypeDefaultNote
verticesnumber[]⚠️ requiredthe coordinates of the polygon vertices,
must contain an even number of elements
and 3 vertices at least.
filled?booleanfalsewhether to be filled or only an outline.
colorId?numberactive colorinteger in range [0, 15].