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 › Boxlike spiral
Page Index Toggle Pages: 1
Boxlike spiral (Read 294 times)
Boxlike spiral
Feb 2nd, 2009, 11:56pm
 
I need to make a program that draws a spiral composed of 50 different lines all connected that make a spiral figure in the center of the environment.  I'm having a lot of trouble getting this.  If anyone could help me with a program that can accomplish this, or start me off on the right path it would be greatly appreciated.


thanks
Re: Boxlike spiral
Reply #1 - Feb 3rd, 2009, 1:13am
 
Yes! OK, on the first run... :-P
Code:
int lineNb = 50;
int lengthIncrement = 7;

void setup()
{
 size(500, 500);
 background(#99BBFF);
 
 strokeWeight(2);
 int lineLength = 5;
 int x, y;
 int px, py;
 px = x = width / 2;
 py = y = height / 2;
 
 for (int i = 0; i < lineNb; i++)
 {
   switch (i % 4)
   {
   case 0:
     x -= lineLength;
     break;
   case 1:
     y -= lineLength;
     break;
   case 2:
     x += lineLength;
     break;
   case 3:
     y += lineLength;
     break;
   }
   line(px, py, x, y);
   px = x; py = y;
   lineLength += lengthIncrement;
 }
}
Re: Boxlike spiral
Reply #2 - Feb 3rd, 2009, 1:24am
 
thank you very much Philho,
Page Index Toggle Pages: 1