xxxxxxxxxx
var ex, ey, eyeSize;
function setup() {
createCanvas(windowWidth, windowHeight);
ex = width/2;
ey = height/2;
eyeSize = 100;
}
function draw() {
background(0);
noStroke();
//instead of the code below make a function to
//draw multiple eyes at certain positions
drawEye (100,90, 100);
drawEye (220,400, 30);
drawEye (520,200, 50);
}
function drawEye(ex,ey,eyeSize) {
var dy = mouseY - ey;
var dx = mouseX - ex;
var orientation = atan2(dy, dx);
push();
translate(ex, ey);
//white
fill(255);
strokeWeight(5);
circle(0,0, eyeSize);
rotate(orientation);
//pupil
fill(0);
circle(eyeSize/4,0,eyeSize/2);
pop();
}