Michelle Janco – Project 3- Dynamic Drawing

changing drawing

//Michelle Janco
//Section B
//mjanco@andrew.cmu.edu
//Project - 3

var Xpos
var Ypos
var pupilYpos
var pupilXpos

function setup() {
    createCanvas(400, 400);
}
function draw() {
  background(255);
//drawing the eye
if (mouseX < (width/2)){
  noStroke();
  fill(249, 214, 87);
}
else {
  noStroke();
  fill(random(0, 255), random(0, 255), random(0, 255));
}
ellipse(200, 200, 350, 350);
//shaking iris
fill(255);
ellipse(Xpos, Ypos, 200, 100);
if (mouseX > width/2) {
Xpos = width/2+ random(0,mouseX/60);
Ypos = height/2 + random(0,mouseX/60);
}
//pupil movement
var pupilXpos = constrain(mouseX, 150, 250);
noStroke();
fill(0);
ellipse(pupilXpos, 200, 40, 40);
}

For this assignment I created an eye that changes color when it looks to the right and follows the mouse. I had a little trouble with the order of things, but finally found the way to make it work.

Leave a Reply