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 › infinite concentric circles
Page Index Toggle Pages: 1
infinite concentric circles (Read 827 times)
infinite concentric circles
Apr 15th, 2009, 7:27pm
 
hi there,

this is driving me insane...

i want to create inifinite concentric circles that follow the mouse... I can do it the longk, dumb-way round... like this:

int grow = +1;
int d = 1;
int x = 100;
int y = 100;


void setup() {
size(100, 100);

smooth();
noFill();
strokeWeight(20);
frameRate(100);
}

void draw() {
 background(50);

  d = (d + grow);
 if (d > 40){
   d = 1;
 }
           stroke(100);
           ellipse(mouseX, mouseY, d, d);
           stroke(200);
           ellipse(mouseX, mouseY, d+20, d+20);
           stroke(100);
           ellipse(mouseX, mouseY, d+40, d+40);
           stroke(200);
           ellipse(mouseX, mouseY, d+60, d+60);
           stroke(100);
           ellipse(mouseX, mouseY, d+80, d+80);
           stroke(200);
           ellipse(mouseX, mouseY, d+100, d+100);
           stroke(100);
           ellipse(mouseX, mouseY, d+120, d+120);
           stroke(200);
           ellipse(mouseX, mouseY, d+140, d+140);
           stroke(100);
           ellipse(mouseX, mouseY, d+160, d+160);
           stroke(200);
           ellipse(mouseX, mouseY, d+180, d+180);
           stroke(100);
           ellipse(mouseX, mouseY, d+200, d+200);
           stroke(200);
           ellipse(mouseX, mouseY, d+220, d+220);
           stroke(100);
           ellipse(mouseX, mouseY, d+240, d+240);
           stroke(200);
           ellipse(mouseX, mouseY, d+260, d+260);
           stroke(100);
           ellipse(mouseX, mouseY, d+280, d+280);
           stroke(200);
           ellipse(mouseX, mouseY, d+300, d+300);
           stroke(100);
           ellipse(mouseX, mouseY, d+320, d+320);
           stroke(200);
           ellipse(mouseX, mouseY, d+340, d+340);
           stroke(100);
           ellipse(mouseX, mouseY, d+360, d+360);
           stroke(200);
           ellipse(mouseX, mouseY, d+380, d+380);
           stroke(100);
           ellipse(mouseX, mouseY, d+400, d+400);
}


But I want to be able to do it more succinctly, like this:

int grow = +1;
int d = 1;

void setup() {
size(200, 200);
smooth();
frameRate(100);
}

void draw() {
 background(50);
 d = (d + grow);
 if (d > 300){
   d = 1;
 }
 noFill();
 stroke(200);
 ellipse(100, 100, d, d);

}


But I can't for the life of me figure out how to tell heaps of circles to grow. What do I do, create a function?

Can anyone help?

thx


 


Re: infinite concentric circles
Reply #1 - Apr 15th, 2009, 8:48pm
 
Perhaps something like this...
Code:

int d = 1;

void setup() {
size(200, 200);
smooth();
frameRate(100);
}



void draw() {
background(50);
if (d > 300){
d = 1;
}
noFill();
stroke(100);
ellipse(mouseX, mouseY, d, d);
stroke(200);
ellipse(mouseX, mouseY, d+20, d+20);
d = d+20;

}
Re: infinite concentric circles
Reply #2 - Apr 15th, 2009, 8:55pm
 
yeah that's not quite it, I can do that,

but notice how you would have to continually draw each ellipse with d+20? you would have to go with line after line of ellipse d + 40, d + 60 etc etc

Sad

i've come over to processing from timelines and keyframes, i'm having a hard trouble understanding how work with time in the coded world...

like, how would you say, (if it's been .5 seconds, draw another circle that grows infinitely)

Re: infinite concentric circles
Reply #3 - Apr 15th, 2009, 8:58pm
 
programming is mind bending

i really can't wait to think like it a bit more
Re: infinite concentric circles
Reply #4 - Apr 15th, 2009, 8:59pm
 
I went back to update my example but you beat me here... Played with it a bit... how about this...
Code:

int grow = +1;
int d = 1;
int x = 100;
int y = 100;

void setup() {
 size(100, 100);

 smooth();
 noFill();
 strokeWeight(20);
 frameRate(100);
}

void draw() {
 background(50);

 d = (d + grow);
 if (d > 40){
   d = 1;
 }
 for(int i = 0; i < 400;){
   stroke(100);
   ellipse(mouseX, mouseY, d+i, d+i);
   i = i+20;
   stroke(200);
   ellipse(mouseX, mouseY, d+i, d+i);
   i = i+20;
 }
}
Re: infinite concentric circles
Reply #5 - Apr 15th, 2009, 9:02pm
 
jeef thats it, thanks so much!!
Page Index Toggle Pages: 1