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
fade out? (n00b) (Read 382 times)
fade out? (n00b)
May 20th, 2006, 10:07pm
 
hey guys, just starting to get my feet wet w/ processing and wondered if someone could help me out...

what i want is, after a certain amount of lines have been drawn to the screen (say 500 for example), to start slowly fading out the older lines in the order that they were drawn to the screen.

this is the code i have so far (its just a crazy "sketch" program that draws lines all over the place) and was wondering if someone would be willing to write psuedocode or just outline the basic theory for the ideal way to achieve this type of fade in Processing.

thanks so much.
-j

Quote:


int width =800;
int height = 600;
int leftBounds = 20;
int topBounds = 20;
int x=400;
int y=300;
int rightBounds = width - leftBounds;
int bottomBounds=height-topBounds;
int baseMax=20;
int randomMax=10;
int maxLines=2000;
int counter=0;

void setup(){
 size (width, height);
 background (100);
 stroke (255);
 smooth();
}

void draw(){
println (rightBounds);
 counter++;
 int maxDist = baseMax *  round(random(randomMax));
 int minDist = 2;
 int newX = x + (direction() * (minDist + round(random(maxDist))));
 int newY = y + (direction() * (minDist + round(random(maxDist))));
 if (newX < leftBounds){ newX = leftBounds;  }
 if (newX > rightBounds){ newX = rightBounds; }
 if (newY < topBounds){ newY = topBounds; }
 if (newY > bottomBounds) { newY = bottomBounds;}
 line (x,y, newX, newY);
 x=newX;
 y=newY;
}

int direction(){
 int dir= random(1) < 0.5 ? 1 : -1;
 return dir;
}


Re: fade out? (n00b)
Reply #1 - May 26th, 2006, 10:26pm
 
What you're intending is already explained in the Learning section.

Storing input

Experiment with the code there and you should be able to figure it out.
Re: fade out? (n00b)
Reply #2 - May 28th, 2006, 11:40am
 
just try to draw a rectangle with the dimensions of your application. The rect should have the color of your background and an alpha value. put this in a loop and your application should fade out
Page Index Toggle Pages: 1