xxxxxxxxxx
62
// Spiky hair character
//
// Jared Donovan 2022
//
// Draws a character with spiky hair.
let bgColor = "#5CA7CB";
let faceYellow = "#FBFF83";
function setup(){
createCanvas(200, 200);
strokeWeight(2);
strokeCap(ROUND);
}
function draw(){
background(bgColor);
stroke(0);
// Draw Face
// Translate to the middle of the page and draw face
translate(width / 2, height / 2);
fill(faceYellow);
ellipse(0, 0, 150);
// Draw Hair
// Hair will be drawn rotated around the
// centre-point from -130 degrees to -50 degrees
push();
rotate(radians(-130));
for(let i = 0; i <= 8; i++){
line(75, 0, 85, 0);
rotate(radians(10));
}
pop();
// Draw Eyes
fill(0);
noStroke();
// Translate & rotate so eyes are endearingly angled
push();
translate(50, -10)
rotate(radians(-10));
ellipse(0, 0, 12, 24);
pop();
// Translate & rotate to the other side for the left eye
push();
translate(-50, -10);
rotate(radians(10));
ellipse(0, 0, 12, 24);
pop();
// Mouth
// Draw the mouth as an open arc
push();
translate(0, 20);
arc(0, 0, 102, 82, 0, PI);
pop();
}