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 › creating circle line increasing & decreasing
Page Index Toggle Pages: 1
creating circle line increasing & decreasing (Read 594 times)
creating circle line increasing & decreasing
Jul 11th, 2008, 11:04am
 
hi,
i want to create a circle line which is increasing & decreasing softly in size (each single circle), so that it looks like a symetrical wave form.
for creating the circle line i start very simple:

float x;
float x=x+10;
void draw (){
ellipse (x,20, 5,5)
}

now to slightly increase the size of the ellipse (5) and decrease it at a certain value again, i might use some sin function...?

who can help?
thanks!
Re: creating circle line increasing & decreasi
Reply #1 - Jul 11th, 2008, 1:34pm
 
Simple starting point:

int radius1 = 5;
int rMove1 = +1;
int minRadius1 = 5, maxRadius1 = 100;
int xPos1 = 100;
int yPos1 = 200;

int radius2 = 5;
float rMove2 = 0;
int minRadius2 = 20, maxRadius2 = 140;
int xPos2 = 300;
int yPos2 = 200;

void setup()
{
 size(400, 400);
//  frameRate(10);
}

void draw()
{
 background(240);
 noFill();
 
 // Linear
 ellipse(xPos1, yPos1, radius1, radius1);
 radius1 += rMove1;
 if (radius1 > maxRadius1)
   rMove1 = -1;
 else if (radius1 < minRadius1)
   rMove1 = +1;

 // Sinus
 ellipse(xPos2, yPos2, radius2, radius2);
 rMove2 += 0.02;
 radius2 = (int) ((maxRadius2 - minRadius2) * sin(rMove2) + minRadius2);
}
Re: creating circle line increasing & decreasi
Reply #2 - Jul 11th, 2008, 5:04pm
 
thank you so much for this two versions of motion!
..i'll try to get it in my sketch.
maybe i have another question tomorrow.
Re: creating circle line increasing & decreasi
Reply #3 - Jul 11th, 2008, 5:12pm
 
it works!Smiley thank you!
Page Index Toggle Pages: 1