|
/* |
|
* This file should contain code that draws your faces. |
|
* |
|
* Each function takes parameters and draws a face that is within |
|
* the bounding box (-10, -10) to (10, 10). |
|
* |
|
* These functions are used by your final arrangement of faces as well as the face editor. |
|
*/ |
|
|
|
|
|
function drawFace1(tilt_value, tongue_value, pukana_value, scale_value) { |
|
const bg_color3 = [225, 206, 187]; |
|
const fg_color3 = [79, 27, 6]; |
|
const fg_color4 = [48, 15, 2]; |
|
const shadow = [209, 192, 167]; |
|
const bone = [222, 211, 186]; |
|
const tongue = [107, 0, 11]; |
|
|
|
let x = scale_value; //original value 1.75 |
|
let y = (scale_value -0.25); // -0.25 |
|
let x2 = (scale_value +0.25); // +0.25 |
|
let y2 = (scale_value -0.5); // -0.5 |
|
|
|
// rotation in degrees |
|
angleMode(DEGREES); |
|
rotate(tilt_value); |
|
//eyes |
|
stroke(bone); |
|
strokeWeight(0.1); |
|
fill(bone); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(-2*x, 0); //start bottom of left eye |
|
vertex(-3*x, -1*y2); |
|
vertex(-3*x, -3*y2); |
|
vertex(-2*x,-4*y2); |
|
vertex(-1*x, -4*y2); |
|
vertex(0, -3*y2); //top middle |
|
vertex(x, -4*y2); |
|
vertex(2*x,-4*y2); |
|
vertex(3*x, -3*y2); |
|
vertex(3*x, -1*y2); |
|
vertex(2*x, 0); //bottom of right eye |
|
vertex(x, 0); |
|
vertex(0, y); //bottom of nose |
|
vertex(-1*x, 0); |
|
endShape(); |
|
//inner eyes |
|
fill(shadow); |
|
stroke(shadow); |
|
strokeJoin(MITER); //left |
|
beginShape(); |
|
vertex(-1*x, 0); |
|
vertex(-1.75*x, -0.25*y2); |
|
vertex(-2.5*x, -1*y2); |
|
vertex(-2.5*x, -3*y2); |
|
vertex(-2*x, -3.5*y2); |
|
vertex(-1*x, -3.5*y2); |
|
vertex(-0.5*x, -3*y2); |
|
vertex(-0.5*x, -1*y2); |
|
endShape(); |
|
strokeJoin(MITER); //right |
|
beginShape(); |
|
vertex(1*x, 0); |
|
vertex(1.75*x, -0.25*y2); |
|
vertex(2.5*x, -1*y2); |
|
vertex(2.5*x, -3*y2); |
|
vertex(2*x, -3.5*y2); |
|
vertex(1*x, -3.5*y2); |
|
vertex(0.5*x, -3*y2); |
|
vertex(0.5*x, -1*y2); |
|
endShape(); |
|
// eyes |
|
fill(0); |
|
noStroke(); |
|
ellipse(-1.5*x, -1.5*y, pukana_value/2, pukana_value/2); //left |
|
ellipse(1.5*x, -1.5*y, pukana_value/2, pukana_value/2); |
|
fill(bone); |
|
ellipse(-1.5*x, -1.5*y, 0.75, 0.75); |
|
ellipse(1.5*x, -1.5*y, 0.75, 0.75); |
|
|
|
//mouth |
|
stroke(bone); |
|
fill(bone); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, y); //top middle of mouth (move clockwise) |
|
vertex(x, 0); |
|
vertex(2*x2, 0); |
|
vertex(3*x2, y); |
|
vertex(3.5*x2, 2*y); // |
|
vertex(3*x2, 3*y); |
|
vertex(1.5*x2, 4.5*y); //bottom right |
|
vertex(0, 5*y); |
|
vertex(-1.5*x2, 4.5*y); //bottom left |
|
vertex(-3*x2, 3*y); |
|
vertex(-3.5*x2, 2*y); // |
|
vertex(-3*x2, y); |
|
vertex(-2*x2, 0); |
|
vertex(-1*x, 0); |
|
endShape(); |
|
//inner mouth |
|
fill(shadow); |
|
stroke(shadow); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, 2*y); //top middle of inner mouth (move clockwise) |
|
vertex(0.75*x, 0.75*y); |
|
vertex(2*x, 0.5*y); |
|
vertex(2.75*x, 1.5*y); |
|
vertex(3*x, 2*y); // |
|
vertex(2.5*x, 3*y); |
|
vertex(1.5*x, 4*y); //bottom right |
|
vertex(0, 4.5*y); |
|
vertex(-1.5*x, 4*y); //bottom left |
|
vertex(-2.5*x, 3*y); |
|
vertex(-3*x, 2*y); // |
|
vertex(-2.75*x, 1.5*y); |
|
vertex(-2*x, 0.5*y); |
|
vertex(-0.75*x, 0.75*y); |
|
endShape(); |
|
//nose |
|
noStroke(); |
|
triangle(0, y, -0.25*x, 0, -0.75*x, 0.25*y); //left |
|
triangle(0, y, 0.25*x, 0, 0.75*x, 0.25*y); //right |
|
|
|
|
|
|
|
fill(tongue); |
|
stroke(tongue); |
|
strokeJoin(MITER); //original tongue |
|
beginShape(); |
|
vertex(0, 2*y); //middle point - clockwise |
|
vertex(0.75*x, 0.75*y); |
|
vertex(1.375*x, 0.625*y); |
|
vertex(1.25*x, 2*y); |
|
vertex(0, 6*y); //tongue point |
|
vertex(-1.25*x, 2*y); |
|
vertex(-1.375*x, 0.625*y); |
|
vertex(-0.75*x, 0.75*y); |
|
endShape(); |
|
//middle slit |
|
fill(74, 0, 8); |
|
stroke(74, 0, 8); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, 2*y); |
|
vertex(0.1*x, 1.85*y); |
|
vertex(0, 6*y); |
|
vertex(-0.1*x, 1.85*y); |
|
vertex(0, 2*y); |
|
endShape(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
/* |
|
* thinness_value ranges from 0-100 and indicates how thin the face is |
|
*/ |
|
function drawFace2(scale_value, tilt_value) { |
|
const fg_main = [4, 61, 18]; |
|
const fg_detail = [2, 33, 10]; |
|
const ivory = [249, 250, 217]; |
|
let x = scale_value; |
|
|
|
angleMode(DEGREES); |
|
rotate(tilt_value); |
|
|
|
//head |
|
fill(fg_detail); |
|
stroke(fg_detail); |
|
strokeWeight(0.1); |
|
//background |
|
strokeJoin(MITER); //starts on left anti-clockwise |
|
beginShape(); |
|
vertex(-4*x, 0); //change to 4 for pull |
|
//vertex(-2*x, x); |
|
vertex(-1*x, 2*x); |
|
vertex(x, 2*x); |
|
//vertex(2*x, x); |
|
vertex(3*x, 0); |
|
vertex(x, -2*x); |
|
vertex(-1*x, -2*x); |
|
vertex(-4*x, 0); //change to 4 for pull |
|
endShape(); |
|
|
|
//eye |
|
noStroke(); |
|
fill(209, 209, 192); |
|
ellipse(0, 0, 3*x, 3*x); //shadow |
|
fill(ivory); |
|
ellipse(0, 0, 2.5*x, 2.5*x); |
|
fill(12, 26, 15); |
|
ellipse(0.8*x, 0, x, x); |
|
|
|
//face border |
|
fill(fg_main); |
|
stroke(fg_main); |
|
strokeWeight(0.1); |
|
|
|
beginShape(); //clockwise |
|
vertex(3*x, 0); |
|
vertex(x, -2*x); |
|
vertex(-1*x, -2*x); |
|
vertex(-4*x, 0); |
|
vertex(-1*x, 2*x); |
|
vertex(x, 2*x); |
|
vertex(3*x, 0); |
|
beginContour(); |
|
//interior anti-clockwise |
|
vertex(2*x, 0); |
|
vertex(x, x); |
|
vertex(-1*x, x); |
|
vertex(-3*x, 0); |
|
vertex(-1*x, -1*x); |
|
vertex(x, -1*x); |
|
vertex(2*x, 0); |
|
endContour(); |
|
endShape(CLOSE); |
|
|
|
//mouth |
|
strokeJoin(MITER); //top |
|
beginShape(); |
|
vertex(2*x, -0.5*x); |
|
vertex(3*x, -1.5*x); |
|
vertex(5*x, -1.5*x); |
|
vertex(6*x, -0.5*x); //tip |
|
vertex(4.5*x, -0.9*x); |
|
vertex(3.5*x, -0.9*x); |
|
vertex(2*x, 0.5*x); //swap x value between 2*x and to 3*x |
|
endShape(); |
|
|
|
strokeJoin(MITER); //bottom |
|
beginShape(); |
|
vertex(2*x, 0.5*x); |
|
vertex(3*x, 1.5*x); |
|
vertex(5*x, 1.5*x); |
|
vertex(6*x, 0.5*x); //tip |
|
vertex(4.5*x, 0.9*x); |
|
vertex(3.5*x, 0.9*x); |
|
vertex(2*x, -0.5*x); //swap x value between 2*x and to 3*x |
|
endShape(); |
|
|
|
//details - top |
|
fill(ivory); |
|
noStroke(); |
|
quad(0, -2*x, 0.5*x, -1.5*x, 0, -1*x, -0.5*x, -1.5*x); |
|
strokeWeight(0.1); |
|
noFill(); |
|
stroke(fg_main); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, -1*x); |
|
vertex(-0.25*x, -1.5*x); |
|
vertex(0, -1.75*x); |
|
vertex(0.25*x, -1.5*x); |
|
vertex(0.05*x, -1.3*x); |
|
endShape(); |
|
|
|
stroke(ivory); |
|
strokeJoin(MITER); //left |
|
beginShape(); |
|
vertex(-0.5*x, -2*x); |
|
vertex(-1*x, -1.5*x); |
|
vertex(-0.5*x, -1*x); |
|
endShape(); |
|
strokeJoin(MITER); //right |
|
beginShape(); |
|
vertex(0.5*x, -2*x); |
|
vertex(x, -1.5*x); |
|
vertex(0.5*x, -1*x); |
|
endShape(); |
|
|
|
//details - bottom |
|
fill(ivory); |
|
noStroke(); |
|
quad(0, 2*x, 0.5*x, 1.5*x, 0, 1*x, -0.5*x, 1.5*x); |
|
strokeWeight(0.1); |
|
noFill(); |
|
stroke(fg_main); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, 1*x); |
|
vertex(-0.25*x, 1.5*x); |
|
vertex(0, 1.75*x); |
|
vertex(0.25*x, 1.5*x); |
|
vertex(0.05*x, 1.3*x); |
|
endShape(); |
|
|
|
stroke(249, 250, 217); |
|
strokeJoin(MITER); //left |
|
beginShape(); |
|
vertex(-0.5*x, 2*x); |
|
vertex(-1*x, 1.5*x); |
|
vertex(-0.5*x, 1*x); |
|
endShape(); |
|
strokeJoin(MITER); //right |
|
beginShape(); |
|
vertex(0.5*x, 2*x); |
|
vertex(x, 1.5*x); |
|
vertex(0.5*x, 1*x); |
|
endShape(); |
|
|
|
} |
|
|
|
/* |
|
* tilt_value is in degrees |
|
* eye_value is an integer number of eyes: either 0, 1, 2, or 3 |
|
* mouth_value is how open the mouth is and should generally range from 0.5 to 10 |
|
*/ |
|
function drawFace3(tilt_value, tongue_value, pukana_value, scale_value) { |
|
const bg_color3 = [225, 206, 187]; |
|
const fg_color3 = [79, 27, 6]; |
|
const fg_color4 = [48, 15, 2]; |
|
const shadow = [33, 9, 0]; |
|
const bone = [212, 199, 180]; |
|
const tongue = [107, 0, 11]; |
|
|
|
let x = scale_value; //original value 1.75 |
|
let y = (scale_value -0.25); // -0.25 |
|
let x2 = (scale_value +0.25); // +0.25 |
|
let y2 = (scale_value -0.5); // -0.5 |
|
//background values |
|
let x3 = scale_value +0.2; //original value 2.25 |
|
let y3 = (scale_value -0.2); // +0.25 |
|
let x4 = (scale_value +0.45); // +0.75 |
|
let y4 = (scale_value -0.4); // |
|
|
|
// rotation in degrees |
|
angleMode(DEGREES); |
|
rotate(tilt_value); |
|
//background taniwha |
|
fill(bone); |
|
stroke(bone); |
|
strokeWeight(0.1); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(-2*x3, 0); //start bottom of left eye |
|
vertex(-3*x3, -1*y4); |
|
vertex(-3*x3, -3*y4); |
|
vertex(-2*x3,-4*y4); |
|
vertex(-1*x3, -4*y4); |
|
vertex(0, -3*y4); //top middle |
|
vertex(x3, -4*y4); |
|
vertex(2*x3,-4*y4); |
|
vertex(3*x3, -3*y4); |
|
vertex(3*x3, -1*y4); |
|
vertex(2*x3, 0); //bottom of right eye |
|
vertex(x3, 0); |
|
vertex(0, y3); //bottom of nose |
|
vertex(-1*x3, 0); |
|
endShape(); |
|
//mouth |
|
stroke(bone); |
|
fill(bone); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, y3); //top middle of mouth (move clockwise) |
|
vertex(x3, 0); |
|
vertex(2*x4, 0); |
|
vertex(3*x4, y3); |
|
vertex(3.5*x4, 2*y3); // |
|
vertex(3*x4, 3*y3); |
|
vertex(1.5*x4, 4.5*y3); //bottom right |
|
vertex(0, 5*y3); |
|
vertex(-1.5*x4, 4.5*y3); //bottom left |
|
vertex(-3*x4, 3*y3); |
|
vertex(-3.5*x4, 2*y3); // |
|
vertex(-3*x4, y3); |
|
vertex(-2*x4, 0); |
|
vertex(-1*x3, 0); |
|
endShape(); |
|
|
|
//eyes |
|
stroke(fg_color3); |
|
strokeWeight(0.1); |
|
fill(fg_color3); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(-2*x, 0); //start bottom of left eye |
|
vertex(-3*x, -1*y2); |
|
vertex(-3*x, -3*y2); |
|
vertex(-2*x,-4*y2); |
|
vertex(-1*x, -4*y2); |
|
vertex(0, -3*y2); //top middle |
|
vertex(x, -4*y2); |
|
vertex(2*x,-4*y2); |
|
vertex(3*x, -3*y2); |
|
vertex(3*x, -1*y2); |
|
vertex(2*x, 0); //bottom of right eye |
|
vertex(x, 0); |
|
vertex(0, y); //bottom of nose |
|
vertex(-1*x, 0); |
|
endShape(); |
|
//inner eyes |
|
fill(shadow); |
|
stroke(shadow); |
|
strokeJoin(MITER); //left |
|
beginShape(); |
|
vertex(-1*x, 0); |
|
vertex(-1.75*x, -0.25*y2); |
|
vertex(-2.5*x, -1*y2); |
|
vertex(-2.5*x, -3*y2); |
|
vertex(-2*x, -3.5*y2); |
|
vertex(-1*x, -3.5*y2); |
|
vertex(-0.5*x, -3*y2); |
|
vertex(-0.5*x, -1*y2); |
|
endShape(); |
|
strokeJoin(MITER); //right |
|
beginShape(); |
|
vertex(1*x, 0); |
|
vertex(1.75*x, -0.25*y2); |
|
vertex(2.5*x, -1*y2); |
|
vertex(2.5*x, -3*y2); |
|
vertex(2*x, -3.5*y2); |
|
vertex(1*x, -3.5*y2); |
|
vertex(0.5*x, -3*y2); |
|
vertex(0.5*x, -1*y2); |
|
endShape(); |
|
// eyes |
|
fill(bone); |
|
noStroke(); |
|
ellipse(-1.5*x, -1.5*y, pukana_value/2, pukana_value/2); //left |
|
ellipse(1.5*x, -1.5*y, pukana_value/2, pukana_value/2); |
|
fill(0); |
|
ellipse(-1.5*x, -1.5*y, 1, 1); |
|
ellipse(1.5*x, -1.5*y, 1, 1); |
|
|
|
//mouth |
|
stroke(fg_color3); |
|
fill(fg_color3); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, y); //top middle of mouth (move clockwise) |
|
vertex(x, 0); |
|
vertex(2*x2, 0); |
|
vertex(3*x2, y); |
|
vertex(3.5*x2, 2*y); // |
|
vertex(3*x2, 3*y); |
|
vertex(1.5*x2, 4.5*y); //bottom right |
|
vertex(0, 5*y); |
|
vertex(-1.5*x2, 4.5*y); //bottom left |
|
vertex(-3*x2, 3*y); |
|
vertex(-3.5*x2, 2*y); // |
|
vertex(-3*x2, y); |
|
vertex(-2*x2, 0); |
|
vertex(-1*x, 0); |
|
endShape(); |
|
//inner mouth |
|
fill(shadow); |
|
stroke(shadow); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, 2*y); //top middle of inner mouth (move clockwise) |
|
vertex(0.75*x, 0.75*y); |
|
vertex(2*x, 0.5*y); |
|
vertex(2.75*x, 1.5*y); |
|
vertex(3*x, 2*y); // |
|
vertex(2.5*x, 3*y); |
|
vertex(1.5*x, 4*y); //bottom right |
|
vertex(0, 4.5*y); |
|
vertex(-1.5*x, 4*y); //bottom left |
|
vertex(-2.5*x, 3*y); |
|
vertex(-3*x, 2*y); // |
|
vertex(-2.75*x, 1.5*y); |
|
vertex(-2*x, 0.5*y); |
|
vertex(-0.75*x, 0.75*y); |
|
endShape(); |
|
//nose |
|
noStroke(); |
|
triangle(0, y, -0.25*x, 0, -0.75*x, 0.25*y); //left |
|
triangle(0, y, 0.25*x, 0, 0.75*x, 0.25*y); //right |
|
|
|
if(tongue_value == 3){ |
|
//teeth |
|
fill(bone); |
|
noStroke(); |
|
triangle(1.375*x, 0.625*y, 0.75*x, 0.75*y, 1*x, 1.5*y); |
|
triangle(1.375*x, 0.625*y, 2*x, 0.5*y, 1.75*x, 1.5*y); //top right |
|
triangle(-1.375*x, 0.625*y, -2*x, 0.5*y, -1.75*x, 1.5*y) //top left |
|
triangle(-1.375*x, 0.625*y, -0.75*x, 0.75*y, -1*x, 1.5*y); //for curved tongue |
|
//bottom row |
|
triangle(-1.5*x, 4*y, -2.25*x, 3.3*y, -1.65*x, 2.75*y); |
|
triangle(-0.75*x, 4.25*y, -1.5*x, 4*y, -1.075*x, 3.25*y); |
|
triangle(0, 4.5*y, -0.75*x, 4.25*y, -0.375*x, 3.25*y); //middle-left |
|
triangle(0, 4.5*y, 0.75*x, 4.25*y, 0.375*x, 3.25*y); //middle-right |
|
triangle(0.75*x, 4.25*y, 1.5*x, 4*y, 1.075*x, 3.25*y); |
|
triangle(1.5*x, 4*y, 2.25*x, 3.3*y, 1.65*x, 2.75*y); |
|
} |
|
else if(tongue_value == 1){ |
|
fill(tongue); |
|
stroke(tongue); |
|
strokeJoin(MITER); //original tongue |
|
beginShape(); |
|
vertex(0, 2*y); //middle point - clockwise |
|
vertex(0.75*x, 0.75*y); |
|
vertex(1.375*x, 0.625*y); |
|
vertex(1.25*x, 2*y); |
|
vertex(0, 6*y); //tongue point |
|
vertex(-1.25*x, 2*y); |
|
vertex(-1.375*x, 0.625*y); |
|
vertex(-0.75*x, 0.75*y); |
|
endShape(); |
|
//middle slit |
|
fill(74, 0, 8); |
|
stroke(74, 0, 8); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, 2*y); |
|
vertex(0.1*x, 1.85*y); |
|
vertex(0, 6*y); |
|
vertex(-0.1*x, 1.85*y); |
|
vertex(0, 2*y); |
|
endShape(); |
|
} |
|
else if(tongue_value ==2){ |
|
//teeth |
|
fill(bone); |
|
noStroke(); |
|
triangle(1.375*x, 0.625*y, 0.75*x, 0.75*y, 1*x, 1.5*y); |
|
triangle(1.375*x, 0.625*y, 2*x, 0.5*y, 1.75*x, 1.5*y); //top right |
|
triangle(-1.375*x, 0.625*y, -2*x, 0.5*y, -1.75*x, 1.5*y) //top left |
|
triangle(-1.375*x, 0.625*y, -0.75*x, 0.75*y, -1*x, 1.5*y); //for curved tongue |
|
//bottom row |
|
triangle(-1.5*x, 4*y, -2.25*x, 3.3*y, -1.65*x, 2.75*y); |
|
triangle(-0.75*x, 4.25*y, -1.5*x, 4*y, -1.075*x, 3.25*y); |
|
triangle(0, 4.5*y, -0.75*x, 4.25*y, -0.375*x, 3.25*y); //middle-left |
|
triangle(0, 4.5*y, 0.75*x, 4.25*y, 0.375*x, 3.25*y); //middle-right |
|
triangle(0.75*x, 4.25*y, 1.5*x, 4*y, 1.075*x, 3.25*y); |
|
triangle(1.5*x, 4*y, 2.25*x, 3.3*y, 1.65*x, 2.75*y); |
|
//tongue |
|
fill(tongue); |
|
stroke(tongue); |
|
strokeJoin(MITER); //curved tongue |
|
beginShape(); |
|
vertex(0, 2*y); //middle point - clockwise |
|
vertex(0.75*x, 0.75*y); |
|
vertex(1.375*x, 0.625*y); |
|
vertex(x, 2*y); |
|
vertex(0.25*x, 3*y); |
|
vertex(0, 4*y); |
|
vertex(0.5*x, 5.4*y); |
|
vertex(0.75*x, 5.25*y); //tip of curved tongue |
|
vertex(0.5*x, 5.75*y); |
|
vertex(-0.75*x, 4*y); |
|
vertex(-1*x, 2.25*y); |
|
vertex(-0.5*x, 1.2*y); |
|
vertex(0, 2*y); |
|
endShape(); |
|
//middle slit |
|
fill(74, 0, 8); |
|
stroke(74, 0, 8); |
|
strokeJoin(MITER); |
|
beginShape(); |
|
vertex(0, 2*y); |
|
vertex(0.75*x, 0.75*y); |
|
vertex(0, 2.5*y); |
|
vertex(-0.25*x, 4*y); |
|
vertex(0.5*x, 5.625*y); |
|
vertex(-0.45*x, 4*y); |
|
vertex(-0.42*x, 2.5*y); |
|
vertex(-0.19*x, 1.7*y); |
|
vertex(0, 2*y); |
|
endShape(); |
|
} |
|
|
|
|
|
} |