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 › applying blur to an ellipse
Page Index Toggle Pages: 1
applying blur to an ellipse (Read 905 times)
applying blur to an ellipse
Nov 15th, 2009, 9:08am
 
hey! i need to make a kind of a snow effect and so i thought i could blur some ellipses but the problem is i don't know how to only apply blur once to an ellipse... it keeps adding to the whole frame ( or stage or something) and the ellipses keep getting more blurry as other ellipses are blured on top

i thought i make something like only applying if the frameCount is  less or equal than 1, and reset the frameCount everytime i draw an ellipse but it doesnt work...

here is my code

Code:
 import processing.pdf.*;
Bolas b1 = new Bolas();
PImage img;
void setup(){
// size(640,480,PDF, "postal.pdf");
size(640,480,P2D);

smooth();
background(255);
img = loadImage("arvore.jpg");





}


void draw(){




for(int i = 0; i < 10; i++) {
// noStroke();
int x = (int)random(width);
int y = (int)random(height);
color col = img.get(x,y);
fill(col);
float prop = random(20);
float prop2 =prop;
//ellipseMode(CENTER);
noStroke();
pushMatrix();

b1.desenhar(x,y,prop,prop);
popMatrix();
}



}

class Bolas{


Bolas(){
frameCount = 0;
}

void desenhar(int x, int y , float prop, float prop2){
ellipse(x,y,prop,prop);
if(frameCount<2){
filter(BLUR,5);
}
}
}
Re: applying blur to an ellipse
Reply #1 - Nov 15th, 2009, 3:49pm
 
Without even scrutinizing your code, I see a very common error corresponding to what you describe: you forgot to add a background() call at the start of draw(). So all the drawings of all the frame just cumulate on screen. The background() erases the previous frame, allowing to start from fresh.
Re: applying blur to an ellipse
Reply #2 - Nov 16th, 2009, 2:05am
 
unfortunatly it's not a mistake. My purpose is to have some snow draw a christmas tree by taking the color from an image , so I have to keep the frames there otherwise if i put a background() it would disapear all the drawing it did til that moment. What i want is for the snow particle to be blury but always at the same level, not adding blur.

Is it better if i use some kind of image? but if i use an image it won't be coloured by the image...
Re: applying blur to an ellipse
Reply #3 - Nov 16th, 2009, 2:45am
 
Then draw your snow in a separate PGraphics, to be copied in main sketch once blurred.
Re: applying blur to an ellipse
Reply #4 - Nov 16th, 2009, 8:21am
 
thank you, i'm going to try that!
Page Index Toggle Pages: 1