//trevor chambers
int ellipsesize
= 10;
float xpos = 250;
float ypos = 250;
float xpos2 = 250;
float ypos2 = 250;
float xspeed = 2;
float yspeed = 2;
float xcol, ycol, xcol2, ycol2;
float dist, dist2;
int xdirection = 1;
int ydirection = 1;void setup() {
size(500, 500); // Defines window size
framerate(30); // Cycling through 30 frames a second
background(0);
stroke(10,20,75);
for(int x=0; x<500; x=x+10){
line(x,0,x,500);
line(0,x,500,x);
}
}
void loop() {
if(mousePressed) {
background(0);
stroke(10,20,75);
for(int x=0; x<500; x=x+10){
line(x,0,x,500);
line(0,x,500,x);
}
} else {}
xpos = xpos + int(random(-10, 10));
ypos = ypos + int(random(-10, 10));
xpos2 = xpos2 + int(random(-10, 10));
ypos2 = ypos2 + int(random(-10, 10));
if (xpos > width-ellipsesize || xpos < 0) {
xpos = 250;
}
if (ypos > height-ellipsesize || ypos < 0) {
ypos = 250;
}
if (xpos2 > width-ellipsesize || xpos2 < 0) {
xpos2 = 250;
}
if (ypos2 > height-ellipsesize || ypos2 < 0) {
ypos2 = 250;
}
//Color
dist = sqrt(sq(abs(xpos - 250)) + sq(abs(ypos - 250)));
dist2 = sqrt(sq(abs(xpos2 - 250)) + sq(abs(ypos2 - 250)));
//Drawing the shapes
stroke(100);
fill(dist);
ellipse(xpos, ypos, ellipsesize, ellipsesize);
ellipse(ypos, xpos, ellipsesize, ellipsesize);
fill(dist2);
ellipse(xpos2, ypos2, ellipsesize, ellipsesize);
ellipse(ypos2, xpos2, ellipsesize, ellipsesize);}