We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › problem applying mask to image array
Page Index Toggle Pages: 1
problem applying mask to image array (Read 377 times)
problem applying mask to image array
Jul 23rd, 2008, 6:42pm
 
I'm trying to apply a mask to all images in an array. I've looked for help in the discussion and the closest thing I could find was this:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1197253210;start=0#0
which didn't help me out.

I'm pretty sure I'm naming the array incorrectly when I'm trying to draw my mask:
images[].mask(maskImg);

Here's the full code:
int xpos;
int xpos;
int ypos;
int xWidth;
int yHeight;
int count = 0;
int numImages = 87;
PImage[] images = new PImage[numImages];
PImage maskImg;

void setup() {
 size(1450, 500);
 background(0);
 frameRate(3);
 xpos = 1450;
 ypos = 10;
 for (int i = 1; i <= images.length; i++) {
   images[i-1] = loadImage("B (" + i + ").jpg");
 }
 maskImg = loadImage("Jamaica_51.jpg");
}

void draw() {
 images[].mask(maskImg); //draws the mask
 if (count < images.length) {
   tint(225, 225, 225, createTint());
   image(images[count], xpos, ypos);
   count++;
 }
 for (int j = distanceBtwnImages(); j <= distanceBtwnImages(); j++) {
   xpos = xpos - j;
 }
}

int createTint(){
 int numberIs;
 numberIs = 50;
 return numberIs;
}

int distanceBtwnImages(){
 int numberIs;
 numberIs = 35;
 return numberIs;
}
Re: problem applying mask to image array
Reply #1 - Jul 23rd, 2008, 7:08pm
 
You have to mask each image seperately:

Code:
PImage[] images = new PImage[numImages];
PImage maskImg;

void setup() {
size(1450, 500);
background(0);
frameRate(3);
xpos = 1450;
ypos = 10;
maskImg = loadImage("Jamaica_51.jpg");

for (int i = 1; i <= images.length; i++) {
images[i-1] = loadImage("B (" + i + ").jpg");
images[i-1].mask(maskImg);
}
}
Re: problem applying mask to image array
Reply #2 - Jul 23rd, 2008, 8:51pm
 
This solved my problem! Thanks!!
Page Index Toggle Pages: 1