-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstars.js
More file actions
48 lines (36 loc) · 1.18 KB
/
stars.js
File metadata and controls
48 lines (36 loc) · 1.18 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
41
42
43
44
45
46
47
48
document.addEventListener("DOMContentLoaded", function(event) {
Galaxy.makeGalaxy();
});
window.Galaxy = {
makeGalaxy: function() {
var the_number_of_stars_the_sky_should_have = 1000,
the_number_of_stars_in_the_sky_now = 0,
galaxy_element,
height = window.outerHeight,
width = window.outerWidth;
galaxy_element = document.createElement('div');
galaxy_element.setAttribute("style",
"height: 100%;" +
"width: 100%;" +
"position: absolute;"
);
document.body.insertBefore(galaxy_element, document.getElementById('content'));
while (the_number_of_stars_in_the_sky_now < the_number_of_stars_the_sky_should_have) {
var new_star = document.createElement('div'),
x,
y;
new_star.innerText = "*";
x = Math.random() * width;
y = Math.random() * height;
new_star.setAttribute('style',
"color: white;" +
"position: absolute;" +
"font-size: 8px;" +
"right: " + x + "px;" +
"top: " + y + "px;"
);
galaxy_element.appendChild(new_star);
the_number_of_stars_in_the_sky_now = the_number_of_stars_in_the_sky_now + 1;
}
}
}