Project-03- Dynamic Drawing

sp17 03 project

//Project 3 - Dynamic Drawing
//sp17
//Section C


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

function draw() {
    background(215, 195, 215);

    if (mouseY < height/2) {
        background(0); 
    } else {
        background (215, 195, 215);
    }

    //SUN 
    fill(235,206,117); // yellow
    stroke(235,206,117); // yellow
    var y = min(mouseY, 620);
    var diam= 230; // diameter


    // if mouse moves towards the center of the sun, the sun shrinks
    // if mouse moves away from the sun it is big

    if (dist (mouseX, mouseY, width/2, y) < diam/4) {
        diam = 50;
    } 
    ellipse(width/2, y, diam, diam); // sun


    //if the mouse Y is above the middle, the sun turns white moon:
    if (mouseY < height/2) {
        fill(255);
        stroke(255);
        ellipse(width/2, y, diam, diam); 
    }


    // if mouse around the centerpoint of the canvas, the sun/moon has rays show up
    if (dist(width/2, height/2, mouseX, mouseY) < 10) {
        strokeWeight(10);
        line(width/2, height/2- 50, width/2, height/2 - 70); 
        line (width/2, height/2 + 50, width/2, height/2 + 70);
        line (width/2 - 50, height/2, width/2 - 70, height/2);
        line (width/2 + 50, height/2, width/2 + 70, height/2);
    }

    //CLOUDS
    // if mouse moves to the right, clouds move right

    fill(137,183,172); // light teal
    stroke(137,183,172) // light teal

    var x = min (mouseX, 500);
     // left cloud 
    ellipse(x, height/4*3, 230, 170);
    ellipse(x - 100, height/4*3, 150, 100);
    ellipse(x + 100, height/4*3, 150, 100); 

    //right cloud
    ellipse(x+ 200, height/4, 230, 170); // middle
    ellipse(x + 100, height/4, 150, 100); // left bump
    ellipse(x + 300, height/4, 150, 100); // right cloud, right bump 


}

Leave a Reply