I am running a p5.js sketch on a flask server. I want to draw several canvases, so i instanced my code like Daniel Schiffman showed in his "9.11: Instance Mode (aka "namespacing") - p5.js Tutorial"-Video, but when i run the code it gives me "Uncaught ReferenceError: p5 is not defined" on the line i instantiate my canvas
var drawCanvas = new p5(firstcanvas);
When i run the code in the p5 web editor it works.
The script tag in my html looks like this
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.3.1/p5.js"
integrity="sha512-a5hlZKgpC1LVAuKgVeXdP0D9Yfacj0hLtNdzx9zFMkIWRrQyO37KtIPiqArGmVuaBYu3ON6Vt0N3+G/JaLXQYQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
so thats the newest version. any idea? thanks
Minimal reproducive example:
var firstCanvas = function(a) {
let abc;
a.setup = function() {
abc = 100;
a.createCanvas(800, 600);
a.background(260);
n = a.createButton("NEW");
n.position(20, a.height + 225);
n.mousePressed(clearCanvas);
}
a.draw = function() {
a.fill(10);
a.rect(a.mouseX, a.mouseY, abc, 50);
}
function clearCanvas() {
a.background(260);
}
}
var drawCanvas = new p5(firstCanvas);
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.3.1/p5.js"
integrity="sha512-a5hlZKgpC1LVAuKgVeXdP0D9Yfacj0hLtNdzx9zFMkIWRrQyO37KtIPiqArGmVuaBYu3ON6Vt0N3+G/JaLXQYQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>