PageSourceSearch

https://chenxi9981.github.io/js/universe.js

js chenxi9981.github.io collected 2026-10-03 08:47:23 UTC 3,073 bytes, 61 lines download raw bytes

1function dark() {
2    window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
3    var n, e, i, h, t = .05,
4        s = document.getElementById("universe"),
5        o = !0,
6        a = "180,184,240",
7        r = "226,225,142",
8        d = "226,225,224",
9        c = [];
10
11    function f() {
12        n = window.innerWidth, e = window.innerHeight, i = .216 * n, s.setAttribute("width", n), s.setAttribute("height", e)
13    }
14
15    function u() {
16        h.clearRect(0, 0, n, e);
17        for (var t = c.length, i = 0; i < t; i++) {
18            var s = c[i];
19            s.move(), s.fadeIn(), s.fadeOut(), s.draw()
20        }
21    }
22
23    function y() {
24        this.reset = function () {
25            this.giant = m(3), this.comet = !this.giant && !o && m(10), this.x = l(0, n - 10), this.y = l(0, e), this.r = l(1.1, 2.6), this.dx = l(t, 6 * t) + (this.comet + 1 - 1) * t * l(50, 120) + 2 * t, this.dy = -l(t, 6 * t) - (this.comet + 1 - 1) * t * l(50, 120), this.fadingOut = null, this.fadingIn = !0, this.opacity = 0, this.opacityTresh = l(.2, 1 - .4 * (this.comet + 1 - 1)), this.do = l(5e-4, .002) + .001 * (this.comet + 1 - 1)
26        }, this.fadeIn = function () {
27            this.fadingIn && (this.fadingIn = !(this.opacity > this.opacityTresh), this.opacity += this.do)
28        }, this.fadeOut = function () {
29            this.fadingOut && (this.fadingOut = !(this.opacity < 0), this.opacity -= this.do / 2, (this.x > n || this.y < 0) && (this.fadingOut = !1, this.reset()))
30        }, this.draw = function () {
31            if (h.beginPath(), this.giant) h.fillStyle = "rgba(" + a + "," + this.opacity + ")", h.arc(this.x, this.y, 2, 0, 2 * Math.PI, !1);
32            else if (this.comet) {
33                h.fillStyle = "rgba(" + d + "," + this.opacity + ")", h.arc(this.x, this.y, 1.5, 0, 2 * Math.PI, !1);
34                for (var t = 0; t < 30; t++) h.fillStyle = "rgba(" + d + "," + (this.opacity - this.opacity / 20 * t) + ")", h.rect(this.x - this.dx / 4 * t, this.y - this.dy / 4 * t - 2, 2, 2), h.fill()
35            } else h.fillStyle = "rgba(" + r + "," + this.opacity + ")", h.rect(this.x, this.y, this.r, this.r);
36            h.closePath(), h.fill()
37        }, this.move = function () {
38            this.x += this.dx, this.y += this.dy, !1 === this.fadingOut && this.reset(), (this.x > n - n / 4 || this.y < 0) && (this.fadingOut = !0)
39        }, setTimeout(function () {
40            o = !1
41        }, 50)
42    }
43
44    function m(t) {
45        return Math.floor(1e3 * Math.random()) + 1 < 10 * t
46    }
47
48    function l(t, i) {
49        return Math.random() * (i - t) + t
50    }
51    f(), window.addEventListener("resize", f, !1),
52        function () {
53            h = s.getContext("2d");
54            for (var t = 0; t < i; t++) c[t] = new y, c[t].reset();
55            u()
56        }(),
57        function t() {
58            document.getElementsByTagName('html')[0].getAttribute('data-theme') == 'dark' && u(), window.requestAnimationFrame(t)
59        }()
60};
61dark()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.