We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys, i have a file called main.js that is written in instance mode and, in the same folder, a mandelbrot.js file that contains a function object in wich i use the color() function. The problem is that i cant access the p5 namespace from the mandelbrot.js file so i get an error.
Answers
Pretty sure I posted a demo of how to address this recently. This uses the alternate, less verbose instance mode code:
Also I noticed this line in your code:
p.m = new mandelbrot(p.createImage(p.height, p.width));
where
p
is the reference to the p5 instance. It's bad practice to arbitrarily attach properties to a library object instance like this: you might inadvertently override an internal property which could cause you all kind of very hard to trace bugs... Create your own global object to store your variables!Made an online CodePen demo for it as well. Check out the link below: :bz http://CodePen.io/anon/pen/mPvpOq?editors=1010
Alternative w/ DataView and RGBa order for color:
http://CodePen.io/anon/pen/YWWRaO?editors=0010