We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have some existing web pages that would be enhanced by the addition of a sketch or two if it were possible. But, in all the examples that I've seen, the sketch appears to replace the entire body of the web page. Is there a way to just put a sketch in a div?
Answers
You need to use an "instance mode", then, you can parent canvas to an existing div.
@Ater, we don't need "instance mode" in order to parent() the
<canvas>
created by createCanvas().It works for both modes. >-)
However for more than 1 sketch, the others needs to use the "instance mode" approach.
Or at least put each 1 into an
<iframe>
. 8-XThis length thread below shows both approaches. Worth checking out: :D
https://forum.Processing.org/two/discussion/14798/how-to-split-a-p5-js-sketch-into-multiple-files
https://github.com/processing/p5.js/wiki/Embedding-p5.js