Function can't be displayed in second canvas within p5.js

I created two separate canvases with p5.js by creating a new instance (see line 58 in my javascript file). Then I inserted a function called "firstAnimation" that will be displayed in one of the canvases.

Run the code here –> https://editor.p5js.org/MaximilianFreitag/sketches/fP46XAHnP

In line 45 of my javascript file p5.js is telling me that my function "secondAnimation" does not exist. So I can not output another animation in this canvas

In line 49 I can still draw a circle inside the second canvas with sketch.circle(100,100,100).

How can I display my second function in the second canvas so that I have two animations?

enter image description here

I can only add a simple circle

>Solution :

You nead to specify where to draw a line. in second function just add myp5.line and just run function secondAnimation() without sketch.

Leave a Reply