void setup()

{

size (400,400);

smooth();

}

int diam = 20;

int x1 = 10;

int y1 = 10;

int x2 = 50;

int y2 = 50;

int x3 = 90;

int y3 = 90;

int xDir = 1;

int yDir = 1;

int xDir2 = 1;

int yDir2 = 1;

int xDir3 = 1;

int yDir3 = 1;

int r, g, b;

void draw()

{

background(r, g, b);

fill(255 - (x1 + y1) * .6375 / 2);

ellipse(x1, y1, diam, diam);

fill(255 - (x2 + y2) * .6375 / 2);

ellipse(x2, y2, diam, diam);

fill(255 - (x3 + y3) * .6375 / 2);

ellipse(x3, y3, diam, diam);

if(x1 > width - diam / 2 || x1 < diam / 2)

{

xDir = -xDir;

}

if(x2 > width - diam / 2 || x2 < diam / 2)

{

xDir2 = -xDir2;

}

if(x3 > width - diam / 2 || x3 < diam / 2)

{

xDir3 = -xDir3;

}

if(y1 > height - diam / 2 || y1 < diam / 2)

{

yDir = -yDir;

}

if(y2 > height - diam / 2 || y2 < diam / 2)

{

yDir2 = -yDir2;

}

if(y3 > height - diam / 2 || y3 < diam / 2)

{

yDir3 = -yDir3;

}

x1 = x1 + xDir;

y1 = y1 + yDir;

x2 = x2 + xDir2;

y2 = y2 + yDir2;

x3 = x3 + xDir3;

y3 = y3 + yDir3;

}

void keyPressed()

{

if(key == ENTER || key == RETURN)

{

r = (int) random(255);

g = (int) random(255);

b = (int) random(255);

}

}