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 › need help with animation
Page Index Toggle Pages: 1
need help with animation (Read 239 times)
need help with animation
Nov 16th, 2008, 9:23pm
 
Hello!
I have this code so far:

final int NLINHAS = 80; //number of lines
final int COMPINI = 10; //initial length
final int VARCOMP = 20; //length variation
final int LARG = 300;;
final int ALTU = 300;
//caculate the center coordenates
final int XC = LARG / 2;
final int YC = ALTU/ 2;
int xFim, yFim; //line extremity coordenates
int comp = COMPINI; //line length
int varComp = VARCOMP; //length variation
float angulo = 0; //current angle
float varang = (float)(2 * PI / NLINHAS); //calculate the angle increment in radians

void setup() {
 background(255);
 size (LARG, ALTU);
 stroke (100);
 strokeWeight (1);
 noLoop();
 frameRate (20);
 }
 
void draw() {
 //draw the lines
 for (int linha=0; linha < NLINHAS; linha++){
   //calculate the end of the line (xFim, yFim)
   xFim = XC + (int)(comp * cos(angulo));
   yFim = YC - (int)(comp * sin(angulo));
   //verify if (xFim, yFim) is outside of the applet or if the length is negative
   //if it is reduce the length, then the
   //length decreses amd calculate the new point
   if (xFim>LARG || yFim>ALTU || xFim<0 || yFim<0 || comp <0) {
varComp *= -1;
comp += 2*varComp;
xFim = XC + (int)(comp * cos(angulo));
yFim = YC - (int)(comp * sin(angulo));
   }
   //draw the line
   line(XC, YC, xFim, yFim);
   //update the length
   comp += varComp;
   //update the angle
   angulo += varang;
   }
}

My problem is that i want my animation to start with just 1 line. I want the number of lines to be added by 1. So first it will show 1 line then 2 then 3 then 4 and so on.
I think you have to use the line number variable (NLINHAS) with "++" but I'm not sure, and I wouldn't know in what cycle to put it in.
I also want the lines to have a random stroke density.

Would somebody be so kind as to help me figure out a way to animate it in that way. I would very much apreciate it.

Thank you so much!!!
Re: need help with animation
Reply #1 - Nov 17th, 2008, 1:32pm
 
I see you already had help in another thread (Help please).
You should avoid duplicate threads to avoid duplicate efforts... Happy

Of course, feel free to ask new questions (in same thread if relevant to same code base) if you have any.
Re: need help with animation
Reply #2 - Nov 17th, 2008, 4:04pm
 
Hi
Sorry i made this new post because I thought my other one had been locked or something.
I'm kinda new at forums.
Keep well Samantha :)
Page Index Toggle Pages: 1