If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Course: Unlisted resources area > Unit 2

Lesson 1: ProcessingJS documentation

beginShape()/endShape()

Use beginShape() and endShape() to create more complex shapes. To start a shape, call beginShape(), then call the vertex() command, then call endShape() to stop. By default, it creates an irregular polygon, but you can control that by sending a mode to beginShape().
Transformations such as translate(), rotate(), and scale() do not work within beginShape(). It is also not possible to use other shapes, such as ellipse() or rect() within beginShape().

beginShape(MODE)

Parameters:
NameDescription
MODE(Optional) Shape mode. Either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRIP

endShape(MODE)

Parameters:
NameDescription
MODE(Optional) Specify CLOSE to close the shape.

vertex(x, y)

Parameters:
NameDescription
xx-coordinate of the vertex
yy-coordinate of the vertex
Trying to use vertex() to draw a shape? Check out these tools:

Want to join the conversation?

No posts yet.