Siwei Xie-Project 03-Dynamic Drawing

sketch

//Siwei Xie
//Section B
//sxie1@andrew.cmu.edu
//Project-03

var angle = 0;

function setup() {
    createCanvas(640, 480);
}
 
function draw() {
	// change background color when mouse moves
    background(205, mouseX/3, mouseY/6);
    noStroke();

    // 3 black objects in background follow mouse's movements,
    // creating a dynamic triangle with changing colors
    fill("black");
    triangle(0, 0, mouseX, mouseY, 0, 480);
    triangle(mouseX, mouseY, 640, 0, 640, 480);
    rect(0,0,640,mouseY);

    // enlarge mouth when mouse moves right
    // mouth position follows mouse
    fill("pink");
    circle(mouseX,mouseY+180,mouseX/2);

    // left rotating eye
    // eye position follows mouse
    fill("white");
    push();
    translate(mouseX-80, mouseY);
    rotate(radians(angle));
    rectMode(CENTER);
    rect(0, 0 , 60, 60);
    pop();
    angle = angle + 3;

    // right rotating eye
    push();
    translate(mouseX+80, mouseY);
    rotate(radians(angle));
    rectMode(CENTER);
    rect(0, 0 , 60, 60);
    pop();
    angle = angle + 3;

    // text enlarges when mouse moves right,
    // and follows mouse's verticle position
    textSize(mouseX/8);
    textFont("old english");
    text("Monster is roaring",0,mouseY/2);
 

}

I drew a monster which follows the mouse’s movements. The monster would roar if mouse moves right, and would “stay calm” if mouse moves left.

Leave a Reply