Jason Zhu-Project-03-Dynamic-Drawing

sketch

/* 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;

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

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

    // Sun Shadow Small
    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)

    // Right Shade
    fill(0);
    rect(640, 0, -.815*y, 480);

    // Left Shade
    fill(0);
    rect(0, 0, .815*y, 480);

}

This project was incredibly hard but rewarding. For me, thins project is when concepts really came together. It was a struggle to figure out how various variables interacted, but I eventually was able to resolve most issues. I had a particularly hard time with rotations and angles. I eventually figured out how to troubleshoot some of these issues, though a few questions linger. Overall, I am fairly satisfied.

Leave a Reply