Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
//Umbrella Simulator
//Peyton Blake

//Umbrella Simulator is the very latest in umbrella shielding technology.
//Navigate the umbrella with your mouse, protect your plants from the colorful acid rain and watch them thank you for your kindness.


//set canvas size
void setup() 
{
  size(400, 400);
  
}

void draw() 

{
  
//set background color
background(20);
  
//Set primitive drawing mode for easiest usage
rectMode(CENTER);
ellipseMode(CENTER);


//Drawing rain lines at varying positions

stroke(mouseX, 150, mouseY);
line(100, ((frameCount % 70)*10), 100, ((frameCount % 70)*10)+50);
line(10, (frameCount % 40)*10, 10, ((frameCount % 40)*10)+50);
line(50, (frameCount % 43)*10, 50, ((frameCount % 43)*10)+50);
line(400, (frameCount % 50)*10, 400, ((frameCount % 50)*10)+50);
line(500, (frameCount % 40)*10, 500, ((frameCount % 40)*10)+50);
line(250, (frameCount % 71)*10, 250, ((frameCount % 71)*10)+50);
line(600, (frameCount % 55)*10, 600, ((frameCount % 55)*10)+50);
line(366, (frameCount % 45)*10, 366, ((frameCount % 45)*10)+50);
line(452, (frameCount % 38)*10, 452, ((frameCount % 38)*10)+50);
line(125, (frameCount % 48)*10, 125, ((frameCount % 48)*10)+50);
line(288, (frameCount % 62)*10, 288, ((frameCount % 62)*10)+50);
line(725, (frameCount % 59)*10, 725, ((frameCount % 59)*10)+50);
line(721, (frameCount % 65)*10, 721, ((frameCount % 65)*10)+50);
line(465, (frameCount % 80)*10, 465, ((frameCount % 80)*10)+50);
line(650, (frameCount % 39)*10, 650, ((frameCount % 39)*10)+50);
line(700, (frameCount % 75)*10, 700, ((frameCount % 75)*10)+50);
line(410, (frameCount % 55)*10, 410, ((frameCount % 55)*10)+50);
line(300, (frameCount % 95)*10, 300, ((frameCount % 95)*10)+50);
line(220, (frameCount % 45)*10, 220, ((frameCount % 45)*10)+50);
line(70, (frameCount % 70)*10, 70, ((frameCount % 70)*10)+50);
line(60, (frameCount % 85)*10, 60, ((frameCount % 85)*10)+50);
line(790, (frameCount % 100)*10, 790, ((frameCount % 100)*10)+50);
line(602, (frameCount % 80)*10, 602, ((frameCount % 80)*10)+50);
line(789, (frameCount % 25)*10, 789, ((frameCount % 25)*10)+50);
line(795, (frameCount % 99)*10, 795, ((frameCount % 99)*10)+50);
line(400, (frameCount % 9)*10, 400, ((frameCount % 9)*10)+50);
line(460, (frameCount % 15)*10, 460, ((frameCount % 15)*10)+50);


//Draw Umbrella//

//coverage box invisible
fill(20);
noStroke();
rect(mouseX+8, mouseY+230, 100, 500);

//handle
noStroke();
fill(180);
rect(mouseX, mouseY, 25, 83);
  
//handle invisible
fill(20);
rect(mouseX-3, mouseY, 10, 60);
rect(mouseX-10, mouseY-5, 10, 55);
ellipse(mouseX-3, mouseY+31, 10, 10);
  
//umbrella tip
fill(180);
triangle(mouseX-15, mouseY-25, mouseX+30, mouseY-25, mouseX+8, mouseY-80);
  
//umbrella canopy
fill(255);
arc(mouseX+8, mouseY-20, 100, 100, PI, PI*2);
     
//umbrella round edges
//left
fill(20);
ellipse(mouseX-7, mouseY-20, 22, 10);
ellipse(mouseX-30, mouseY-20, 22, 10);

//right
fill(20);
ellipse(mouseX+22, mouseY-20, 22, 10);
ellipse(mouseX+47, mouseY-20, 22, 10);

//plants

//right grass
rectMode(CORNER);
//set color to change when over with umbrella
fill(0, round(((mouseX)/325)*200), 50);
ellipse(390, 370, 5, 60);
ellipse(370, 360, 5, 60);
ellipse(359, 375, 5, 60);
ellipse(378, 380, 5, 60);
ellipse(365, 360, 5, 60);
ellipse(355, 373, 5, 60);
ellipse(345, 390, 5, 60);
fill(0, round(((mouseX)/325)*200), 50, 100);
ellipse(380, 380, 50, 50);
ellipse(360, 380, 50, 50);

//left grass
//set color to change when over with umbrella
fill(40, (1-round(mouseX/50))*200, 50);
ellipse(30, 370, 5, 60);
ellipse(25, 360, 5, 60);
ellipse(18, 375, 5, 60);
ellipse(5, 380, 5, 60);
ellipse(41, 360, 5, 60);
ellipse(50, 373, 5, 60);
ellipse(58, 390, 5, 60);
fill(40, (1-round(mouseX/50))*200, 50, 100);
ellipse(20, 380, 50, 50);
ellipse(40, 380, 50, 50);

//bottom ground border
fill(0);
rect(0, 380, 800, 800); 
}

//click mouse to see a small message
void mousePressed() {
println("it's raining, it's pouring...");
}