-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstars.js
More file actions
40 lines (33 loc) · 1.38 KB
/
stars.js
File metadata and controls
40 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Stars background generator for Bot Sportello Arcade
// Auto-creates twinkling starry sky effect
(function() {
// Create stars container if it doesn't exist
let starsContainer = document.getElementById('stars');
if (!starsContainer) {
starsContainer = document.createElement('div');
starsContainer.id = 'stars';
starsContainer.className = 'stars';
document.body.insertBefore(starsContainer, document.body.firstChild);
}
const colors = ['', 'blue', 'cyan', 'red'];
for (let i = 0; i < 150; i++) {
const star = document.createElement('div');
star.className = 'star';
// Random color (mostly white, some colored)
if (Math.random() > 0.7) {
const colorClass = colors[Math.floor(Math.random() * colors.length)];
if (colorClass) star.classList.add(colorClass);
}
// Random size (1-3px)
const size = Math.random() * 2 + 1;
star.style.width = size + 'px';
star.style.height = size + 'px';
// Random position
star.style.left = Math.random() * 100 + '%';
star.style.top = Math.random() * 100 + '%';
// Random animation delay for staggered twinkling
star.style.animationDelay = Math.random() * 3 + 's';
star.style.animationDuration = (Math.random() * 2 + 2) + 's';
starsContainer.appendChild(star);
}
})();