ctv-project-02

sketch

//Ty Van de Zande
//Section B
//ctv@andrew.cmu.edu
//Assignment-03-A

var wid = 640;
var hgt = 480;
var colo = 0;

function setup() {
    createCanvas(wid, hgt);
}
 
function draw() {
    //rota variable must be defined 
    //in the draw loop, so it updates every frame
    var rota = mouseX/200;
    background(170, 190, 200);
    fill(colo);
    
    //starts a shape to apply features (eye)
    push(); 
    translate(width/3, height/3); //place on canvas
    rotate(rota);
    rect(-26, -26, 52, 52); //square
    rect(0, -26, 52, 52); //makes it a rectangle
    pop(); // ends shape features
    
    //starts a shape to apply features (eye)
    push(); 
    translate(width/3*2, height/3);
    rotate(rota);
    rect(-26, -26, 52, 52);
    rect(0, -26, 52, 52);
    pop();
    
    //starts a shape to apply features (mouth)
    push(); 
    translate(width/2, height/3*2);
    //changes openness of mouth based on mouseY
    arc(0, 50, 90, mouseY, 0, PI, OPEN);
    pop(); 
    
    //starts nose with features
    push();
    translate(mouseX, mouseY);
    //draws nose
    beginShape();
    curveVertex(0, 0);
    curveVertex(10, 10);
    curveVertex(40, 40);
    curveVertex(80, 80);
    curveVertex(100, 120);
    curveVertex(80, 140);
    curveVertex(40, 130);
    curveVertex(10, 100);
    curveVertex(0, 0);
    
    // change direction of nose, based on cursor
    if (mouseX <= width/2) { 
        scale(-.75, .75);

    } else { //scales down nose shape
        scale(.75,.75);
    }
    endShape(); 
    pop();
}

//if you click, it changes black to white!
function mousePressed(){
    if(colo == 0){
        colo = 255;
    noStroke();
    } else {
        colo = 0;
    }
}

 

This project was fun because it was cool to play with the shapes while programming each line. I wish I had spent more time on it, but I spent wayyyy too much time trying to figure out coordinates for the nose. The nose still looks horrible, so I just need to spend more time using curveVertex() for drawing.

Leave a Reply