MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / animation

Function animation

assets/js/Animated_Background.js:1–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1function animation () {
2
3 const colors = ["2196F3", "e91e63", "ffeb3b", "74ff1d"];
4
5 const section = document.querySelector("section");
6 const square = document.createElement("span");
7 const star = document.createElement("i");
8
9 star.classList.add("fas");
10 star.classList.add("fa-star");
11
12 let size = Math.random() * 100;
13
14 star.style.height = 20 + size + "px";
15 star.style.width = 20 + size + "px";
16
17 star.style.top = Math.random() * innerHeight + "px";
18 star.style.left = Math.random() * innerWidth + "px";
19
20 // const randomColor = Math.floor(Math.random()*16777215).toString(16);
21 let randomColor = colors[Math.floor(Math.random()*4)];
22 star.style.color = "#" + randomColor;
23
24 section.appendChild(star);
25
26 size = Math.random() * 20;
27
28 square.style.height = 20 + size + "px";
29 square.style.width = 20 + size + "px";
30
31 square.style.top = Math.random() * innerHeight + "px";
32 square.style.left = Math.random() * innerWidth + "px";
33
34 randomColor = colors[Math.floor(Math.random()*4)];
35 square.style.backgroundColor = "#" + randomColor;
36
37 section.appendChild(square);
38
39 setTimeout(function() {
40 section.removeChild(square);
41 section.removeChild(star);
42 }, 5000);
43}
44
45setInterval(animation,100);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected