Project 3 – Dynamic Drawing

For this project I created a nautical scene that has many changing/moving elements that simulate the change from sunrise to sunset.

sketch

//Helen Cheng - helenc1
//Section C

var waterLevel=400

function setup() {
    createCanvas(600, 450);
}

function draw() {
  strokeWeight(0);
  //sky gradients from dark to light along x
  var skyG = 136-mouseX/6
  var b = 255-mouseX/6
  background(0,skyG,b)
  //sun gradients from red to yellow along x
  var g = 255-(mouseX/6)
  fill(255, g, 10);
  circle(600-mouseX, 200, 100);
  //water level rises and falls along y
  fill(141,206,238);
  rect(0,waterLevel-mouseY/4,600,450);
  //sailboat moves with your cursor along X
  fill(230,62,54);
  arc(mouseX,400,200,100,0,PI);
  //sail
  fill(255);
  triangle(mouseX,375,mouseX,300,mouseX+75,350);
  strokeWeight(5);
  stroke(56,56,56);
  line(mouseX,400,mouseX,300);
}

Leave a Reply