// Example usage
new Element('div', {
className: 'galaxy',
style: {
top: 0,
left: 0
}
}).appendTo(document.body);
new Element('div', {
className: 'star',
style: {
top: 0,
right: 0
}
}).appendTo(document.body);
new Element('div', {
className: 'gas',
style: {
bottom: 0,
right: 0
}
}).appendTo(document.body);
// Initialize the animation
document.addEventListener('DOMContentLoaded', function () {
const galaxyElements = document.querySelectorAll('.galaxy');
const starElements = document.querySelectorAll('.star');
const gasElements = document.querySelectorAll('.gas');
galaxyElements.forEach(function (element) {
element.style.transform = 'translate(' + getRandomNumber(0, window.innerWidth) + 'px, ' + getRandomNumber(0, window.innerHeight) + 'px)';
});
starElements.forEach(function (element) {
element.style.animationDelay = getRandomNumber(0, 10) + 's';
});
gasElements.forEach(function (element) {
element.style.transform = 'translate(' + getRandomNumber(0, window.innerWidth) + 'px, ' + getRandomNumber(0, window.innerHeight) + 'px)';
});
});
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}