xxxxxxxxxx
44
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
drawGhost();
}
function drawGhost() {
noStroke();
fill("white");
const x = width/2;
const y = height/2;
const ghostWidth = 75;
const ghostHeight = 100;
const numPoints = 8;
const spacing = ghostWidth/numPoints;
rectMode(CENTER);
rect(x, y+ghostHeight/4, ghostWidth, ghostHeight/2);
ellipse(x, y, ghostWidth, ghostHeight);
const triHeight = 10;
const rectHeight = ghostHeight/2;
beginShape();
curveVertex(x-ghostWidth/2, y+rectHeight);
for (let i = 0; i <= numPoints; i++) {
// stroke("red");
// strokeWeight(5);
point(x-ghostWidth/2 + i*spacing, y+rectHeight+triHeight*(i%2));
noStroke();
// stroke("black");
// strokeWeight(1);
curveVertex(x-ghostWidth/2 + i*spacing, y+rectHeight+triHeight*(i%2));
}
curveVertex(x-ghostWidth/2 + numPoints*spacing, y+rectHeight+triHeight*(numPoints%2));
endShape();
fill("black");
ellipse(x-15,y-18, 10, 10);
ellipse(x+15,y-18, 10, 10);
noFill();
stroke("black");
strokeWeight(3);
arc(x, y, 10, 10, 0, -PI);
}