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 › Blend Mode Problem?Is it a bug
Page Index Toggle Pages: 1
Blend Mode Problem?Is it a bug? (Read 492 times)
Blend Mode Problem?Is it a bug?
Jun 16th, 2009, 2:47pm
 
Hi,

I try to change Image's Blend mode randomly. However, I can't do. Processing warns about last variable. It says, last variable in blend have to be String not int?????? My code is basically like this;

String[] modeArray = {"ADD","SUBTRACT","MULTIPLY"};
int index;

PImage mage;

void setup()
{
 ....

 mage = loadImage("foo.jpg");
 image(mage , 0, 0, width, height);
}

void draw()
{
  index = round(random(3));
  mage .blend(mage , 0, 0, width, height, 0, 0,round(random(width)), round(random(height)),modeArray[index] );
}
Re: Blend Mode Problem?Is it a bug?
Reply #1 - Jun 16th, 2009, 7:45pm
 
dont know if thats the problem but instead of round(random(3)); you should use int(random(3); giving you 0, 1, 2... and not 0,1,2,3 like round would do.
Re: Blend Mode Problem?Is it a bug?
Reply #2 - Jun 17th, 2009, 1:22am
 
The compiler is right...
You do:
blend(img, 0, 0, 33, 100, 67, 0, 33, 100, SUBTRACT);
not
blend(img, 0, 0, 33, 100, 67, 0, 33, 100, "SUBTRACT");
Here, SUBSTRACT is an int constant.

So correct with:
int[] modeArray = { ADD, SUBTRACT, MULTIPLY };
Page Index Toggle Pages: 1