PageSourceSearch

https://lorica.ai/wp-content/themes/affari/js/canvas-water.js?ver=9

js lorica.ai collected 2026-10-05 16:08:59 UTC 6,342 bytes, 102 lines download raw bytes

1window.waterAnimation = function() {
2    "use strict";
3    var t, i = {
4            screen: {
5                elem: null,
6                callback: null,
7                ctx: null,
8                width: 0,
9                height: 0,
10                left: 0,
11                top: 0,
12                init: function(t, i, s) {
13                    return this.elem = document.getElementById(t), this.callback = i || null, "CANVAS" == this.elem.tagName && (this.ctx = this.elem.getContext("2d")), window.addEventListener("resize", function() {
14                        this.resize()
15                    }.bind(this), !1), this.elem.onselectstart = function() {
16                        return !1
17                    }, this.elem.ondrag = function() {
18                        return !1
19                    }, s && this.resize(), this
20                },
21                resize: function() {
22                    var t = this.elem;
23                    for (this.width = t.offsetWidth, this.height = t.offsetHeight, this.left = 0, this.top = 0; null != t; t = t.offsetParent) this.left += t.offsetLeft, this.top += t.offsetTop;
24                    this.ctx && (this.elem.width = this.width, this.elem.height = this.height), this.callback && this.callback()
25                }
26            }
27        },
28        s = function(t, i) {
29            this.x = t, this.y = i, this.magnitude = t * t + i * i, this.computed = 0, this.force = 0
30        };
31    s.prototype.add = function(t) {
32        return new s(this.x + t.x, this.y + t.y)
33    };
34    var h = function(t) {
35        var i = .1,
36            h = 1.5;
37        this.vel = new s((Math.random() > .5 ? 1 : -1) * (.2 + .25 * Math.random()), (Math.random() > .5 ? 1 : -1) * (.2 + Math.random())), this.pos = new s(.2 * t.width + Math.random() * t.width * .6, .2 * t.height + Math.random() * t.height * .6), this.size = t.wh / 15 + (Math.random() * (h - i) + i) * (t.wh / 15), this.width = t.width, this.height = t.height
38    };
39    h.prototype.move = function() {
40        this.pos.x >= this.width - this.size ? (this.vel.x > 0 && (this.vel.x = -this.vel.x), this.pos.x = this.width - this.size) : this.pos.x <= this.size && (this.vel.x < 0 && (this.vel.x = -this.vel.x), this.pos.x = this.size), this.pos.y >= this.height - this.size ? (this.vel.y > 0 && (this.vel.y = -this.vel.y), this.pos.y = this.height - this.size) : this.pos.y <= this.size && (this.vel.y < 0 && (this.vel.y = -this.vel.y), this.pos.y = this.size), this.pos = this.pos.add(this.vel)
41    };
42    var e = function(t, i, e, n, a) {
43        this.step = 5, this.width = t, this.height = i, this.wh = Math.min(t, i), this.sx = Math.floor(this.width / this.step), this.sy = Math.floor(this.height / this.step), this.paint = !1, this.metaFill = r(t, i, t, n, a), this.plx = [0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0], this.ply = [0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1], this.mscases = [0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 0, 2, 1, 1, 0], this.ix = [1, 0, -1, 0, 0, 1, 0, -1, -1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1], this.grid = [], this.balls = [], this.iter = 0, this.sign = 1;
44        for (var o = 0; o < (this.sx + 2) * (this.sy + 2); o++) this.grid[o] = new s(o % (this.sx + 2) * this.step, Math.floor(o / (this.sx + 2)) * this.step);
45        for (var l = 0; e > l; l++) this.balls[l] = new h(this)
46    };
47    e.prototype.computeForce = function(t, i, s) {
48        var h, e = s || t + i * (this.sx + 2);
49        if (0 === t || 0 === i || t === this.sx || i === this.sy) h = .6 * this.sign;
50        else {
51            h = 0;
52            for (var r, n = this.grid[e], a = 0; r = this.balls[a++];) h += r.size * r.size / (-2 * n.x * r.pos.x - 2 * n.y * r.pos.y + r.pos.magnitude + n.magnitude);
53            h *= this.sign
54        }
55        return this.grid[e].force = h, h
56    }, e.prototype.marchingSquares = function(t) {
57        var i = t[0],
58            s = t[1],
59            h = t[2],
60            e = i + s * (this.sx + 2);
61        if (this.grid[e].computed === this.iter) return !1;
62        for (var r, n = 0, a = 0; 4 > a; a++) {
63            var l = i + this.ix[a + 12] + (s + this.ix[a + 16]) * (this.sx + 2),
64                d = this.grid[l].force;
65            (d > 0 && this.sign < 0 || 0 > d && this.sign > 0 || !d) && (d = this.computeForce(i + this.ix[a + 12], s + this.ix[a + 16], l)), Math.abs(d) > 1 && (n += Math.pow(2, a))
66        }
67        if (15 === n) return [i, s - 1, !1];
68        5 === n ? r = 2 === h ? 3 : 1 : 10 === n ? r = 3 === h ? 0 : 2 : (r = this.mscases[n], this.grid[e].computed = this.iter);
69        var p = this.step / (Math.abs(Math.abs(this.grid[i + this.plx[4 * r + 2] + (s + this.ply[4 * r + 2]) * (this.sx + 2)].force) - 1) / Math.abs(Math.abs(this.grid[i + this.plx[4 * r + 3] + (s + this.ply[4 * r + 3]) * (this.sx + 2)].force) - 1) + 1);
70        return o.lineTo(this.grid[i + this.plx[4 * r] + (s + this.ply[4 * r]) * (this.sx + 2)].x + this.ix[r] * p, this.grid[i + this.plx[4 * r + 1] + (s + this.ply[4 * r + 1]) * (this.sx + 2)].y + this.ix[r + 4] * p), this.paint = !0, [i + this.ix[r + 4], s + this.ix[r + 8], r]
71    }, e.prototype.renderMetaballs = function() {
72        for (var t, i = 0; t = this.balls[i++];) t.move();
73        for (this.iter++, this.sign = -this.sign, this.paint = !1, o.fillStyle = this.metaFill, o.beginPath(), i = 0; t = this.balls[i++];) {
74            var s = [Math.round(t.pos.x / this.step), Math.round(t.pos.y / this.step), !1];
75            do s = this.marchingSquares(s); while (s);
76            this.paint && (o.fill(), o.closePath(), o.beginPath(), this.paint = !1, o.filter = 'blur(75px)') //matt added filter
77        }
78    };
79    var r = function(t, i, s, h, e) {
80        var r = o.createRadialGradient(t / 1, i / 1, 0, t / 1, i / 1, s);
81        return r.addColorStop(0, h), r.addColorStop(1, e), r
82    };
83    if (document.getElementById("water-anim")) {
84        var n = function() {
85                requestAnimationFrame(n), o.clearRect(0, 0, a.width, a.height), t.renderMetaballs()
86            },
87            a = i.screen.init("water-anim", null, !0),
88            o = a.ctx;
89        a.resize(), t = new e(a.width, a.height, 6, "#252B8D", "#252B8D")
90    }
91    return {
92        run: n
93    }
94}();
95
96if (document.getElementById('water-anim')) {
97    waterAnimation.run();
98    
99}
100setTimeout(function() {
101    //$('.js-works-d-list').addClass('is-loaded');
102}, 150);

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.