int numSpots = 48;
float x = width/2;
float y = height/2;
float angle = 0;
float [] spots = new float[numSpots];
float distance;
float sShake;
void setup() {
size (600, 400);
smooth();
ellipseMode(CENTER);
for (int i = 0; i < spots.length; i++) {
float z = i * (PI/24) - PI;
spots[i]=z;
}
}
void draw() {
background(255);
fill(0);
// angle = random(-0.1, 0.1);
translate(width/2, height/2);
float angle = atan2(mouseY-height/2, mouseX-width/2);
//rotate(angle);
ellipse(0, 0, 75, 75);
fill(255);
ellipse(-15, 0, 28, 28);
ellipse(15,0, 28, 28);
fill(0);
ellipse(-15, 0, 2, 2);
ellipse(15, 0, 2, 2);
for (int i = 0; i < spots.length; i++) {
float ca = cos(spots[i]);
float sa = sin(spots[i]);
distance = dist(width/2, height/2, mouseX, mouseY);
if (((distance < 250) && (spots[i])-angle < PI/(distance/12)) && (spots[i]-angle > -PI/(distance/12))){
distance = dist(width/2, height/2, mouseX, mouseY) - 5;
sShake = random(50, distance);
}
else { sShake=random(50, 60);}
line (x + ca*32.5, y + sa*32.5, x + ca*sShake, y + sa*sShake);
}
}
Everett - L
on Monday, Nov 24, 2008 – 8:29 am