Can I create multiple canvas elements on same page using p5js

You would want to use instance mode. The first few examples use Global Mode and the next few examples use Instance Mode. Instead of using the default canvas, in instance mode you control where p5js puts the canvas element. If you have two containers, you would use:

new p5(leftSketch, 'left');
new p5(rightSketch, 'right');

leftSketch and rightSketch would be functions that take a variable p. That variable is an instance of p5js and you can control each canvas element separately.

Leave a Comment