Project-03-Dynamic Drawing

sketch

//Rebecca Enright
//Section A
//renright@andrew.cmu.edu
//Dynamic Drawing

//creates variable for diameter
var  dia = 10
//creates variabe for grayscale color
var C = 255

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

function draw() {
    background(255,100,125);
    //creates ellipse
    fill(C);
    ellipse(width/2,height/2,dia,dia);
    //ellipse gets larger/smaller and turns black
    if (mouseX > width/2) {
        C = C-10;
        dia = dia + 5;
    }
    //ellipse gets smaller/larger and turns white
    if (mouseX < width/2) {
    	C = C + 10;
    	dia = dia - 5;
    }
    //creates variables for colors
    var R = 100;
    var G = 0;
    var B = 255;

    //creates variable for rectangle side
    var s = 5;
    //variable for rectangle location
    var x = 320;
    var y = 240;
    
    //Rectangle changes
    if (mouseY < height/2) {
    //decreases red color component
        R -= 10;
    //increases green color component   
        G += 50;
    //decreases blue color component   
        B -=  10;
    //increases area
        s += 100;
    //moves rectangle up
        y += 20;
    //moves rectangle to the left
        x -= 20;
    }
    //Rectangle changes
    if (mouseY > height/2) {
    //increases red color component
        R += 50;
    //decreases green color component   
        G -= 10;
    //increases blue color component   
        B += 50;
    //decreases area
        s -= 50;
    //moves rectangle down
        y -= 20;
    //moves rectangle to the right
        x += 20;
    }
    //creates rectangle
    fill(R,G,B);
    rectMode(CENTER);
    rect(x,y,s,s);

}

I found this project to be rather difficult, however I really enjoyed experimenting with the different effects the movement of the mouse could have on the picture.

Leave a Reply