Chelsea Fan-Project-03-Dynamic Drawing

DynamicDrawing

/* Chelsea Fan
Section 1B
chelseaf@andrew.cmu.edu
Project-03
*/

//Changes in size, position, shape, and distance
function setup() {
    createCanvas(640, 480);
    noStroke();
}

function draw() {
    background(173, 216, 230);
    fill(255,255,0);
    //MouseX can move from 50 to 450
    var mouse = max(min(mouseX, 450), 50);
    var size = mouse * 400.0 / 640.0;
//Rabbit 1
    //Body
    fill(250, 250 , 250);
    ellipse(10+mouse*350/640, 225, size, size+50);
    //Tummy
    fill(255, 228, 225);
    ellipse(10+mouse*350/640, 235, size/1.5, size+20);
    //Head
    fill(250, 250, 250);
    ellipse(10+mouse*350/640, 180, size, size);
    //Ear
    ellipse(3+mouse*350/640, 160, size/8, size);
    ellipse(15+mouse*350/640, 160, size/8, size);
    //Eyes
    fill(211, 211, 211);
    ellipse(mouse*350/640-3, 180, size/4, size/4);
    ellipse(15+mouse*350/640, 180, size/4, size/4);
    fill(0)
    ellipse(mouse*350/640-3, 180, size/8, size/8);
    ellipse(15+mouse*350/640, 180, size/8, size/8);

//Purple square
    fill(216, 191, 216);
    size = 300-size;
    rect(width-mouse*350/640-140, 230, size, size);
    rectMode(CENTER); // center rect around 0,0
}
   

I used my last Project’s bunny drawing as a template for this new and improved dynamic bunny. I enjoyed learning how to incorporate the mouse location into the dynamic drawing.

Leave a Reply