Reference buildShape()

buildShape()

This API is experimental

Its behavior may change in a future version of p5.js.

Records drawing commands executed inside callback into a p5.ShapeCollection and returns it.

buildShape is the easiest way to record a self-contained drawing block. It intercepts p5.js drawing commands within the callback and stores them. begin() and end() are called automatically.

Options:

  • draw (Boolean, optional): If true, the drawing commands will be drawn onto the canvas in addition to being recorded. If false (default), they are only recorded silently without rendering.

Examples

Syntax

buildShape(callback, [options])

Parameters

callback
Function: a function containing the drawing instructions.
options
Object: recording options.

Returns

p5.ShapeCollection: the recorded shape.

Related References