user525032
user525032

Reputation:

undefined property when setting mask with processing js

I'm using processingJS to put a mask on the image and output it

/* @pjs preload="mask.png"; */
PImage mask = loadImage('mask.png');
PImage img = loadImage(img);

image(img, 0,0); // works - outputs image
img.mask(mask);
image(img, 0,0); // Uncaught TypeError: Cannot set property '3' of undefined

Upvotes: 0

Views: 509

Answers (1)

The fact that this works at all is slightly mystifying, because of the PImage img = loadImage(img) line: you've not declared img yet, but use it as argument for loadImage anyway =)

I would recommend first fixing the code so that you only use declared variables as function arguments (perhaps with a preload for 'image.png' in addition to 'mask.png' and loading that into your img variable) and then seeing if you're still having problems.

Upvotes: 2

Related Questions