- Each instance of p5 got a
<canvas>
element (HTMLCanvasElement) attached to it. - Just like a Processing Java Mode’s PApplet got a canvas (PGraphics) as well.
- When we call createCanvas(), it returns a p5.Renderer object; which is a subclass of p5.Element btW.
- Besides the main
<canvas>
, we can create additional offscreen canvases via createGraphics(). - However, it returns a hackish wrapper p5.Graphics instead of an actual p5.Renderer!
- A p5.Graphics got all of the properties of a p5 instance, besides those inherited by p5.Element.
- We can even access TAU and call random(), cos(), etc. from it!
- Notice in my online sketch “Rotating Cube”, I’m calling mouseMoved() method over the p5.Renderer object returned by createCanvas().