// prototype circle sequencer int erad = 5; float radius = 150; float maxRadius = 150; int angle = 0; float[] sequence = new float[360]; float endX,endY; float mousepX, mousepY; boolean overball = false; boolean balllock = false; boolean playing = false; void setup() { size(400, 400); background(102); smooth(); framerate(60); ellipseMode(CENTER_RADIUS); PFont font = loadFont("CenturyGothic-10.vlw"); textFont(font, 10); textAlign(RIGHT); } void draw() { stroke(255); background(102); text("press spacebar to restart ", width, 10); endX = (cos(radians(angle))*radius)+width/2; endY = (sin(radians(angle))*radius)+width/2; ellipse(endX, endY, erad, erad); line(width/2, height/2, endX, endY); stroke(200); for(int i=1; i<360; i++) { point(((cos(radians(i))*sequence[i])+width/2), ((sin(radians(i))*sequence[i])+width/2)); } if(playing) { if(sequence[angle] != 0) radius = sequence[angle]; angle++; if(angle>=360) angle = 0; } else { if(mouseX > endX-erad && mouseX < endX+erad && mouseY > endY-erad && mouseY < endY+erad) { overball = true; } else { overball = false; } if(angle == 359) { playing=true; } } } void keyPressed() { if(key == ' ') { restart(); } } void restart() { angle = 0; playing = false; sequence = new float[360]; radius = maxRadius; } void mousePressed() { if (overball) { balllock = true; } else { balllock = false; } } void mouseDragged() { radius = min(dist(width/2,height/2,mouseX,mouseY),maxRadius); angle = int( degrees( atan2( ((mouseY- height/2.0)/(height/2.0)), ((mouseX- width/2.0 )/(width/2.0)) ) ) ); // WHOA if(angle < 0) angle = angle+360; sequence[angle] = radius; } void mouseReleased() { balllock = false; }