xxxxxxxxxx
130
//Inspired by current chrismas and war situation we are in. All I want for Chrismas is BringTheHostageHome and AnApartmentWithMamad!
let star;
let myFont;
let chrismas;
let snow;
function preload() {
myFont = loadFont("HelloKetta.otf");
star = loadModel("star.obj");
snow = loadModel("snow.obj");
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
textFont(myFont);
}
function draw() {
background(0);
STAR();
Snowing();
trunk();
spiral(160, windowWidth / 2);
spiral(120, windowWidth / 3);
spiral(80, windowWidth / 4);
spiral(40, windowWidth / 5);
spiral(0, windowWidth / 6);
spiral(-40, windowWidth / 7);
spiral(-80, windowWidth / 8);
spiral(-120, windowWidth / 12);
TXT("All", -10, -105);
TXT("I", 0, -65);
TXT("Want", -20, -30);
TXT("For", -10, 10);
TXT("Chrismas", -40, 45);
TXT("Is", -5, 85);
TXT("BringTheHostageBack", -92, 115);
TXT("AndAnApartmentWithMamad", -120, 155);
}
function trunk() {
push();
translate(0, 300, 0);
rotateY(frameCount * 0.01);
fill(139, 69, 19);
cylinder(20, 250);
pop();
}
function spiral(x, y) {
push();
translate(0, x, 0);
fill(0, 100, 0);
rotateX(frameCount * 0.01);
rotate(HALF_PI);
cylinder(20, y);
pop();
}//I asked chatGPT for changing the direction of the cylinder
function Snowing() {
for (let countX = -width; countX < width; countX = countX + 100) {
for (let countY = -height; countY < height; countY = countY + 100) {
push();
scale(0.5);
stroke(0, 20);
translate(countX, countY, 0);
rotateX(frameCount * 0.1);
rotateY(frameCount * 0.2);
rotateZ(frameCount * 0.3);
model(snow);
pop();
}
}
}
/*I tried to make the snow falling down but failed:
for (countSnow = -windowWidth; countSnow < windowWidth; countSnow = countSnow + 50) {
push(); translate(random(-windowWidth,windowWidth),z, 0);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
rotateZ(frameCount * 0.01);
scale(0.5);
stroke(0, 20);
model(snow); pop();
z=z+0.1
if(z>height){z=-height}
}
}*/
function TXT(a, b, c) {
push();
translate(0, 0, 60);//make the text in the front
textSize(20);
text(a, b, c);
pop();
}//Learned from the selected assignment about text.
function STAR() {
push();
translate(0, -180, 0);
noStroke();
fill(231, 156, 0);
scale(0.6);
rotateY(frameCount * 0.04);
model(star);
pop();
}
function mousePressed() {
if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
let fs = fullscreen();
fullscreen(!fs);
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}