Procedural Drawing: moving eyeballs
float x=0 ; //location for the face
float x2=0 ;//location for the eyes
int dirX = 1; //direction for the face
int dirX2 = -1; //direction for eyes
float speedX = 0.5; //speed of face
float speedX2 = 0.001; //speed of eyes
void setup () {
size(400, 400);
background(0);
}
void draw () {
background(0);
noFill();
//condition for the direction of the face to change
x += speedX * dirX;
if (x <= -200) {
// x = -25;
dirX = - dirX;
}
if (x >=200) {
dirX = -1;
}
for (int i = -200; i <= 600; i+=70) {
for (int i2 = 25; i2 <=400; i2+=70) {
stroke(i, random(200), random(255));
strokeWeight(2);
noFill();
ellipse(i+x, i2+(random(-1.5, 1.5)), 50, 50);
arc(i+x, i2+(random(-1.5, 1.5))-7, 40, 40, radians(50), radians(130));
for (int i3 = -200; i3 <= 500; i3+=70) {
//condition for the direction of the face to change
x2 += speedX2 * dirX2;
if (x2 <= -100) {
// x = -25;
dirX2 = - dirX2;
}
if (x2 >= 200) {
dirX2 = -1;
}
strokeWeight(1);
ellipse(i3-8+x2, i2+(random(-2, 2))-6, 10, 10);
ellipse(i3+8+x2, i2+(random(-2, 2))-6, 10, 10);
}
}
}
save ("capture.png");
}

Comments
Post a Comment