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 › Arc Mathematics
Page Index Toggle Pages: 1
Arc Mathematics (Read 1236 times)
Arc Mathematics
Oct 17th, 2006, 9:10pm
 
So I know how to draw a medicine wheel out of arcs, but not how to code it in such a way that would allow it to jump randomly in the code below. Help?

arc(200, 205, 100, 100, 0, PI/2);
arc(200, 205, 100, 100, PI/2, PI);
arc(200, 205, 100, 100, PI, TWO_PI-PI/2);
arc(200, 205, 100, 100, TWO_PI-PI/2, TWO_PI);



void setup()
{
 size(600, 600);
 background(185,216,255);
 color(57,114,185);
 noStroke();
 ellipseMode(CENTER_RADIUS);
}

void draw()

{

 if(mousePressed==true)
 {
   noStroke();
   wheel a = new wheel();
   a.draw();  
 }
 else
 {
   rotellipse e = new rotellipse();
   e.ellipsechange(mouseX, mouseY, pmouseX, pmouseY);
 }

 // black rectangle covers images
 if(keyPressed)
 {
   if(key==' ')
   {
     background(0);
   }
 }    
}

// draws ellipses
class wheel
{
 int wheels = 100;
 float xpos[] = new float[wheels];
 float ypos[] = new float[wheels];
 float b = random(100);

 void draw()
 {
   xpos[wheels-20] = mouseX;
   ypos[wheels-20] = mouseY;

   for(int i=0; i<wheels; i++)
   {
     // ARCS HERE
   }
 }
}  

// draws ellipses randomly
class rotellipse
{
 float move;
 void ellipsechange(int x, int y, int px, int py)
 {
   smooth();  
   move = abs(x-px) + abs(y-py);  
   translate(mouseX, mouseY);

   stroke(10, 0, 10/2);
   ellipse(5,5,5+move,5+move);
 }
}
Re: Arc Mathematics
Reply #1 - Dec 3rd, 2006, 9:46pm
 
Hi,
I got your program to learn and practice control with the mouse.
I might send you a modified version of it later.

The circles you draw follow the mouse.
What do you mean by <allow it to jump randomly> ?

I'm sending you the code I have right now:

////////////////////////////////////////////////////
static int nRGB = 256;

void setup()  
{
 size(600, 600);
 background(185,216,255);
 color(57,114,185);
 noStroke();
 ellipseMode(CENTER_RADIUS);

}

void draw()

{
 //// draw an egg with mouse-changing color
 fill(96);
 arc(150, 50, 50, 100, 0, PI/2);
 fill((mouseX*nRGB)/width,144,(mouseY*nRGB)/height);
 arc(150, 50, 150, 100, PI/2, PI);
 fill(160);
 arc(150, 50, 150, 50, PI, TWO_PI-PI/2);
 fill((mouseY*nRGB)/height,208,(mouseX*nRGB)/width);
 arc(150, 50, 50, 50, TWO_PI-PI/2, TWO_PI);
 fill(255);

 if(mousePressed==true)
 {
   noStroke();
   wheel a = new wheel();
   a.draw();  
 }
 else
 {
   rotellipse e = new rotellipse();
   e.ellipsechange(mouseX, mouseY, pmouseX, pmouseY);
 }

 // black rectangle covers images
 if(keyPressed)
 {
   if(key==' ')
   {
     background(0);
   }
 }    
}

// draws ellipses
class wheel
{
 int wheels = 50;  
 float xpos[] = new float[wheels];  
 float ypos[] = new float[wheels];  
 float b = random(100);

 void draw()
 {  
   xpos[wheels-20] = mouseX;  
   ypos[wheels-20] = mouseY;  

   for(int i=0; i<wheels; i++)  
   {  
     // ARCS HERE
     stroke(128);
     int xx=int(random(width));
     int yy=int(random(height));
     int rx=int(random(10,width/6));
     int ry=int(random(10,height/6));
     arc(xx, yy, rx, ry, 0, PI/2);
     arc(xx, yy, rx, ry, PI/2, PI);
     arc(xx, yy, rx, ry, PI, TWO_PI-PI/2);
     arc(xx, yy, rx, ry, TWO_PI-PI/2, TWO_PI);
   }
 }
}    

// draws ellipses randomly
class rotellipse
{
 float move;
 void ellipsechange(int x, int y, int px, int py)  
 {  
   smooth();  
   move = abs(x-px) + abs(y-py);  
   translate(mouseX, mouseY);

   stroke(10, 0, 10/2);
   ellipse(5,5,5+move,5+move);  
 }
}
Page Index Toggle Pages: 1