The createGraphics() function can be used to create a new p5.Graphics object, which can serve as an off-screen graphics buffer within the canvas. Off-screen buffers can have different dimensions and properties than their current display surface, even though they appear to be existing in the same space.
Create Graphics by p5.js Contributors and the Processing Foundation is licensed under CC BY-NC-SA 4.0.
Related Examples

Black canvas with a very dark grey rectangle in the middle. A white circle is at the edge of the rectangle.
Create Graphics
Draw imagery off-screen.

Two curving lines made of repeating white circles and squares with black outlines, on a black and white background.
Multiple Canvases
Use Instance Mode to put multiple canvases on the page.

Two spheres broken up into a square grid with a gradient in each grid.
Shader as a Texture
Generate a texture for a 3D shape using a shader.