# Jason Zhu-Project-03-Dynamic-Drawing

``````/* Jason Zhu
Section E
jlzhu@andrew.cmu.edu
Assignment-03
*/

// This code demonstrates the Sunset!

// Easing Variables
var easing = .05
var x = 1;
var y = 1;

function setup() {
createCanvas(640,480);
}

function draw() {
// Max Min Function
noStroke();
var mX = max(min(mouseX, 640), 0);
var mY = max(min(mouseY, 480), 0);

// Background Change
var g = (480-mY)*(.309)+85;
var g2 = (480-mY)*(.309)+85;
background(255,g,100);

// Ease Sun Function
var tarY = mY;
var dy = tarY - y;
y += dy * easing;

fill (360,g-20,140)
ellipse(x + width / 2,y,mouseY / .35 +20,mouseY / .35 +20);
if (y> 395) {
y=395
}

fill (330,g-20,100)
ellipse(x + width / 2,y,mouseY / .55 +20,mouseY / .55 +20);
if (y> 395) {
y=395
}

fill (270,g-20,60)
ellipse(x + width / 2,y,mouseY / .9 +20,mouseY / .9 +20);
if (y> 395) {
y=395
}

// Sun
fill (250,g-40,40)
ellipse(x + width / 2,y,100,100);
if (y> 395) {
y=395
}

// Grass
var g2 = (480-mY)*(.309)+85;
fill(135,g2,100);
rect(0,410,640,120)