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 & HelpPrograms › redrawing background
Page Index Toggle Pages: 1
redrawing background (Read 724 times)
redrawing background
Apr 19th, 2007, 7:42am
 
Hello, Folks,

I am looking for some help with replacing the background image with a blurred version of the last image rendered.

void draw(){
 last = //what just was rendered, but made blurry
 tint(0, 153, 204);
 background(last);
 //move objects
}

so I can have better control over trails of moving objects.

Thanks for your help, Greg
Re: redrawing background
Reply #1 - May 5th, 2007, 4:25am
 
Here ya go:
Quote:

color last[], current[];

void setup() {
 loadPixels(); //Initialize the pixels array
 last = new color[pixels.length]; //Initialize the array for the last frame
 current = new color[pixels.length]; //Initialize the array for th current frame
}

void draw(){
 arraycopy(last,pixels); //Copy "last" array to pixels array
 updatePixels(); //Update pixels array
 //move objects
 loadPixels(); //Get the pixels array form current frame image
 arraycopy(pixels,current); //Copy pixels array to "current" array
 filter(BLUR, 1); //Apply blur filter
 arraycopy(pixels,last); //Copy the pixels array with blur filter to the "last" array
 arraycopy(current,pixels); //Copy "current" array (pixels array before the blur filter) back to the pixels array
 updatePixels(); //Update pixels arra
}  
Page Index Toggle Pages: 1