xxxxxxxxxx
136
let colorgrad = [255, 215, 0];
function setup() {
frameRate(60);
createCanvas(400, 400);
background(0);
}
function draw() {
//Controlling the color of the image with changing values
stroke(colorgrad[0], colorgrad[1], colorgrad[2]);
strokeWeight(2);
noSmooth();
//Forming the outside borders of the image
line(200, 30, 60, 80);
line(60, 80, 60, 160);
line(60, 160, 60, 240);
line(60, 240, 160, 370);
line(160, 370, 240, 370);
line(240, 370, 340, 240);
line(340, 240, 340, 240);
line(340, 240, 340, 80);
line(340, 80, 200, 30);
//left lower chin
for (let i = 80; i < 340; i += 20) {
strokeWeight(1);
// line(160,370,i,240)
}
//right lower chin, left lower chin
//forehead and face base
for (let i = 80; i < 340; i += 20) {
strokeWeight(1);
line(160, 370, i, 240);
line(240, 370, i, 240);
line(i, 240, i, 80);
line(200, 30, i, 80);
}
//lines connecting accross the face
for (let i = 80; i <= 240; i += 20) {
strokeWeight(1);
line(60, 80, 340, i);
line(60, 240, 340, i);
line(340, 80, 60, i);
line(340, 240, 60, i);
}
//Triangular Cheek left
for (let i = 200; i >= 60; i -= 20) {
noFill();
strokeWeight(1);
triangle(i, 160, 60, 80, 60, 240);
}
//Triangular Cheek right
for (let i = 200; i <= 340; i += 20) {
noFill();
strokeWeight(1);
triangle(i, 160, 340, 80, 340, 240);
}
//Eyes
strokeWeight(2);
quad(125, 165, 155, 165, 180, 145, 100, 145);
quad(275, 165, 245, 165, 220, 145, 300, 145);
//Pupil Left
for (let i = 125; i < 155; i += 2) {
stroke(0, 255, 255);
strokeWeight(0.7);
line(140, 145, i, 164);
}
//Pupil Right
for (let i = 245; i < 275; i += 2) {
stroke(0, 255, 255);
strokeWeight(0.7);
line(260, 145, i, 164);
}
stroke(colorgrad[0], colorgrad[1], colorgrad[2]);
strokeWeight(2);
//Upper Lip
noFill();
strokeWeight(1.5);
strokeJoin(MITER);
beginShape();
vertex(200, 270);
vertex(150, 285);
vertex(250, 285);
vertex(200, 270);
endShape();
//Lower Lip
noFill();
strokeWeight(1.5);
strokeJoin(MITER);
beginShape();
vertex(200, 300);
vertex(150, 285);
vertex(250, 285);
vertex(200, 300);
endShape();
//Upper Lip Fill
for (let i = 160; i < 250; i += 10) {
strokeWeight(1);
line(200, 270, i, 285);
}
//Lower Lip Fill
for (let i = 160; i < 250; i += 10) {
strokeWeight(1);
line(200, 300, i, 285);
}
//Color Shifting at the end of the draw loop
colorgrad[0] -= 1;
colorgrad[1] -= 1;
//If colorgrad[1] falls, then reset it back to golden
if (colorgrad[1] <= 0) {
colorgrad[0] = 255;
colorgrad[1] = 215;
}
print(mouseX, ", ", mouseY);
print(colorgrad);
}