varia.website/themes/varia/static/js/stars.js

28 lines
574 B
JavaScript
Raw Normal View History

2017-07-06 14:28:42 +02:00
// stars.js
// Random Stars
2021-01-19 21:50:17 +01:00
var generateStars = function () {
var $galaxy = $(".galaxy");
var iterator = 0;
while (iterator <= 100) {
var xposition = Math.random();
var yposition = Math.random();
var star_type = Math.floor(Math.random() * 3 + 1);
var position = {
x: $galaxy.width() * xposition,
y: $galaxy.height() * yposition,
};
$('<div class="star star-type' + star_type + '"></div>')
.appendTo($galaxy)
.css({
top: position.y,
left: position.x,
});
iterator++;
}
2017-07-06 14:28:42 +02:00
};
2021-01-19 21:50:17 +01:00
generateStars();