I don’t think there’s a need to use a nested div. Instead, draw the second canvas/PGraphic onto the main. (Sounds like you already started looking into this )
But how to draw/add elements inside the main canvas ? For example if I use .draw() to draw the graphics, or when add a checkbox or whatever, all goes below the canvas instead of inside the canvas as expected. I don’t understand… I tried to use .parent(canvas) but it doesn’t seem to change anything. Do I have to use ‘position’ instead, or is there a better solution ?
Could you provide the code that recreates this problem? What also would be helpful is a more detailed description of the desired behavior vs. the current behavior.
Solved, I was thinking the Canvas was like the main window of a p5.js project, on which every elements (graphics or inputs) would be attached to. I understand now that the canvas is optional and is just like all other elements
You are recommended to have 0 or 1 canvas within a global sketch or sketch instance. And more graphics buffers (which may be shown) with createGraphics.
This method should be called only once at the start of setup. Calling createCanvas more than once in a sketch will result in very unpredictable behavior. If you want more than one drawing canvas you could use createGraphics (hidden by default but it can be shown).
You can also have multiple instance mode sketches – each with their own canvas.