xxxxxxxxxx
74
let snowman;
function setup() {
createCanvas(400, 400, WEBGL);
snowman = new Snowman();
noLoop(); // Remove the automatic rotation
}
function draw() {
background(200);
snowman.display();
}
class Snowman {
constructor() {
this.bodyRadius = 100;
this.headRadius = 70;
this.eyeRadius = 10;
this.noseSize = 20;
this.mouthSize = 10;
this.positionY = 50; // Adjust the position along the Y-axis
this.strokeColor = 200; // Grey outline color
}
display() {
// Body
push();
translate(0, this.positionY, 0);
fill(255);
stroke(this.strokeColor); // Grey outline
sphere(this.bodyRadius);
pop();
// Head
push();
translate(0, this.positionY - this.bodyRadius - this.headRadius / 2, 0);
fill(255);
stroke(this.strokeColor); // Grey outline
sphere(this.headRadius);
pop();
// Eyes
push();
translate(-this.headRadius / 3, this.positionY - this.headRadius / 5, this.headRadius / 3);
fill(0);
stroke(this.strokeColor); // Grey outline
sphere(this.eyeRadius);
pop();
push();
translate(this.headRadius / 3, this.positionY - this.headRadius / 5, this.headRadius / 3);
fill(0);
stroke(this.strokeColor); // Grey outline
sphere(this.eyeRadius);
pop();
// Nose
push();
translate(0, this.positionY - this.headRadius / 5, this.headRadius / 2);
fill(255, 165, 0);
stroke(255,0,0); // Grey outline
cone(this.noseSize, this.noseSize * 2);
pop();
// Mouth
push();
translate(0, this.positionY - this.headRadius / 5, this.headRadius / 3);
fill(255, 0, 0);
stroke(this.strokeColor); // Grey outline
torus(this.mouthSize, this.mouthSize / 2, 10, 3);
pop();
}
}