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.
Page Index Toggle Pages: 1
"erase" pixels (Read 442 times)
"erase" pixels
Oct 19th, 2008, 5:28am
 
hi all.

i'm needing to slowly erode pixels from a layered stack of images and am wondering about suggested best practices. i've been tinkering with loadPixels/updatePixels, as well as the related get and set functions. I'm able to change the color of a pixel, but not simply adjust the transparency of it (which would be ideal to achieve an eroding effect).

Any advice/input would be really helpful. Thanks!
Re: "erase" pixels
Reply #1 - Oct 19th, 2008, 11:06am
 
You can set the value of the pixel to its original color minus some amount of alpha. Processing makes it easy to find this value with the color function. The lerpColor() function allows you to easily transition between any two color values.

Code:

float amt = 0.5;
int colorWithZeroAlpha = initialColor - color(0,0,0,255);
int newColor = lerpColor( initialColor, colorWithZeroAlpha, amt );


http://processing.org/reference/lerpColor_.html
Page Index Toggle Pages: 1