Hello! I want to know if there was a way to make sure an image was loaded when loading it outside Preload. I sometimes get “Uncaught ReferenceError: loadImage is not defined” and sometimes it loads. It doesnt seem to be predictable. The reason why I need to load outside preload is because I am creating a “preview art on your wall” module where clients load pictures of their wall at runtime in a product page via a “upload image” button in the page. They can change their wall as they please.
- Before issuing loadImage() assign
null
to the p5.Image global variable. - Let’s say that variable is named img.
- Then inside draw() callback have a statement similar to this:
img && image(img, width >> 1, height >> 1);
3 Likes
It does seem to be working. I’m going to run it about 20 times and if it does not throw the error again I will call this the solution. Thanks.