// Global Variables
float fade = .01; // start with a value between .005 and .015. Larger numbers lead to faster fade
boolean makeArt = false;
void setup() {
size(600, 600);
colorMode(HSB);
background(0);
}
void draw() {
noStroke();
fill(0, frameCount*fade);
rect(0, 0, width, height);
if(makeArt) {
if(key == 'b') {
bubbles();
}
if(key == 't') {
triangles();
}
}
}
// Draw randomly sized and color bubbles on part of the screen
void bubbles() {
// these determine what part of the screen bubbles appear on
int spreadX = 100;
int spreadY = 100;
int i=0;
while(i < 10) {
float x = random(mouseX-spreadX, mouseX+spreadX);//random(width);
float y = random(mouseY-spreadY, mouseY+spreadY); // random(height);
float d = random(10, 200);
float hue = random(256);
fill(hue, 240, 180);
ellipse(x, y, d, d);
i++;
}
}
// draw triangle patterns centered around the mouse position
void triangles() {
translate(mouseX, mouseY);
float hueOffset = random(150);
float triSize = random(100);
int i=0;
while(i<50) {
stroke(i*3 + hueOffset, 250, 250);//i, i);
// triangle takes x, y for all three vertices
rotate(.13);// =50%TWO_PI);
triangle(-triSize, triSize, triSize, triSize, 0, -triSize);
i++;
}
translate(-mouseX, -mouseY);
}
void mousePressed() {
makeArt = true;
}
void mouseClicked() {
makeArt = false;
}