beginShape()
Draws a polygon with any number of given vertices.
Example

beginShape()
vertex(200, 100)
vertex(300, 150)
vertex(300, 250)
vertex(200, 300)
vertex(100, 250)
vertex(100, 150)
vertex(200, 100)
endShape()
Syntax
beginShape(FORMAT)
...
vertex(x1,y1)
vertex(x2,y2)
vertex(x3,y3)
etc.
...
endShape(MODE)
beginShape()
starts the list of co-ordinates
FORMAT
contains any of POINTS, LINES, TRIANGLES, QUADS, TESS, see Description
vertex(xi,yi)
The coordinates of the i-th vertex of the polygon
endShape()
ends the list of co-ordinates
MODE
CLOSE or nothing

Description
beginShape() and endShape() allow the drawing of shapes with many corners. After beginShape() is called, corners (vertices) should be listed, each on a separate line. After that, endShape() should be called to end the list. Corners are written in their x,y co-ordinates as vertex(x,y)
The inputs available for beginShape() are:
TESS Connects the edges and creates a closed region. This is the default behavior if nothing was given.

POINTS Draw a set of points

LINES Draw a set of unconnected line segments

TRIANGLES Draw a set of triangles

QUADS Draw a set of quadrilaterals

endShape(CLOSE)
connects the last vertex to the first one

endShape()

Last updated