This commit is contained in:
End 2025-12-19 19:52:22 -07:00
parent 3a7bf63067
commit 7bc0ad72ba
No known key found for this signature in database
6 changed files with 213 additions and 0 deletions

BIN
img/backgroundtile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
img/ornaments.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
img/tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

29
index.html Normal file
View file

@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Haxmas Day 7</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=VT323&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="header">
<h1 class="important-text">Haxmas Day 7</h1>
<h2 id="date"></h2>
</div>
<div id="tree-container">
<div id="tree"></div>
<div id="star"></div>
<div id="decorations"></div>
</div>
<script src="script.js"></script>
</body>
</html>

87
script.js Normal file
View file

@ -0,0 +1,87 @@
const date = new Date();
const days = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
const ornamentPositions = [
// Row 1
{ x: 0, y: 0 },
{ x: 16, y: 0 },
{ x: 32, y: 0 },
{ x: 48, y: 0 },
{ x: 64, y: 0 },
{ x: 80, y: 0 },
// Row 2
{ x: 0, y: 16 },
{ x: 16, y: 16 },
{ x: 32, y: 16 },
{ x: 48, y: 16 },
{ x: 64, y: 16 },
{ x: 80, y: 16 },
// Row 3
{ x: 0, y: 32 },
{ x: 16, y: 32 },
{ x: 32, y: 32 },
{ x: 48, y: 32 },
{ x: 64, y: 32 },
{ x: 80, y: 32 },
// Row 4
{ x: 0, y: 48 },
{ x: 16, y: 48 },
{ x: 32, y: 48 },
{ x: 48, y: 48 },
{ x: 64, y: 48 },
{ x: 80, y: 48 },
];
const stars = ["⭐", "💫", "💖", "🎄", "🏴‍☠️", "👾", "✨", "🌟"];
function changeStar() {
let randomIndex = Math.floor(Math.random() * stars.length);
document.getElementById("star").innerText = stars[randomIndex];
}
function getTreeX(y) {
const center = 132;
const maxWidth = 100;
const minWidth = 10;
const progress = Math.min(Math.max((y - 50) / 350, 0), 1);
const widthAtY = minWidth + (maxWidth - minWidth) * progress;
return center + (Math.random() - 0.5) * 2 * widthAtY;
}
document.addEventListener("DOMContentLoaded", () => {
const decorations = document.getElementById("decorations");
const dateText = document.getElementById("date");
const star = document.getElementById("star");
dateText.innerText = days + "/" + month + "/" + year;
let ornamentCount = 5;
if (month === 12) {
ornamentCount = Math.max(25 - days, 0);
}
for (let i = 0; i < ornamentCount; i++) {
const randomPos =
ornamentPositions[Math.floor(Math.random() * ornamentPositions.length)];
const ornament = document.createElement("div");
ornament.className = "ornament";
ornament.id = "ornament" + i;
ornament.style.backgroundPosition = `-${randomPos.x}px -${randomPos.y}px`;
const y = Math.random() * 300 + 80;
const x = getTreeX(y);
ornament.style.left = x + "px";
ornament.style.top = y + "px";
decorations.appendChild(ornament);
}
star.addEventListener("click", changeStar);
});

97
style.css Normal file
View file

@ -0,0 +1,97 @@
body {
font-family: "VT323", monospace;
background: linear-gradient(180deg, #0f0f23 0%, #1a1a3e 50%, #0f0f23 100%);
color: azure;
margin: 0;
padding: 20px;
min-height: 100vh;
}
#header,
#footer {
text-align: center;
}
#header h1 {
font-size: 3rem;
margin-bottom: 0;
}
#header h2 {
font-size: 1.5rem;
margin-top: 0.5rem;
}
#tree-container {
width: 264px;
height: 456px;
margin: 2rem auto;
position: relative;
overflow: hidden;
}
#tree {
width: 264px;
height: 456px;
background-image: url("img/tree.png");
background-repeat: no-repeat;
image-rendering: pixelated;
animation: tree-lights 0.8s steps(1) infinite;
}
@keyframes tree-lights {
0% {
background-position: 0 0;
}
25% {
background-position: -264px 0;
}
50% {
background-position: 0 -456px;
}
75% {
background-position: -264px -456px;
}
100% {
background-position: 0 0;
}
}
#star {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
font-size: 3rem;
z-index: 5;
cursor: pointer;
transition: transform 0.2s;
}
#star:hover {
transform: translateX(-50%) scale(1.2);
}
#decorations {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.ornament {
width: 16px;
height: 16px;
background-image: url("img/ornaments.png");
background-repeat: no-repeat;
position: absolute;
z-index: 10;
transform: scale(2);
image-rendering: pixelated;
}
.important-text {
color: #5bc0de;
}