xxxxxxxxxx
117
//added moustache rollover, head and necklace buttons.
var headColorsOn, necklaceOn
function setup() {
createCanvas(500, 500);
headColorsOn = false
necklaceOn = false
}
function draw() {
background(250, 150, 130);
drawJulia()
drawFace()
drawMoustache()
headColors()
drawNecklace()
}
function drawNecklace() {
if (necklaceOn) {
rectMode(CENTER)
fill('purple')
noStroke()
rect(250, 400, 80, 25)
fill('pink')
ellipse(250, 400, 25, 15)
ellipse(223, 400, 25, 15)
ellipse(277, 400, 25, 15)
}
}
function mouseClicked() {
if (mouseX > 150 && mouseX < 400 && mouseY < 375 && mouseY > 150) {
headColorsOn = !headColorsOn
}
if (mouseX > 170 && mouseX < 330 && mouseY > 375 && mouseY < 450) {
necklaceOn = !necklaceOn
}
}
function headColors() {
if (headColorsOn) {
fill(random(0, 255), random(0, 255), random(0, 255))
ellipse(250, 250, 225, 250)
drawFace()
}
else {drawFace()}
}
function drawMoustache() {
if (mouseX > 180 && mouseX < 300 && mouseY > 220 && mouseY < 300) {
line(240, 280, 210, 295)
line(247, 280, 220, 295)
line(250, 280, 230, 295)
line(250, 280, 240, 295)
line(250, 280, 250, 295) //center
line(250, 280, 260, 295)
line(250, 280, 270, 295)
line(253, 280, 280, 295)
line(260, 280, 290, 295)
}
}
function drawJulia() {
//hair
noStroke()
rectMode(CENTER)
fill(20, 0, 10)
rect(width / 2, 300, 290, 400, 100)
//neck
fill(230, 200, 130)
rect(250, 330, 80, 300)
//head
fill(250, 220, 150)
ellipse(250, 250, 225, 250)
//Shoulders
fill(150, 200, 255)
noStroke()
rect(250, 500, 230, 150, 350)
}
function drawFace() {
//eye whites
fill(250, 250, 250)
ellipse(200, 220, 40, 27)
ellipse(295, 220, 40, 27)
//irises
fill(50, 20, 10)
ellipse(200, 220, 25, 25)
ellipse(295, 220, 25, 25)
//eyebrows
stroke(100, 80, 80)
strokeWeight(7)
line(180, 195, 220, 187)
line(280, 187, 320, 195)
//nose
stroke(250, 200, 100)
strokeWeight(8)
line(230, 270, 250, 260)
line(250, 260, 270, 270)
//mouth
noStroke()
fill(250, 120, 100)
ellipse(width / 2, 320, 62, 40)
}