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 › simple geometry problem
Page Index Toggle Pages: 1
simple geometry problem (Read 879 times)
simple geometry problem
Apr 4th, 2006, 2:09am
 
Hi,

This is a very simple program that creates a spirographic image. I'm having trouble thinking of a way of making the rotation point of the spirograph  align with the centre of the image. Any help would be appreciated.

size(500,500);
rectMode(CENTER);
for(int x=500;x>0;x=x-2){
 translate(width/3, height/150);
rotate(PI/6);
 rect(100,100,x,x);
 fill((x/2)-30);
 stroke(255);}
Re: simple geomtry problem
Reply #1 - Apr 4th, 2006, 2:48am
 
errrr...
Code:

size(500,500);
rectMode(CENTER);
translate(width/2.8, -height/8); // addition - mildly central
for(int x=500;x>0;x=x-2){
translate(width/3, height/150);
rotate(PI/6);
rect(100,100,x,x);
fill((x/2)-30);
stroke(255);
}

I pondered reverse engineering your equation and then ran away in fear.
Re: simple geomtry problem
Reply #2 - Apr 4th, 2006, 3:48am
 
better fear than disgust I guess... thanks for the quick fix.
Re: simple geometry problem
Reply #3 - May 2nd, 2006, 5:37pm
 
try this:


int x;
float y = 0.1;

void setup()

{
 size(500,500);
 rectMode(CENTER);
 smooth();
}

void draw()
{
 translate(width/2, height/2); // addition - mildly central
 //   translate(2, height/2);  
 rotate(PI/1+y);  
 rect(y,y,x,x);

 fill((x/2)-1);
 stroke(255);

 x=x+1;
 y=y+0.08;
 if(x==100)
 {
   x=0;


 }

}

void mousePressed()
{
 saveFrame("image-###.tif");
}  



change the y float value that gets added on at the end, and change the "if x==" value too.  Fun.
Re: simple geometry problem
Reply #4 - May 28th, 2006, 8:22am
 
fun indeed. thanks stevecooley...
Page Index Toggle Pages: 1