kstargio proj2 Downloadvar headWidth = 640/2 - 10;
var headHeight = 840/1.75 - 10;
var skinTone = 3;
var eyeWidth = 55;var eyeHeight = 30;var eyeSpread = 12;var eyeColor = 1;var pupilHeight = 27;
var noseSpread = 60;
var noseWidth = 10;var noseHeight = 60;var lipColor = 3;
var mouthHeight = 5*840/8
var mouthShape = 1
var hairColor = 3
var hairStyle = 1
function setup() {
createCanvas(640, 840);
}
function draw() {
background(110, 70, 110); noStroke();
if (skinTone <= 1) {
fill(240, 211, 202); } else if (skinTone <= 2) {
fill(246, 200, 167);
} else if (skinTone <= 3) {
fill(219, 140, 95);
} else if (skinTone <= 4) {
fill(121, 69, 53);
} else {
fill(42, 31, 27); } ellipse(width/2, height/2, headWidth, headHeight); fill(255);
stroke(0);
strokeWeight(1);
ellipse(width/2 - 5*eyeSpread, height/2 - 25, eyeWidth, 15);
ellipse(width/2 + 5*eyeSpread, height/2 - 25, eyeWidth, 15);
arc(width/2 - 5*eyeSpread, height/2 - 25, eyeWidth, eyeHeight, PI, 0);
arc(width/2 + 5*eyeSpread, height/2 - 25, eyeWidth, eyeHeight, PI, 0); noStroke();
fill(0);
if (eyeHeight <= 18) { pupilHeight = 27;
} else if (eyeHeight <= 22) {
pupilHeight = 28;
} else if (eyeHeight <= 26) {
pupilHeight = 29;
} else if (eyeHeight <= 30) {
pupilHeight = 31;
} else if (eyeHeight <= 33) {
pupilHeight = 32;
} else {
pupilHeight = 33;
}
if (eyeColor <= 1) { fill(64, 106, 138); } else if (eyeColor <= 2) {
fill(48, 24, 23); } else if (eyeColor <= 3) {
fill(100, 61, 27); } else {
fill(105, 85, 25); } arc(width/2 - 5*eyeSpread, height/2 - pupilHeight, eyeWidth/2, eyeHeight*.8, PI+HALF_PI+QUARTER_PI, PI+(QUARTER_PI), OPEN);
arc(width/2 + 5*eyeSpread, height/2 - pupilHeight, eyeWidth/2, eyeHeight*.8, PI+HALF_PI+QUARTER_PI, PI+QUARTER_PI, OPEN); fill(0);
ellipse(width/2 - 5*eyeSpread, height/2 - pupilHeight, eyeWidth/3, eyeHeight*.5);
ellipse(width/2 + 5*eyeSpread, height/2 - pupilHeight, eyeWidth/3, eyeHeight*.5);
fill(255); ellipse(width/2 - 5*eyeSpread + eyeWidth/12, height/2 - pupilHeight - eyeHeight/12, eyeWidth/8, eyeHeight/6);
ellipse(width/2 + 5*eyeSpread + eyeWidth/12, height/2 - pupilHeight - eyeHeight/12, eyeWidth/8, eyeHeight/6);
ellipse(width/2 - 5*eyeSpread + eyeWidth/9, height/2 - pupilHeight + eyeHeight/12, eyeWidth/16, eyeHeight/11);
ellipse(width/2 + 5*eyeSpread + eyeWidth/9, height/2 - pupilHeight + eyeHeight/12, eyeWidth/16, eyeHeight/11); stroke(0);
strokeWeight(3);
noFill();
arc(width/2 - 5*eyeSpread, height/2 - 25, eyeWidth, eyeHeight, PI, 0, OPEN);
arc(width/2 + 5*eyeSpread, height/2 - 25, eyeWidth, eyeHeight, PI, 0); noFill();
stroke(0);
strokeWeight(1);
arc(width/2 - noseSpread, height/2 + 15, 95, 175, PI+HALF_PI+QUARTER_PI, QUARTER_PI/2);
arc(width/2 + noseSpread, height/2 + 15, 95, 175, PI-(QUARTER_PI)/2, PI+QUARTER_PI); noFill();
strokeWeight(5);
if (skinTone <= 1) {
stroke(230, 201, 192); } else if (skinTone <= 2) {
stroke(236, 190, 157);
} else if (skinTone <= 3) {
stroke(209, 130, 85);
} else if (skinTone <= 4) {
stroke(111, 59, 43);
} else {
stroke(32, 21, 17); }
arc(width/2, height/2 + 70, noseWidth + 10, 25, PI+QUARTER_PI, -QUARTER_PI), OPEN; stroke(0);
strokeWeight(1);
beginShape(); curveVertex(width/2 - (noseWidth+12), height/2 + (noseHeight+7));
curveVertex(width/2 - (noseWidth+12), height/2 + (noseHeight+7));
curveVertex(width/2 - (noseWidth+17), height/2 + (noseHeight+12));
curveVertex(width/2 - (noseWidth+17), height/2 + (noseHeight+20));
curveVertex(width/2 - (noseWidth+10), height/2 + (noseHeight+23));
curveVertex(width/2 - noseWidth, height/2 + 80);
curveVertex(width/2, height/2 + 85);
curveVertex(width/2 + noseWidth, height/2 + 80);
curveVertex(width/2 + (noseWidth+10), height/2 + (noseHeight+23));
curveVertex(width/2 + (noseWidth+17), height/2 + (noseHeight+20));
curveVertex(width/2 + (noseWidth+17), height/2 + (noseHeight+12));
curveVertex(width/2 + (noseWidth+12), height/2 + (noseHeight+7));
curveVertex(width/2 + (noseWidth+12), height/2 + (noseHeight+7));
endShape(); if (mouthShape <= 1) {
fill(236, 240, 215);
} else {
if (lipColor <= 1) {
fill(245, 195, 195);
} else if (lipColor <= 2) {
fill(255, 175, 145);
} else if (lipColor <= 3) {
fill(235, 125, 85);
} else if (lipColor <= 4) {
fill(95, 39, 33);
} else {
fill(52, 21, 17);
}}
beginShape();
curveVertex(width/2 + 65, mouthHeight + 15); curveVertex(width/2 + 60, mouthHeight + 17); curveVertex(width/2 + 45, mouthHeight + 20);
curveVertex(width/2 + 15, mouthHeight + 20);
curveVertex(width/2, mouthHeight + 22); curveVertex(width/2 - 15, mouthHeight + 20);
curveVertex(width/2 - 45, mouthHeight + 20);
curveVertex(width/2 - 60, mouthHeight + 17); curveVertex(width/2 - 65, mouthHeight + 15); curveVertex(width/2 - 55, mouthHeight + 23);
curveVertex(width/2 - 40, mouthHeight + 32);
curveVertex(width/2 - 15, mouthHeight + 40);
curveVertex(width/2, mouthHeight + 39); curveVertex(width/2 + 15, mouthHeight + 40);
curveVertex(width/2 + 40, mouthHeight + 32);
curveVertex(width/2 + 55, mouthHeight + 23);
curveVertex(width/2 + 65, mouthHeight + 15); curveVertex(width/2 + 60, mouthHeight + 17); curveVertex(width/2 + 45, mouthHeight + 20);
curveVertex(width/2 + 45, mouthHeight + 20);
endShape();
if (mouthShape <= 1) {
line(width/2 - 52, mouthHeight + 18, width/2 - 52, mouthHeight + 27);
line(width/2 - 45, mouthHeight + 18, width/2 - 45, mouthHeight + 28);
line(width/2 - 37, mouthHeight + 18, width/2 - 37, mouthHeight + 30);
line(width/2 - 27, mouthHeight + 18, width/2 - 27, mouthHeight + 32);
line(width/2 - 15, mouthHeight + 18, width/2 - 15, mouthHeight + 34);
line(width/2, mouthHeight + 18, width/2, mouthHeight + 37); line(width/2 + 15, mouthHeight + 18, width/2 + 15, mouthHeight + 34);
line(width/2 + 27, mouthHeight + 18, width/2 + 27, mouthHeight + 32);
line(width/2 + 37, mouthHeight + 18, width/2 + 37, mouthHeight + 30);
line(width/2 + 45, mouthHeight + 18, width/2 + 45, mouthHeight + 28);
line(width/2 + 52, mouthHeight + 18, width/2 + 52, mouthHeight + 27);
} else {
null;
}
if (lipColor <= 1) {
fill(245, 195, 195);
} else if (lipColor <= 2) {
fill(255, 175, 145);
} else if (lipColor <= 3) {
fill(235, 125, 85);
} else if (lipColor <= 4) {
fill(95, 39, 33);
} else {
fill(52, 21, 17);
} if (mouthShape <= 1) {
beginShape();
curveVertex(width/2 + 65, mouthHeight + 16); curveVertex(width/2 + 60, mouthHeight + 18); curveVertex(width/2 + 45, mouthHeight + 20 + 5);
curveVertex(width/2 + 15, mouthHeight + 20 + 12);
curveVertex(width/2, mouthHeight + 22 + 11); curveVertex(width/2 - 15, mouthHeight + 20 + 12);
curveVertex(width/2 - 45, mouthHeight + 20 + 5);
curveVertex(width/2 - 60, mouthHeight + 18); curveVertex(width/2 - 65, mouthHeight + 16); curveVertex(width/2 - 55, mouthHeight + 23 + 5);
curveVertex(width/2 - 40, mouthHeight + 32 + 7);
curveVertex(width/2 - 15, mouthHeight + 40 + 10);
curveVertex(width/2, mouthHeight + 39 + 10); curveVertex(width/2 + 15, mouthHeight + 40 + 10);
curveVertex(width/2 + 40, mouthHeight + 32 + 7);
curveVertex(width/2 + 55, mouthHeight + 23 + 5);
curveVertex(width/2 + 65, mouthHeight + 15); curveVertex(width/2 + 60, mouthHeight + 17); curveVertex(width/2 + 45, mouthHeight + 20);
curveVertex(width/2 + 45, mouthHeight + 20);
endShape();
} else {
null;
} beginShape();
curveVertex(width/2 - 65, mouthHeight + 15); curveVertex(width/2 - 11, mouthHeight + 5);
curveVertex(width/2, mouthHeight + 7); curveVertex(width/2 + 11, mouthHeight + 5);
curveVertex(width/2 + 63, mouthHeight + 14); curveVertex(width/2 + 60, mouthHeight + 17);
curveVertex(width/2 + 45, mouthHeight + 20);
curveVertex(width/2 + 15, mouthHeight + 20);
curveVertex(width/2, mouthHeight + 22); curveVertex(width/2 - 15, mouthHeight + 20);
curveVertex(width/2 - 45, mouthHeight + 20);
curveVertex(width/2 - 60, mouthHeight + 17);
curveVertex(width/2 - 63, mouthHeight + 14); curveVertex(width/2 - 11, mouthHeight + 5);
curveVertex(width/2 - 11, mouthHeight + 5); endShape(); if (hairColor <= 1) {
stroke(0);
fill(0);
} else if (hairColor <= 2) {
stroke(127);
fill(127);
} else if (hairColor <= 3) {
stroke(23, 9, 7);
fill(23, 9, 7);
} else if (hairColor <= 4) {
stroke(93, 58, 42);
fill(93, 58, 42);
} else if (hairColor <= 5) {
stroke(83, 30, 12);
fill(83, 30, 12);
} else if (hairColor <= 6) {
stroke(226, 174, 126);
fill(226, 174, 126);
} else {
stroke(51, 9, 4);
fill(51, 9, 4);
} quad(width/2 - headWidth/4 - eyeSpread/2, height/2 - headHeight/7 - 4,
width/2 - headWidth/9, height/2 - headHeight/7,
width/2 - headWidth/9 +3, height/2 - headHeight/8,
width/2 - headWidth/4 - eyeSpread/2, height/2 - headHeight/8 - 5);
beginShape();
curveVertex(width/2 - headWidth/4 - eyeSpread/2, height/2 - headHeight/7 - 4);
curveVertex(width/2 - headWidth/4 - eyeSpread/2, height/2 - headHeight/7 - 4);
curveVertex(width/2 - headWidth/4 - eyeSpread/2 - 10, height/2 - headHeight/7 - 4);
curveVertex(width/2 - headWidth/4 - eyeSpread/2 - 20, height/2 - headHeight/7);
curveVertex( width/2 - headWidth/4 - eyeSpread/2 - 30, height/2 - headHeight/8 + 4);
curveVertex( width/2 - headWidth/4 - eyeSpread/2 - 20, height/2 - headHeight/8 - 2);
curveVertex( width/2 - headWidth/4 - eyeSpread/2 - 10, height/2 - headHeight/8 - 5);
curveVertex( width/2 - headWidth/4 - eyeSpread/2, height/2 - headHeight/8 - 5);
curveVertex( width/2 - headWidth/4 - eyeSpread/2, height/2 - headHeight/8 - 5);
endShape();
quad(width/2 + headWidth/4 + eyeSpread/2, height/2 - headHeight/7 - 4,
width/2 + headWidth/9, height/2 - headHeight/7,
width/2 + headWidth/9 - 3, height/2 - headHeight/8,
width/2 + headWidth/4 + eyeSpread/2, height/2 - headHeight/8 - 5);
beginShape();
curveVertex(width/2 + headWidth/4 + eyeSpread/2, height/2 - headHeight/7 - 4);
curveVertex(width/2 + headWidth/4 + eyeSpread/2, height/2 - headHeight/7 - 4);
curveVertex(width/2 + headWidth/4 + eyeSpread/2 + 10, height/2 - headHeight/7 - 4);
curveVertex(width/2 + headWidth/4 + eyeSpread/2 + 20, height/2 - headHeight/7);
curveVertex( width/2 + headWidth/4 + eyeSpread/2 + 30, height/2 - headHeight/8 + 4);
curveVertex( width/2 + headWidth/4 + eyeSpread/2 + 20, height/2 - headHeight/8 - 2);
curveVertex( width/2 + headWidth/4 + eyeSpread/2 + 10, height/2 - headHeight/8 - 5);
curveVertex( width/2 + headWidth/4 + eyeSpread/2, height/2 - headHeight/8 - 5);
curveVertex( width/2 + headWidth/4 + eyeSpread/2, height/2 - headHeight/8 - 5);
endShape(); if (hairStyle <= 1) {
beginShape();
curveVertex(width/2 - headWidth/4.5, height/2 - headHeight/3);
curveVertex(width/2 - headWidth/4.5, height/2 - headHeight/2.25);
curveVertex(width/2 - headWidth/3.5, height/2 - headHeight/2);
curveVertex(width/2 - headWidth/2.5, height/2 - headHeight/2);
curveVertex(width/2 - headWidth/2, height/2 - headHeight/2.15);
curveVertex(width/2 - headWidth/1.85, height/2 - headHeight/2.5);
curveVertex(width/2 - headWidth/1.9, height/2 - headHeight/3);
curveVertex(width/2 - headWidth/1.85, height/2 - headHeight/3.75);
curveVertex(width/2 - headWidth/1.9, height/2 - headHeight/4.5);
curveVertex(width/2 - headWidth/1.85, height/2 - headHeight/5.5);
curveVertex(width/2 - headWidth/1.9, height/2 - headHeight/7);
curveVertex(width/2 - headWidth/1.85, height/2 - headHeight/10);
curveVertex(width/2 - headWidth/1.9, height/2 - headHeight/16);
curveVertex(width/2 - headWidth/1.85, height/2 - headHeight/50);
curveVertex(width/2 - headWidth/1.9, height/2 + headHeight/50);
curveVertex(width/2 - headWidth/1.85, height/2 + headHeight/16);
curveVertex(width/2 - headWidth/1.9, height/2 + headHeight/10);
curveVertex(width/2 - headWidth/1.85, height/2 + headHeight/7);
curveVertex(width/2 - headWidth/1.9, height/2 + headHeight/5.5);
curveVertex(width/2 - headWidth/1.85, height/2 + headHeight/4.5);
curveVertex(width/2 - headWidth/1.9, height/2 + headHeight/3.75);
curveVertex(width/2 - headWidth/1.85, height/2 + headHeight/3);
curveVertex(width/2 - headWidth/1.9, height/2 + headHeight/2.5);
curveVertex(width/2 - headWidth/2, height/2 + headHeight/3);
curveVertex(width/2 - headWidth/2.1, height/2 + headHeight/3.75);
curveVertex(width/2 - headWidth/2.07, height/2 + headHeight/4.5);
curveVertex(width/2 - headWidth/2.11, height/2 + headHeight/5.5);
curveVertex(width/2 - headWidth/2.08, height/2 + headHeight/7);
curveVertex(width/2 - headWidth/2, height/2);
curveVertex(width/2 - headWidth/2.2, height/2 - headHeight/5);
curveVertex(width/2 - headWidth/2.6, height/2 - headHeight/3);
curveVertex(width/2 - headWidth/2.7, height/2 - headHeight/2.75);
curveVertex(width/2 - headWidth/2.8, height/2 - headHeight/2.65);
curveVertex(width/2 - headWidth/3, height/2 - headHeight/2.65);
curveVertex(width/2 - headWidth/3, height/2 - headHeight/2.65);
endShape();
beginShape();
curveVertex(width/2 + headWidth/4.5, height/2 - headHeight/3);
curveVertex(width/2 + headWidth/4.5, height/2 - headHeight/2.25);
curveVertex(width/2 + headWidth/3.5, height/2 - headHeight/2);
curveVertex(width/2 + headWidth/2.5, height/2 - headHeight/2);
curveVertex(width/2 + headWidth/2, height/2 - headHeight/2.15);
curveVertex(width/2 + headWidth/1.85, height/2 - headHeight/2.5);
curveVertex(width/2 + headWidth/1.9, height/2 - headHeight/3);
curveVertex(width/2 + headWidth/1.85, height/2 - headHeight/3.75);
curveVertex(width/2 + headWidth/1.9, height/2 - headHeight/4.5);
curveVertex(width/2 + headWidth/1.85, height/2 - headHeight/5.5);
curveVertex(width/2 + headWidth/1.9, height/2 - headHeight/7);
curveVertex(width/2 + headWidth/1.85, height/2 - headHeight/10);
curveVertex(width/2 + headWidth/1.9, height/2 - headHeight/16);
curveVertex(width/2 + headWidth/1.85, height/2 - headHeight/50);
curveVertex(width/2 + headWidth/1.9, height/2 + headHeight/50);
curveVertex(width/2 + headWidth/1.85, height/2 + headHeight/16);
curveVertex(width/2 + headWidth/1.9, height/2 + headHeight/10);
curveVertex(width/2 + headWidth/1.85, height/2 + headHeight/7);
curveVertex(width/2 + headWidth/1.9, height/2 + headHeight/5.5);
curveVertex(width/2 + headWidth/1.85, height/2 + headHeight/4.5);
curveVertex(width/2 + headWidth/1.9, height/2 + headHeight/3.75);
curveVertex(width/2 + headWidth/1.85, height/2 + headHeight/3);
curveVertex(width/2 + headWidth/1.9, height/2 + headHeight/2.5);
curveVertex(width/2 + headWidth/2, height/2 + headHeight/3);
curveVertex(width/2 + headWidth/2.1, height/2 + headHeight/3.75);
curveVertex(width/2 + headWidth/2.07, height/2 + headHeight/4.5);
curveVertex(width/2 + headWidth/2.11, height/2 + headHeight/5.5);
curveVertex(width/2 + headWidth/2.08, height/2 + headHeight/7);
curveVertex(width/2 + headWidth/2, height/2);
curveVertex(width/2 + headWidth/2.2, height/2 - headHeight/5);
curveVertex(width/2 + headWidth/2.6, height/2 - headHeight/3);
curveVertex(width/2 + headWidth/2.7, height/2 - headHeight/2.75);
curveVertex(width/2 + headWidth/2.8, height/2 - headHeight/2.65);
curveVertex(width/2 + headWidth/3, height/2 - headHeight/2.65);
curveVertex(width/2 + headWidth/3, height/2 - headHeight/2.65);
endShape();
noFill();
strokeWeight(5);
arc(width/2, height/2, headWidth, headHeight, PI, 0);
strokeWeight(10);
arc(width/2, height/2, headWidth - headWidth/50, headHeight - headHeight/50, PI+QUARTER_PI/4, -QUARTER_PI/4);
strokeWeight(15);
arc(width/2, height/2, headWidth - headWidth/40, headHeight - headHeight/40, PI+QUARTER_PI/2, -QUARTER_PI/2);
strokeWeight(20);
arc(width/2, height/2, headWidth - headWidth/20, headHeight - headHeight/20, PI+QUARTER_PI/2+QUARTER_PI/4, -(QUARTER_PI/2+QUARTER_PI/4));
strokeWeight(25);
arc(width/2, height/2, headWidth - headWidth/10, headHeight - headHeight/10, PI+QUARTER_PI, -QUARTER_PI);
strokeWeight(25);
arc(width/2, height/2, headWidth - headWidth/6, headHeight - headHeight/5, PI+QUARTER_PI+QUARTER_PI/4, -(QUARTER_PI+QUARTER_PI/4));
strokeWeight(50);
arc(width/2, height/2 - headHeight/2, headWidth - headWidth/5, headHeight/3, QUARTER_PI, PI - QUARTER_PI);
} else if (hairStyle <= 2) {
ellipse(width/2 + 20, height/2 - headHeight/2, headWidth/2, headHeight/3);
noFill();
strokeWeight(5);
arc(width/2, height/2, headWidth, headHeight, PI, 0);
strokeWeight(10);
arc(width/2, height/2, headWidth - headWidth/50, headHeight - headHeight/50, PI+QUARTER_PI/4, -QUARTER_PI/4);
strokeWeight(15);
arc(width/2, height/2, headWidth - headWidth/40, headHeight - headHeight/40, PI+QUARTER_PI/2, -QUARTER_PI/2);
strokeWeight(20);
arc(width/2, height/2, headWidth - headWidth/20, headHeight - headHeight/20, PI+QUARTER_PI/2+QUARTER_PI/4, -(QUARTER_PI/2+QUARTER_PI/4));
strokeWeight(25);
arc(width/2, height/2, headWidth - headWidth/10, headHeight - headHeight/10, PI+QUARTER_PI, -QUARTER_PI);
strokeWeight(25);
arc(width/2, height/2, headWidth - headWidth/6, headHeight - headHeight/5, PI+QUARTER_PI+QUARTER_PI/4, -(QUARTER_PI+QUARTER_PI/4));
strokeWeight(50);
arc(width/2, height/2 - headHeight/2, headWidth - headWidth/5, headHeight/3, QUARTER_PI, PI - QUARTER_PI);
} else {
noFill();
strokeWeight(5);
arc(width/2, height/2, headWidth, headHeight, PI, 0);
strokeWeight(10);
arc(width/2, height/2, headWidth - headWidth/50, headHeight - headHeight/50, PI+QUARTER_PI/4, -QUARTER_PI/4);
strokeWeight(15);
arc(width/2, height/2, headWidth - headWidth/40, headHeight - headHeight/40, PI+QUARTER_PI/2, -QUARTER_PI/2);
strokeWeight(20);
arc(width/2, height/2, headWidth - headWidth/20, headHeight - headHeight/20, PI+QUARTER_PI/2+QUARTER_PI/4, -(QUARTER_PI/2+QUARTER_PI/4));
strokeWeight(25);
arc(width/2, height/2, headWidth - headWidth/10, headHeight - headHeight/10, PI+QUARTER_PI, -QUARTER_PI);
strokeWeight(25);
arc(width/2, height/2, headWidth - headWidth/6, headHeight - headHeight/5, PI+QUARTER_PI+QUARTER_PI/4, -(QUARTER_PI+QUARTER_PI/4));
strokeWeight(50);
arc(width/2, height/2 - headHeight/2, headWidth - headWidth/5, headHeight/3, QUARTER_PI, PI - QUARTER_PI);
}
}
function mousePressed() {
headWidth = random(width/2 - 30, width/2 + 30);
headHeight = random(height/2 - 20, height/2 + 70);
skinTone = random(0, 5);
eyeWidth = random(40, 65);
eyeHeight = random(15, 37);
eyeSpread = random(10, 15);
eyeColor = random(0, 4);
noseSpread = random(57, 67);
noseWidth = random(5, 20);
noseHeight = random(55, 65);
lipColor = random(0, 5);
mouthHeight = random(5*height/8 - 15, 5*height/8 + 15);
mouthShape = random(2);
hairColor = random(7);
hairStyle = random(3);
}