alphachapmtl
Full Member
Offline
Posts: 128
Canada
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); } }