Overlapping Ellipses

 

show code

int rad = 2;        // margin
float xpos, ypos;    // Starting position of shape
float xspeed = 8;  // Speed of the shape
float yspeed = 2;  // Speed of the shape
int xdirection = 1;  // Left or Right
int ydirection = 0;  // Top to Bottom

void setup() {
size(600, 200);
frameRate(16);
background(0);
//stroke(100);
noStroke();

xpos = 2;
ypos = height/2;
}

void draw() {
strokeWeight(random(0, 3));

float randomR = random(0, 50);
float randomG = random(100, 200);
float randomB = random(100, 255);
float randomA = random(0, 100);
float randomWidth = random(0, 150);
float randomHeight = random(0, 150);

xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
for (float x = 10; x < width; x += 20) {
for (float y = 10; y < height; y += 20) {
//      point(x, y);
}
}

if (xpos > width-rad || xpos < rad) {
background(0);

xpos = rad;
fill(randomR, randomG, randomB, randomA);
}
if (ypos > height-rad || ypos < rad) {
ydirection *= -1;
fill(randomR, randomG, randomB, randomA);
}
// Draw the shape
fill(randomR, randomG, randomB, randomA);
ellipse(xpos, ypos, randomWidth, randomHeight);
if (ypos>=height) {
//    saveFrame("chameleonEyes-######4.png");
reset();
}
}

void reset() {
background(0);
ypos=2;
}