//Ellipse variables
float angle = 0.0;
float speed2 = 0.02;
float radius = 100.0;
float dx = 3.0;
float dy = 1.5;
float nr = 0.0;
float inc = 0.05;
//Square variables
int destX = int(random(width));
int destY = int(random(height));
int x = 0;
int y = 0;
int speed = 20;
int assign = int(random(1.99));
void setup() {
size(400, 400);
smooth();
}
void draw() {
background(41, 6, 29);
noStroke();
fill(131, 86, 106);
float x2;
float y2;
float x3;
float y3;
angle += speed2;
nr += inc;
x2 = 200 + sin(angle)*radius;
y2 = 200 + cos(angle)*radius;
x3 = x2 + sin(angle*dx)*(noise(nr)*radius);
y3 = y2 + cos(angle*dx)*(noise(nr)*radius);
ellipse(x3, y3, 30, 30);
fill(196, 87, 158);
ellipse(x3 + 2, y3 - 2, 27, 27);
stroke(70);
fill(200);
strokeWeight(2);
if (assign == 0) {
if (dist(x, 0, destX, 0) < speed) {
assign = int(random(1.99));
destX = int(random(width));
}
if (destX > x) {
x += speed;
} else {
x -= speed;
}
}
if (assign == 1) {
if (dist(0, y, 0, destY) < speed) {
assign = int(random(1.99));
destY = int(random(height));
}
if (destY > y) {
y += speed;
} else {
y -= speed;
}
}
rect(x, y, 20, 20);
}
Exercise 10: Animate two shapes of your own design. Give one a mechanical motion and give the other a more organic motion.