drawPolygon

This allows you to draw the outline of custom shapes. This includes triangles, quadrilaterals, or something much more complex.

Depending on which function your using, the points can be provided in 1 or 2 arrays, and can be translated along the x and y axis.

drawPolygon( points )

Draws a polygon outline using the points given. The 'points' array is presumed to be an array of numbers, in the order of x, y, x, y, x, y, and so on.

// draws a kite shaped object
aKite = [ 150, 100, 200, 150, 150, 300, 100, 150 ]
drawPolygon( aKite )

drawPolygon( points, x, y )

Draws a polygon, in the same way as the previous 'drawPolygon' function, but when drawn it is translated by the x and y values given.

// draws a kite shaped object, translated
aKite = [ 150, 100, 200, 150, 150, 300, 100, 150 ]
drawPolygon( aKite, 100, 0 )

drawPolygon( xs, ys )

This version of 'drawPolygon' takes separate arrays for the x and y values.

aKiteXs = [ 350, 400, 350, 300 ]
aKiteYs = [ 100, 150, 300, 150 ]
drawPolygon( aKiteXs, aKiteYs )

drawPolygon( xs, ys, x, y )

Takes separate arrays for the x and y points of the polygon, and allows you to translate it by the 'x' and 'y' values given.

aKiteXs = [ 350, 400, 350, 300 ]
aKiteYs = [ 100, 150, 300, 150 ]
drawPolygon( aKiteXs, aKiteYs, 100, 0 )
/**
 * All four kites together
 */

aKite = [ 150, 100, 200, 150, 150, 300, 100, 150 ]

aKiteXs = [ 350, 400, 350, 300 ]
aKiteYs = [ 100, 150, 300, 150 ]

onEachFrame() do
    fill( :blue )
    setColor( :white )
    
    drawPolygon( aKite )
    drawPolygon( aKite, 100, 0 )
    
    drawPolygon( aKiteXs, aKiteYs )
    drawPolygon( aKiteXs, aKiteYs, 100, 0 )
end

See also

How Alignment Works - fillPolygon