How can I share methods that call P5.js functions between two different sketches/canvases?

Is there a way to share common methods between two different sketches/canvases? It only works if I’m not referencing any P5.js methods. In the example below there are two sketches and each is loaded …

P5 try to factorize Graphics and Canvas code

I want to factorize code for drawing same thing in a graphics or in the standard canvas. ( In my real program, i want to have autonomous class that draw themselves in some context given at …

How to use windowWidth and windowHeight outside of setup()?

I need the screen dimensions for a project, but trying windowWidth and windowHeight yields an error saying I can’t use them outside of setup(). I also tried defining the windowWidth and Height to a …