blendMode in instance mode

All members belonging to class p5, that is, anything listed here: reference | p5.js

Needs to be prefixed w/ a variable referencing the p5 instance it is acting upon.

In your case that variable is the callback sketch1()'s parameter named p: reference | p5.js

Here’s some sketch which has both global & instance mode versions:

Alternatively you can simply forget about instance mode and just have each global mode sketch inside an <iframe> tag:
Developer.Mozilla.org/en-US/docs/Web/HTML/Element/iframe

As you can see in action from the link below w/ 2 global mode & 2 instance mode of the same sketch running on the same page:
Matter-JS-Bouncing-Colorful-Balls.Glitch.me/all.html

You can hit CTRL+U in order to inspect its “all.html” file btW.

1 Like