xxxxxxxxxx
//setting the variables
let tailColor;
let bodyColor;
let bodyWidth;
let bodyHeight;
let headColor;
let headSize;
let faceColor;
let faceSize;
let hairColor;
let perchColor;
let legsColor;
let legsWidth;
let legsHeight;
let faceDetailColor;
let wingColor;
function setup() {
createCanvas(600, 600);
background(162, 208, 232);
generateBirdProperties();
drawBird();
}
function drawBird() {
//tail
noStroke(); //no outline
fill(tailColor);
//quadrilateral, four-sided shape
quad(270, 450, 330, 450, 365, 600, 235, 600);
stroke(255); //white outline
noFill();
line(340, 600, 300, 270)
line(260, 600, 300, 270)
line(300, 600, 300, 270)
//body
noStroke();
fill(bodyColor);
ellipse(300, 320, bodyWidth, bodyHeight);
//head
noStroke()
fill(headColor);
ellipse(300, 140, headSize);
//face
noStroke()
fill(faceColor);
ellipse(300, 135, faceSize);
// Hair
fill(hairColor);
triangle(300, 10, 275, 70, 325, 70);
//perch
fill(perchColor);
rect(0, 450, 600, 28);
//right leg
stroke(255)
fill(legsColor);
ellipse(330, 460, 20, 40); //finger1
ellipse(340, 460, 20, 40); //finger2
ellipse(350, 460, 20, 40); //finger3
//left leg
strokeWeight(2)
fill(legsColor);
ellipse(270, 460, 20, 40); //finger1
ellipse(260, 460, 20, 40); //finger2
ellipse(250, 460, 20, 40); //finger3
//face details
noStroke();
//cheeks
fill(faceDetailColor);
ellipse(255, 150, 45, 50);
ellipse(345, 150, 45, 50);
//beak
fill(255, 204, 179);
triangle(280, 140, 320, 140, 300, 190)
//outer nostrils
fill(250, 192, 162);
ellipse(306, 140, 15, 15);
ellipse(296, 140, 15, 15);
//inner nostrils
fill(255, 204, 179);
ellipse(296, 140, 10, 10);
ellipse(306, 140, 10, 10);
//eyes
noStroke();
//eyeline
fill(179, 179, 179);
ellipse(280, 110, 30, 40);
ellipse(320, 110, 30, 40);
//pupil
fill(0, 0, 0);
ellipse(280, 110, 25, 35);
ellipse(320, 110, 25, 35);
//shine
fill(255, 255, 255);
ellipse(280, 102, 6, 6);
ellipse(320, 102, 6, 6);
//right wing
fill(201, 199, 199);
triangle(340, 240, 400, 240, 370, 430)
ellipse(370, 240, 60, 60);
stroke(255)
fill(0, 0, 255);
line(370, 300, 370, 430)
line(390, 280, 370, 430)
//left wing
noStroke();
fill(201, 199, 199);
triangle(260, 240, 200, 240, 230, 430);
ellipse(230, 240, 60, 60);
stroke(255)
fill(0, 0, 0);
line(230, 300, 230, 430);
line(210, 280, 230, 430)
}
function generateBirdProperties() {
tailColor = color(random(255), random(255), random(255));
// b/w 0-255, random RGB color
bodyColor = color(random(255), random(255), random(255));
bodyWidth = random(150, 200);
bodyHeight = random(250, 300);
headColor = color(random(255), random(255), random(255));
headSize = random(120, 160);
faceColor = color(random(255), random(255), random(255));
faceSize = random(130, 150);
hairColor = color(random(255), random(255), random(255));
perchColor = color(random(255), random(255), random(255));
legsColor = color(random(255), random(255), random(255));
legsWidth = random(15, 25);
legsHeight = random(30, 50);
faceDetailColor = color(random(255), random(255), random(255));
wingColor = color(random(255), random(255), random(255));
}
//interactive feature
function keyPressed() {
if (keyCode === 32) { //spacebar key
background(162, 208, 232); //clear canvas
generateBirdProperties();
drawBird();
}
}