Skip to content

Instantly share code, notes, and snippets.

@arackaf
Created November 21, 2020 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arackaf/9f9730284c01b747198056a6f79e7bf3 to your computer and use it in GitHub Desktop.
Save arackaf/9f9730284c01b747198056a6f79e7bf3 to your computer and use it in GitHub Desktop.
var app = (function () {
"use strict";
function t() {}
function n(t) {
return t();
}
function e() {
return Object.create(null);
}
function r(t) {
t.forEach(n);
}
function o(t) {
return "function" == typeof t;
}
function i(t, n) {
return t != t ? n == n : t !== n || (t && "object" == typeof t) || "function" == typeof t;
}
function c(n, ...e) {
if (null == n) return t;
const r = n.subscribe(...e);
return r.unsubscribe ? () => r.unsubscribe() : r;
}
function s(t, n, e) {
t.$$.on_destroy.push(c(n, e));
}
function a(t, n, e, r) {
if (t) {
const o = u(t, n, e, r);
return t[0](o);
}
}
function u(t, n, e, r) {
return t[1] && r
? (function (t, n) {
for (const e in n) t[e] = n[e];
return t;
})(e.ctx.slice(), t[1](r(n)))
: e.ctx;
}
function l(t, n, e, r, o, i, c) {
const s = (function (t, n, e, r) {
if (t[2] && r) {
const o = t[2](r(e));
if (void 0 === n.dirty) return o;
if ("object" == typeof o) {
const t = [],
e = Math.max(n.dirty.length, o.length);
for (let r = 0; r < e; r += 1) t[r] = n.dirty[r] | o[r];
return t;
}
return n.dirty | o;
}
return n.dirty;
})(n, r, o, i);
if (s) {
const o = u(n, e, r, c);
t.p(o, s);
}
}
function f(t, n, e) {
t.insertBefore(n, e || null);
}
function d(t) {
t.parentNode.removeChild(t);
}
function $() {
return (t = " "), document.createTextNode(t);
var t;
}
function h(t, n, e, r) {
return t.addEventListener(n, e, r), () => t.removeEventListener(n, e, r);
}
function p(t, n, e) {
null == e ? t.removeAttribute(n) : t.getAttribute(n) !== e && t.setAttribute(n, e);
}
function m(t, n, e, r) {
t.style.setProperty(n, e, r ? "important" : "");
}
let g;
function v(t) {
g = t;
}
function x() {
if (!g) throw new Error("Function called outside component initialization");
return g;
}
function y(t) {
x().$$.on_mount.push(t);
}
const b = [],
w = [],
M = [],
S = [],
k = Promise.resolve();
let z = !1;
function A(t) {
M.push(t);
}
let _ = !1;
const E = new Set();
function F() {
if (!_) {
_ = !0;
do {
for (let t = 0; t < b.length; t += 1) {
const n = b[t];
v(n), q(n.$$);
}
for (v(null), b.length = 0; w.length; ) w.pop()();
for (let t = 0; t < M.length; t += 1) {
const n = M[t];
E.has(n) || (E.add(n), n());
}
M.length = 0;
} while (b.length);
for (; S.length; ) S.pop()();
(z = !1), (_ = !1), E.clear();
}
}
function q(t) {
if (null !== t.fragment) {
t.update(), r(t.before_update);
const n = t.dirty;
(t.dirty = [-1]), t.fragment && t.fragment.p(t.ctx, n), t.after_update.forEach(A);
}
}
const P = new Set();
function O(t, n) {
t && t.i && (P.delete(t), t.i(n));
}
function L(t, n, e, r) {
if (t && t.o) {
if (P.has(t)) return;
P.add(t),
undefined.c.push(() => {
P.delete(t), r && (e && t.d(1), r());
}),
t.o(n);
}
}
const j = "undefined" != typeof window ? window : "undefined" != typeof globalThis ? globalThis : global;
function R(t) {
t && t.c();
}
function T(t, e, i) {
const { fragment: c, on_mount: s, on_destroy: a, after_update: u } = t.$$;
c && c.m(e, i),
A(() => {
const e = s.map(n).filter(o);
a ? a.push(...e) : r(e), (t.$$.on_mount = []);
}),
u.forEach(A);
}
function C(t, n) {
const e = t.$$;
null !== e.fragment && (r(e.on_destroy), e.fragment && e.fragment.d(n), (e.on_destroy = e.fragment = null), (e.ctx = []));
}
function I(t, n) {
-1 === t.$$.dirty[0] && (b.push(t), z || ((z = !0), k.then(F)), t.$$.dirty.fill(0)), (t.$$.dirty[(n / 31) | 0] |= 1 << n % 31);
}
function N(n, o, i, c, s, a, u = [-1]) {
const l = g;
v(n);
const f = o.props || {},
$ = (n.$$ = {
fragment: null,
ctx: null,
props: a,
update: t,
not_equal: s,
bound: e(),
on_mount: [],
on_destroy: [],
before_update: [],
after_update: [],
context: new Map(l ? l.$$.context : []),
callbacks: e(),
dirty: u,
skip_bound: !1,
});
let h = !1;
if (
(($.ctx = i
? i(n, f, (t, e, ...r) => {
const o = r.length ? r[0] : e;
return $.ctx && s($.ctx[t], ($.ctx[t] = o)) && (!$.skip_bound && $.bound[t] && $.bound[t](o), h && I(n, t)), e;
})
: []),
$.update(),
(h = !0),
r($.before_update),
($.fragment = !!c && c($.ctx)),
o.target)
) {
if (o.hydrate) {
const t = (function (t) {
return Array.from(t.childNodes);
})(o.target);
$.fragment && $.fragment.l(t), t.forEach(d);
} else $.fragment && $.fragment.c();
o.intro && O(n.$$.fragment), T(n, o.target, o.anchor), F();
}
v(l);
}
class V {
$destroy() {
C(this, 1), (this.$destroy = t);
}
$on(t, n) {
const e = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
return (
e.push(n),
() => {
const t = e.indexOf(n);
-1 !== t && e.splice(t, 1);
}
);
}
$set(t) {
var n;
this.$$set && ((n = t), 0 !== Object.keys(n).length) && ((this.$$.skip_bound = !0), this.$$set(t), (this.$$.skip_bound = !1));
}
}
const X = [];
function Y(n, e = t) {
let r;
const o = [];
function c(t) {
if (i(n, t) && ((n = t), r)) {
const t = !X.length;
for (let t = 0; t < o.length; t += 1) {
const e = o[t];
e[1](), X.push(e, n);
}
if (t) {
for (let t = 0; t < X.length; t += 2) X[t][0](X[t + 1]);
X.length = 0;
}
}
}
return {
set: c,
update: function (t) {
c(t(n));
},
subscribe: function (i, s = t) {
const a = [i, s];
return (
o.push(a),
1 === o.length && (r = e(c) || t),
i(n),
() => {
const t = o.indexOf(a);
-1 !== t && o.splice(t, 1), 0 === o.length && (r(), (r = null));
}
);
},
};
}
function W(n, e, i) {
const s = !Array.isArray(n),
a = s ? [n] : n,
u = e.length < 2;
return {
subscribe: Y(i, (n) => {
let i = !1;
const l = [];
let f = 0,
d = t;
const $ = () => {
if (f) return;
d();
const r = e(s ? l[0] : l, n);
u ? n(r) : (d = o(r) ? r : t);
},
h = a.map((t, n) =>
c(
t,
(t) => {
(l[n] = t), (f &= ~(1 << n)), i && $();
},
() => {
f |= 1 << n;
}
)
);
return (
(i = !0),
$(),
function () {
r(h), d();
}
);
}).subscribe,
};
}
const B = Y(window.innerWidth),
H = Y(window.innerHeight),
D = Y(window.devicePixelRatio),
U = Y(),
G = Y(),
J = Y(0),
K = (function (t) {
const n = Object.keys(t);
return W(
n.map((n) => t[n]),
(t) => t.reduce((t, e, r) => ((t[n[r]] = e), t), {})
);
})({ context: U, canvas: G, width: B, height: H, pixelRatio: D, time: J }),
Q = Symbol(),
Z = (t) => {
const n = (function (t) {
return x().$$.context.get(t);
})(Q),
e = { ready: !1, mounted: !1 };
"function" == typeof t ? (e.render = t) : t && (t.render && (e.render = t.render), t.setup && (e.setup = t.setup)),
n.add(e),
y(
() => (
(e.mounted = !0),
() => {
n.remove(e), (e.mounted = !1);
}
)
);
};
const { window: tt } = j;
function nt(t) {
let n, e, r, o, i, c, s;
const u = t[8].default,
g = a(u, t, t[7], null);
return {
c() {
var i;
(i = "canvas"),
(n = document.createElement(i)),
(o = $()),
g && g.c(),
p(n, "width", (e = t[2] * t[1])),
p(n, "height", (r = t[3] * t[1])),
m(n, "width", t[2] + "px"),
m(n, "height", t[3] + "px");
},
m(e, r) {
f(e, n, r), t[9](n), f(e, o, r), g && g.m(e, r), (i = !0), c || ((s = h(tt, "resize", t[4], { passive: !0 })), (c = !0));
},
p(t, [o]) {
(!i || (6 & o && e !== (e = t[2] * t[1]))) && p(n, "width", e),
(!i || (10 & o && r !== (r = t[3] * t[1]))) && p(n, "height", r),
(!i || 4 & o) && m(n, "width", t[2] + "px"),
(!i || 8 & o) && m(n, "height", t[3] + "px"),
g && g.p && 128 & o && l(g, u, t, t[7], o, null, null);
},
i(t) {
i || (O(g, t), (i = !0));
},
o(t) {
L(g, t), (i = !1);
},
d(e) {
e && d(n), t[9](null), e && d(o), g && g.d(e), (c = !1), s();
},
};
}
function et(t, n, e) {
let r, o, i, c;
s(t, K, (t) => e(12, (r = t))), s(t, D, (t) => e(1, (o = t))), s(t, B, (t) => e(2, (i = t))), s(t, H, (t) => e(3, (c = t)));
let a,
u,
l,
{ $$slots: f = {}, $$scope: d } = n,
{ killLoopOnError: $ = !0 } = n,
{ attributes: h = {} } = n,
p = [];
return (
y(
() => (
(u = a.getContext("2d", h)),
G.set(a),
U.set(u),
p.forEach(async (t) => {
if (t.setup) {
let n = t.setup(r);
n && n.then && (await n);
}
t.ready = !0;
}),
(function (t) {
let n = 0,
e = performance.now();
return (
(function r() {
l = requestAnimationFrame(r);
const o = performance.now(),
i = (o - e) / 1e3;
(e = o), (n += i), t(n, i);
})(),
() => {
cancelAnimationFrame(l);
}
);
})((t, n) => {
J.set(t),
(function (t) {
u.save(),
u.scale(o, o),
p.forEach((n) => {
try {
n.mounted && n.ready && n.render && n.render(r, t);
} catch (t) {
console.error(t), $ && (cancelAnimationFrame(l), console.warn("Animation loop stopped due to an error"));
}
}),
u.restore();
})(n);
})
)
),
(function (t, n) {
x().$$.context.set(t, n);
})(Q, {
add(t) {
this.remove(t), p.push(t);
},
remove(t) {
const n = p.indexOf(t);
n >= 0 && p.splice(n, 1);
},
}),
(t.$$set = (t) => {
"killLoopOnError" in t && e(5, ($ = t.killLoopOnError)),
"attributes" in t && e(6, (h = t.attributes)),
"$$scope" in t && e(7, (d = t.$$scope));
}),
[
a,
o,
i,
c,
function () {
B.set(window.innerWidth), H.set(window.innerHeight), D.set(window.devicePixelRatio);
},
$,
h,
d,
f,
function (t) {
w[t ? "unshift" : "push"](() => {
(a = t), e(0, a);
});
},
]
);
}
class rt extends V {
constructor(t) {
super(), N(this, t, et, nt, i, { killLoopOnError: 5, attributes: 6 });
}
}
function ot(t) {
let n;
const e = t[2].default,
r = a(e, t, t[1], null);
return {
c() {
r && r.c();
},
m(t, e) {
r && r.m(t, e), (n = !0);
},
p(t, [n]) {
r && r.p && 2 & n && l(r, e, t, t[1], n, null, null);
},
i(t) {
n || (O(r, t), (n = !0));
},
o(t) {
L(r, t), (n = !1);
},
d(t) {
r && r.d(t);
},
};
}
function it(t, n, e) {
let { $$slots: r = {}, $$scope: o } = n,
{ color: i = null } = n;
return (
Z((t) => {
const { context: n, width: e, height: r } = t;
n.clearRect(0, 0, e, r), i && ((n.fillStyle = i), n.fillRect(0, 0, e, r));
}),
(t.$$set = (t) => {
"color" in t && e(0, (i = t.color)), "$$scope" in t && e(1, (o = t.$$scope));
}),
[i, o, r]
);
}
class ct extends V {
constructor(t) {
super(), N(this, t, it, ot, i, { color: 0 });
}
}
function st(t) {
let n;
const e = t[4].default,
r = a(e, t, t[3], null);
return {
c() {
r && r.c();
},
m(t, e) {
r && r.m(t, e), (n = !0);
},
p(t, [n]) {
r && r.p && 8 & n && l(r, e, t, t[3], n, null, null);
},
i(t) {
n || (O(r, t), (n = !0));
},
o(t) {
L(r, t), (n = !1);
},
d(t) {
r && r.d(t);
},
};
}
function at(t, n, e) {
let { $$slots: r = {}, $$scope: o } = n,
{ color: i = "black" } = n,
{ divisions: c = 20 } = n,
{ pointSize: s = 1 } = n;
return (
Z((t) => {
const { context: n, width: e, height: r } = t,
o = e / r;
n.save();
for (let t = 0; t < c; t++) {
n.beginPath();
for (let i = 0; i < c; i++) {
const a = c <= 1 ? 0.5 : i / (c - 1),
u = c <= 1 ? 0.5 : t / (c - 1);
let l, f;
e > r ? ((l = a * e), (f = u * o * r)) : ((l = (a / o) * e), (f = u * r)), n.arc(l, f, s, 0, 2 * Math.PI);
}
(n.fillStyle = i), n.fill();
}
n.restore();
}),
(t.$$set = (t) => {
"color" in t && e(0, (i = t.color)),
"divisions" in t && e(1, (c = t.divisions)),
"pointSize" in t && e(2, (s = t.pointSize)),
"$$scope" in t && e(3, (o = t.$$scope));
}),
[i, c, s, o, r]
);
}
class ut extends V {
constructor(t) {
super(), N(this, t, at, st, i, { color: 0, divisions: 1, pointSize: 2 });
}
}
function lt(t) {
let n;
const e = t[9].default,
r = a(e, t, t[8], null);
return {
c() {
r && r.c();
},
m(t, e) {
r && r.m(t, e), (n = !0);
},
p(t, [n]) {
r && r.p && 256 & n && l(r, e, t, t[8], n, null, null);
},
i(t) {
n || (O(r, t), (n = !0));
},
o(t) {
L(r, t), (n = !1);
},
d(t) {
r && r.d(t);
},
};
}
function ft(t, n, e) {
let { $$slots: r = {}, $$scope: o } = n,
{ color: i = "hsl(0, 0%, 100%)" } = n,
{ align: c = "center" } = n,
{ baseline: s = "middle" } = n,
{ text: a = "" } = n,
{ x: u = 0 } = n,
{ y: l = 0 } = n,
{ fontSize: f = 16 } = n,
{ fontFamily: d = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica' } = n;
return (
Z((t) => {
const { context: n, width: e, height: r } = t;
a && ((n.fillStyle = i), (n.font = `${f}px ${d}`), (n.textAlign = c), (n.textBaseline = s), n.fillText(a, u, l));
}),
(t.$$set = (t) => {
"color" in t && e(0, (i = t.color)),
"align" in t && e(1, (c = t.align)),
"baseline" in t && e(2, (s = t.baseline)),
"text" in t && e(3, (a = t.text)),
"x" in t && e(4, (u = t.x)),
"y" in t && e(5, (l = t.y)),
"fontSize" in t && e(6, (f = t.fontSize)),
"fontFamily" in t && e(7, (d = t.fontFamily)),
"$$scope" in t && e(8, (o = t.$$scope));
}),
[i, c, s, a, u, l, f, d, o, r]
);
}
class dt extends V {
constructor(t) {
super(), N(this, t, ft, lt, i, { color: 0, align: 1, baseline: 2, text: 3, x: 4, y: 5, fontSize: 6, fontFamily: 7 });
}
}
var $t = 1e-6,
ht = function () {
var t = new Float32Array(2);
return (t[0] = 0), (t[1] = 0), t;
};
var pt = function (t) {
var n = new Float32Array(2);
return (n[0] = t[0]), (n[1] = t[1]), n;
};
var mt = function (t, n) {
var e = new Float32Array(2);
return (e[0] = t), (e[1] = n), e;
};
var gt = function (t, n) {
return (t[0] = n[0]), (t[1] = n[1]), t;
};
var vt = function (t, n, e) {
return (t[0] = n), (t[1] = e), t;
};
var xt = function (t, n) {
var e = t[0],
r = t[1],
o = n[0],
i = n[1];
return Math.abs(e - o) <= $t * Math.max(1, Math.abs(e), Math.abs(o)) && Math.abs(r - i) <= $t * Math.max(1, Math.abs(r), Math.abs(i));
};
var yt = function (t, n) {
return t[0] === n[0] && t[1] === n[1];
};
var bt = function (t, n, e) {
return (t[0] = n[0] + e[0]), (t[1] = n[1] + e[1]), t;
};
var wt = function (t, n, e) {
return (t[0] = n[0] - e[0]), (t[1] = n[1] - e[1]), t;
};
var Mt = wt,
St = function (t, n, e) {
return (t[0] = n[0] * e[0]), (t[1] = n[1] * e[1]), t;
};
var kt = St,
zt = function (t, n, e) {
return (t[0] = n[0] / e[0]), (t[1] = n[1] / e[1]), t;
};
var At = zt,
_t = function (t, n) {
return (t[0] = 1 / n[0]), (t[1] = 1 / n[1]), t;
};
var Et = function (t, n, e) {
return (t[0] = Math.min(n[0], e[0])), (t[1] = Math.min(n[1], e[1])), t;
};
var Ft = function (t, n, e) {
return (t[0] = Math.max(n[0], e[0])), (t[1] = Math.max(n[1], e[1])), t;
};
var qt = function (t, n, e) {
var r = Math.cos(e),
o = Math.sin(e),
i = n[0],
c = n[1];
return (t[0] = i * r - c * o), (t[1] = i * o + c * r), t;
};
var Pt = function (t, n) {
return (t[0] = Math.floor(n[0])), (t[1] = Math.floor(n[1])), t;
};
var Ot = function (t, n) {
return (t[0] = Math.ceil(n[0])), (t[1] = Math.ceil(n[1])), t;
};
var Lt = function (t, n) {
return (t[0] = Math.round(n[0])), (t[1] = Math.round(n[1])), t;
};
var jt = function (t, n, e) {
return (t[0] = n[0] * e), (t[1] = n[1] * e), t;
};
var Rt = function (t, n, e, r) {
return (t[0] = n[0] + e[0] * r), (t[1] = n[1] + e[1] * r), t;
};
var Tt = function (t, n) {
var e = n[0] - t[0],
r = n[1] - t[1];
return Math.sqrt(e * e + r * r);
};
var Ct = Tt,
It = function (t, n) {
var e = n[0] - t[0],
r = n[1] - t[1];
return e * e + r * r;
};
var Nt = It,
Vt = function (t) {
var n = t[0],
e = t[1];
return Math.sqrt(n * n + e * e);
};
var Xt = Vt,
Yt = function (t) {
var n = t[0],
e = t[1];
return n * n + e * e;
};
var Wt = Yt,
Bt = function (t, n) {
return (t[0] = -n[0]), (t[1] = -n[1]), t;
};
var Ht = function (t, n) {
var e = n[0],
r = n[1],
o = e * e + r * r;
o > 0 && ((o = 1 / Math.sqrt(o)), (t[0] = n[0] * o), (t[1] = n[1] * o));
return t;
};
var Dt = function (t, n) {
return t[0] * n[0] + t[1] * n[1];
};
var Ut = function (t, n, e) {
var r = n[0] * e[1] - n[1] * e[0];
return (t[0] = t[1] = 0), (t[2] = r), t;
};
var Gt = function (t, n, e, r) {
var o = n[0],
i = n[1];
return (t[0] = o + r * (e[0] - o)), (t[1] = i + r * (e[1] - i)), t;
};
var Jt = function (t, n) {
n = n || 1;
var e = 2 * Math.random() * Math.PI;
return (t[0] = Math.cos(e) * n), (t[1] = Math.sin(e) * n), t;
};
var Kt = function (t, n, e) {
var r = n[0],
o = n[1];
return (t[0] = e[0] * r + e[2] * o), (t[1] = e[1] * r + e[3] * o), t;
};
var Qt = function (t, n, e) {
var r = n[0],
o = n[1];
return (t[0] = e[0] * r + e[2] * o + e[4]), (t[1] = e[1] * r + e[3] * o + e[5]), t;
};
var Zt = function (t, n, e) {
var r = n[0],
o = n[1];
return (t[0] = e[0] * r + e[3] * o + e[6]), (t[1] = e[1] * r + e[4] * o + e[7]), t;
};
var tn = function (t, n, e) {
var r = n[0],
o = n[1];
return (t[0] = e[0] * r + e[4] * o + e[12]), (t[1] = e[1] * r + e[5] * o + e[13]), t;
};
var nn = function (t, n, e, r, o, i) {
var c, s;
n || (n = 2);
e || (e = 0);
s = r ? Math.min(r * n + e, t.length) : t.length;
for (c = e; c < s; c += n) (en[0] = t[c]), (en[1] = t[c + 1]), o(en, en, i), (t[c] = en[0]), (t[c + 1] = en[1]);
return t;
},
en = ht();
var rn = {
EPSILON: $t,
create: ht,
clone: pt,
fromValues: mt,
copy: gt,
set: vt,
equals: xt,
exactEquals: yt,
add: bt,
subtract: wt,
sub: Mt,
multiply: St,
mul: kt,
divide: zt,
div: At,
inverse: _t,
min: Et,
max: Ft,
rotate: qt,
floor: Pt,
ceil: Ot,
round: Lt,
scale: jt,
scaleAndAdd: Rt,
distance: Tt,
dist: Ct,
squaredDistance: It,
sqrDist: Nt,
length: Vt,
len: Xt,
squaredLength: Yt,
sqrLen: Wt,
negate: Bt,
normalize: Ht,
dot: Dt,
cross: Ut,
lerp: Gt,
random: Jt,
transformMat2: Kt,
transformMat2d: Qt,
transformMat3: Zt,
transformMat4: tn,
forEach: nn,
limit: function (t, n, e) {
var r = n[0] * n[0] + n[1] * n[1];
if (r > e * e) {
var o = Math.sqrt(r);
(t[0] = (n[0] / o) * e), (t[1] = (n[1] / o) * e);
} else (t[0] = n[0]), (t[1] = n[1]);
return t;
},
};
function on(t) {
let n, e, o, i, c;
(n = new dt({ props: { fontSize: 8, baseline: "top" } })), t[13](n);
const s = t[12].default,
u = a(s, t, t[11], null);
return {
c() {
R(n.$$.fragment), (e = $()), u && u.c();
},
m(r, s) {
T(n, r, s),
f(r, e, s),
u && u.m(r, s),
(o = !0),
i || ((c = [h(window, "mousedown", t[2]), h(window, "mouseup", t[3]), h(window, "mousemove", t[1])]), (i = !0));
},
p(t, [e]) {
n.$set({}), u && u.p && 2048 & e && l(u, s, t, t[11], e, null, null);
},
i(t) {
o || (O(n.$$.fragment, t), O(u, t), (o = !0));
},
o(t) {
L(n.$$.fragment, t), L(u, t), (o = !1);
},
d(o) {
t[13](null), C(n, o), o && d(e), u && u.d(o), (i = !1), r(c);
},
};
}
function cn(t, n, e) {
let r, o;
s(t, B, (t) => e(19, (r = t))), s(t, H, (t) => e(20, (o = t)));
let i,
{ $$slots: c = {}, $$scope: a } = n,
{ color: u = "#ffe554" } = n,
{ size: l = 10 } = n,
{ thickness: f = 3 } = n,
{ startX: d = r / 2 } = n,
{ startY: $ = o / 2 } = n,
{ moveSpeed: h = 0.2 } = n,
{ maxVelocity: p = 5 } = n,
m = d,
g = $;
const v = [0, 0];
let x = null,
y = !1;
function b({ clientX: t, clientY: n }) {
x = [t, n];
}
return (
Z((t, n) => {
const { context: e, width: r, height: o } = t;
let c = [m, g];
if (y) {
const t = rn.sub([], x, c);
rn.length(t) > 2 * l && (rn.normalize(t, t), rn.scaleAndAdd(v, v, t, h));
}
if (
((m < 0 || m > r) && ((m = Math.max(0, Math.min(r, m))), (v[0] *= -1)),
(g < 0 || g > o) && ((g = Math.max(0, Math.min(o, g))), (v[1] *= -1)),
(v[0] = Math.max(-p, Math.min(p, v[0]))),
(v[1] = Math.max(-p, Math.min(p, v[1]))),
(v[0] *= 0.98),
(v[1] *= 0.98),
(m += v[0]),
(g += v[1]),
(c[0] = m),
(c[1] = g),
(e.lineCap = "round"),
e.beginPath(),
(e.fillStyle = u),
(e.strokeStyle = u),
(e.lineWidth = f),
e.arc(m, g, l, 0, 2 * Math.PI),
e.stroke(),
rn.squaredLength(v) > 0)
) {
const t = rn.normalize([], v);
(e.lineWidth = f),
(function (t, n, e, r) {
const o = rn.scaleAndAdd([], n, e, r);
t.beginPath(), t.moveTo(n[0], n[1]), t.lineTo(o[0], o[1]), t.stroke();
})(e, c, t, l);
}
i.$set({ text: `(${c.map((t) => Math.round(t)).join(", ")})`, x: m, y: g + l + 10 });
}),
(t.$$set = (t) => {
"color" in t && e(4, (u = t.color)),
"size" in t && e(5, (l = t.size)),
"thickness" in t && e(6, (f = t.thickness)),
"startX" in t && e(7, (d = t.startX)),
"startY" in t && e(8, ($ = t.startY)),
"moveSpeed" in t && e(9, (h = t.moveSpeed)),
"maxVelocity" in t && e(10, (p = t.maxVelocity)),
"$$scope" in t && e(11, (a = t.$$scope));
}),
[
i,
b,
function (t) {
b(t), (y = !0);
},
function (t) {
b(t), (y = !1);
},
u,
l,
f,
d,
$,
h,
p,
a,
c,
function (t) {
w[t ? "unshift" : "push"](() => {
(i = t), e(0, i);
});
},
]
);
}
class sn extends V {
constructor(t) {
super(), N(this, t, cn, on, i, { color: 4, size: 5, thickness: 6, startX: 7, startY: 8, moveSpeed: 9, maxVelocity: 10 });
}
}
function an(t) {
let n, e, r;
n = new dt({ props: { text: t[0], fontSize: "12", fontFamily: "Courier New", align: "left", baseline: "top", x: 20, y: 20 } });
const o = t[2].default,
i = a(o, t, t[1], null);
return {
c() {
R(n.$$.fragment), (e = $()), i && i.c();
},
m(t, o) {
T(n, t, o), f(t, e, o), i && i.m(t, o), (r = !0);
},
p(t, [e]) {
const r = {};
1 & e && (r.text = t[0]), n.$set(r), i && i.p && 2 & e && l(i, o, t, t[1], e, null, null);
},
i(t) {
r || (O(n.$$.fragment, t), O(i, t), (r = !0));
},
o(t) {
L(n.$$.fragment, t), L(i, t), (r = !1);
},
d(t) {
C(n, t), t && d(e), i && i.d(t);
},
};
}
function un(t, n, e) {
let { $$slots: r = {}, $$scope: o } = n,
i = "",
c = 0,
s = performance.now();
return (
Z((t, n) => {
let r = performance.now();
if ((c++, r >= s + 1e3)) {
e(0, (i = `${((1e3 * c) / (r - s)).toFixed(1)} FPS`)), (s = r), (c = 0);
}
}),
(t.$$set = (t) => {
"$$scope" in t && e(1, (o = t.$$scope));
}),
[i, o, r]
);
}
class ln extends V {
constructor(t) {
super(), N(this, t, un, an, i, {});
}
}
function fn(n) {
let e, r;
return (
(e = new ut({ props: { divisions: 30, color: "hsla(0, 0%, 100%, 0.5)" } })),
{
c() {
R(e.$$.fragment);
},
m(t, n) {
T(e, t, n), (r = !0);
},
p: t,
i(t) {
r || (O(e.$$.fragment, t), (r = !0));
},
o(t) {
L(e.$$.fragment, t), (r = !1);
},
d(t) {
C(e, t);
},
}
);
}
function dn(t) {
let n, e, r, o, i, c, s, a;
return (
(n = new ct({ props: { color: "hsl(0, 0%, 10%)", $$slots: { default: [fn] }, $$scope: { ctx: t } } })),
(r = new sn({ props: { size: 10 } })),
(i = new dt({
props: {
text: "Click and drag around the page to move the character.",
fontSize: 12,
align: "right",
baseline: "bottom",
x: t[0] - 20,
y: t[1] - 20,
},
})),
(s = new ln({})),
{
c() {
R(n.$$.fragment), (e = $()), R(r.$$.fragment), (o = $()), R(i.$$.fragment), (c = $()), R(s.$$.fragment);
},
m(t, u) {
T(n, t, u), f(t, e, u), T(r, t, u), f(t, o, u), T(i, t, u), f(t, c, u), T(s, t, u), (a = !0);
},
p(t, e) {
const r = {};
4 & e && (r.$$scope = { dirty: e, ctx: t }), n.$set(r);
const o = {};
1 & e && (o.x = t[0] - 20), 2 & e && (o.y = t[1] - 20), i.$set(o);
},
i(t) {
a || (O(n.$$.fragment, t), O(r.$$.fragment, t), O(i.$$.fragment, t), O(s.$$.fragment, t), (a = !0));
},
o(t) {
L(n.$$.fragment, t), L(r.$$.fragment, t), L(i.$$.fragment, t), L(s.$$.fragment, t), (a = !1);
},
d(t) {
C(n, t), t && d(e), C(r, t), t && d(o), C(i, t), t && d(c), C(s, t);
},
}
);
}
function $n(t) {
let n, e;
return (
(n = new rt({ props: { $$slots: { default: [dn] }, $$scope: { ctx: t } } })),
{
c() {
R(n.$$.fragment);
},
m(t, r) {
T(n, t, r), (e = !0);
},
p(t, [e]) {
const r = {};
7 & e && (r.$$scope = { dirty: e, ctx: t }), n.$set(r);
},
i(t) {
e || (O(n.$$.fragment, t), (e = !0));
},
o(t) {
L(n.$$.fragment, t), (e = !1);
},
d(t) {
C(n, t);
},
}
);
}
function hn(t, n, e) {
let r, o;
return s(t, B, (t) => e(0, (r = t))), s(t, H, (t) => e(1, (o = t))), [r, o];
}
return new (class extends V {
constructor(t) {
super(), N(this, t, hn, $n, i, {});
}
})({ target: document.body });
})();
//# sourceMappingURL=bundle.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment