Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* Stewart Wyatt
 991281070
 Introduction to Media Computation Assignment 1: Interactive Drawing*/

void setup() {            //setup for the side 

  size(400, 400);
  noStroke();
  smooth();
  frameRate(30);
}

void mouseClicked() {      // WHen the mouse is clicked, fireworks light up the sky
  fill(255);
  for (int i=0; i<50; i++) {
    fill(random(100, 255), random(100, 255), random(100, 255));
    ellipse(random(0, 400), random(0, 100), 5, 5);
  }
}


void draw() {

  background(25, 150-mouseX/3, 255-mouseX/2);    //Creates the day-to-night effect



  //sun
  fill(255, 240, 67);
  ellipse(40, 100+mouseX, 80, 80);

  //moon
  fill(203, 203, 203);
  ellipse(350, 450-mouseX, 60, 60);

  fill(25, 180-mouseX/3, 15-mouseX/2);          //changes the far hill's color as the day ends
  arc(240, 400, 400, 250, 0, TWO_PI);          //far hill
  if (mouseX<=200) {                          //if the cursor is to the left of the middle of the screen, the hills are green in sunlight, if it's to the right, they're green in moonlight.
    fill(25, 180-mouseX/2, 15);
    arc(0, 400, 800, 150, 0, TWO_PI);
    noStroke();
  } else if (mouseX>200) {
    fill(25, mouseX/3, 15);
    arc(0, 400, 800, 150, 0, TWO_PI);
    noStroke();
  }
  //tree
  fill(129, 56, 0);
  rect(250, 178, 25, 100);
  fill(44, 160, 6);
  ellipse(250, 178, 50, 50);
  ellipse(280, 178, 50, 50);
  ellipse(265, 158, 50, 50);
  ellipse(245, 168, 50, 50);
  ellipse(285, 168, 50, 50);

  //person 1
  fill(126, 47, 232);
  rect(225, 240, 10, 35);
  fill(255);
  ellipse(230, 232, 20, 20);

  //person 2
  fill(255, 64, 246);
  rect(280, 243, 10, 35);
  triangle(285, 240, 275, 278, 295, 278);
  fill(255);
  ellipse(285, 235, 20, 20);
}