(function (global) { const WORD = {"from":"Guoliang","to":"Lucio","letters":[{"ch":"G","kind":"keep","shared":"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50","fullA":"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00","fullB":"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50","out":[{"d":"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00","P":79.21,"j":"end"},{"d":"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00","P":73.21,"j":"start"}],"in":[{"d":"M8.50 22.00L8.50 0.00","P":22.0,"j":"start"},{"d":"M58.00 91.50L80.00 91.50","P":22.0,"j":"start"}],"x0":0.0,"x1":0.0,"dot":null},{"ch":"u","kind":"keep","shared":"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00","fullA":"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00","fullB":"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00","out":[],"in":[],"x0":88.8,"x1":88.0,"dot":null},{"ch":"o","kind":"keep","shared":"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","fullA":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","fullB":"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50","out":[{"d":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50","P":60.41,"j":"both"}],"in":[{"d":"M38.00 46.50L60.00 46.50","P":22.0,"j":"start"},{"d":"M38.00 91.50L60.00 91.50","P":22.0,"j":"start"}],"x0":159.0,"x1":158.2,"dot":null},{"ch":"l","kind":"fade","d":"M8.50 0.00L8.50 100.00","x0":230.8,"x1":230.8,"dot":null},{"ch":"i","kind":"keep","shared":"M8.50 38.00L8.50 100.00","fullA":"M8.50 38.00L8.50 100.00","fullB":"M8.50 38.00L8.50 100.00","out":[],"in":[],"x0":262.8,"x1":227.9,"dot":[0,14,17]},{"ch":"a","kind":"fade","d":"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","x0":291.6,"x1":291.6,"dot":null},{"ch":"n","kind":"fade","d":"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00","x0":362.7,"x1":362.7,"dot":null},{"ch":"g","kind":"keep","shared":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","fullA":"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00","fullB":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","out":[{"d":"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50","P":113.21,"j":"start"}],"in":[],"x0":432.9,"x1":256.7,"dot":null}],"pad":17,"vbw":526.9,"vbh":170,"stroke":17,"raysT":"translate(0.000 22.727) scale(0.7727)"}; const RAYS = "M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z"; const NS = "http://www.w3.org/2000/svg"; const el = (n, a) => { const e = document.createElementNS(NS, n); for (const k in a) e.setAttribute(k, a[k]); return e; }; const reduced = () => global.matchMedia && global.matchMedia("(prefers-reduced-motion: reduce)").matches; const clamp01 = v => Math.max(0, Math.min(1, v)); const smooth = t => t * t * (3 - 2 * t); const SPLIT = 0.5; function engine(render, duration) { let t = 0, target = 0, raf = null, last = 0; function tick(now) { const step = (now - last) / duration; last = now; t = t < target ? Math.min(target, t + step) : Math.max(target, t - step); render(t); raf = t === target ? null : requestAnimationFrame(tick); } function go(v) { target = v; if (reduced()) { t = v; render(t); return; } if (raf === null) { last = performance.now(); raf = requestAnimationFrame(tick); } } return { play: () => go(1), reverse: () => go(0), toggle: () => go(target ? 0 : 1), set: v => { cancelAnimationFrame(raf); raf = null; target = t = v; render(t); }, stop: () => { cancelAnimationFrame(raf); raf = null; }, get t() { return t; } }; } function setDash(path, P, j, frac) { const v = clamp01(frac) * P; path.style.visibility = v < 0.05 ? "hidden" : "visible"; if (j === "both") { const h = v / 2; path.setAttribute("stroke-dasharray", h.toFixed(2) + " " + Math.max(0, P - 2*h).toFixed(2) + " " + h.toFixed(2)); path.setAttribute("stroke-dashoffset", "0"); } else if (j === "end") { path.setAttribute("stroke-dasharray", v.toFixed(2) + " " + (2*P+20).toFixed(2)); path.setAttribute("stroke-dashoffset", (-(P - v)).toFixed(2)); } else { path.setAttribute("stroke-dasharray", v.toFixed(2) + " " + (2*P+20).toFixed(2)); path.setAttribute("stroke-dashoffset", "0"); } } function wordmark(container, opts = {}) { const o = Object.assign({ trigger: "hover", color: "currentColor", rays: "#FFF3CF", duration: 450, autoDelay: 1800 }, opts); const svg = el("svg", { viewBox: "0 0 " + WORD.vbw + " " + WORD.vbh, role: "img", "aria-label": "Guoliang Chen, Lucio" }); svg.style.display = "block"; svg.style.width = "100%"; svg.style.height = "auto"; const root = el("g", { transform: "translate(" + WORD.pad + " " + WORD.pad + ")", fill: "none", stroke: o.color, "stroke-width": WORD.stroke, "stroke-linejoin": "miter", "stroke-linecap": "butt" }); svg.appendChild(root); const letters = WORD.letters.map(L => { const g = el("g", { transform: "translate(" + L.x0 + " 0)" }); root.appendChild(g); const R = Object.assign({ g, outEls: [], inEls: [] }, L); if (L.kind === "fade") { R.fadeEl = el("path", { d: L.d }); g.appendChild(R.fadeEl); } else { R.fullA = el("path", { d: L.fullA }); g.appendChild(R.fullA); R.fullB = el("path", { d: L.fullB }); g.appendChild(R.fullB); if (L.shared) g.appendChild(el("path", { d: L.shared })); for (const c of L.out) { const p = el("path", { d: c.d }); g.appendChild(p); R.outEls.push([p, c]); } for (const c of L.in) { const p = el("path", { d: c.d }); g.appendChild(p); R.inEls.push([p, c]); } } if (L.dot) { R.dotEl = el("rect", { x: L.dot[0], y: L.dot[1], width: L.dot[2], height: L.dot[2], rx: L.dot[2] * 0.22, fill: o.color, stroke: "none" }); g.appendChild(R.dotEl); } return R; }); const rays = el("path", { d: RAYS, fill: o.rays, stroke: "none", opacity: 0 }); root.appendChild(rays); container.appendChild(svg); function render(t) { const tA = smooth(clamp01(t / SPLIT)), tB = smooth(clamp01((t - SPLIT) / (1 - SPLIT))); for (const L of letters) { if (L.kind === "fade") { L.fadeEl.setAttribute("opacity", (1 - tA).toFixed(3)); if (L.dotEl) L.dotEl.setAttribute("opacity", (1 - tA).toFixed(3)); } else { for (const [p, c] of L.outEls) setDash(p, c.P, c.j, 1 - tA); for (const [p, c] of L.inEls) setDash(p, c.P, c.j, tA); L.fullA.style.visibility = tA <= 0.001 ? "visible" : "hidden"; L.fullB.style.visibility = tA >= 0.999 ? "visible" : "hidden"; } L.g.setAttribute("transform", "translate(" + (L.x0 + (L.x1 - L.x0) * tB).toFixed(2) + " 0)"); } rays.setAttribute("transform", "translate(" + (letters[0].x0 + (letters[0].x1 - letters[0].x0) * tB).toFixed(2) + " 0) " + WORD.raysT); rays.setAttribute("opacity", clamp01((t - 0.8) / 0.2).toFixed(3)); } const a = engine(render, o.duration); render(0); if (o.trigger === "hover") { container.addEventListener("mouseenter", a.play); container.addEventListener("mouseleave", a.reverse); container.addEventListener("focus", a.play); container.addEventListener("blur", a.reverse); } if (o.trigger === "click") container.addEventListener("click", a.toggle); if (o.trigger === "auto") setInterval(a.toggle, o.autoDelay + o.duration); return Object.assign(a, { svg }); } const LET = { C: [0, .75], L: [.25, .75], U: [.25, 1], I: [.75, 1], O: [.75, 1.75] }; function frame(S, w, r) { const m = w / 2, R = r - m, c = m + R, k = R * Math.SQRT1_2, f = v => v.toFixed(3); const d = "M" + f(S-c+k) + " " + f(c-k) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(S-c) + " " + f(m) + "H" + f(c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(m) + " " + f(c) + "V" + f(S-c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(c) + " " + f(S-m) + "H" + f(S-c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(S-m) + " " + f(S-c) + "V" + f(c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(S-c+k) + " " + f(c-k) + "Z"; return { d, P: 4 * (S - 2 * c) + 2 * Math.PI * R }; } function loader(container, opts = {}) { const o = Object.assign({ sequence: "LUCIO", color: "#F3F1EC", track: "#26262D", rays: "#FFF3CF", hold: 480, morph: 640, size: 96, stroke: 0.17, radius: 0.22 }, opts); const S = 120, w = S * o.stroke, r = S * o.radius, F = frame(S, w, r); const svg = el("svg", { viewBox: "0 0 " + S + " " + S, width: o.size, height: o.size, role: "img", "aria-label": "Loading" }); if (o.track) svg.appendChild(el("path", { d: F.d, fill: "none", stroke: o.track, "stroke-width": w })); const path = el("path", { d: F.d, fill: "none", stroke: o.color, "stroke-width": w, "stroke-linecap": "butt" }); const k = w / 22, rays = el("path", { d: RAYS, fill: o.rays, transform: "translate(" + (w - 22*k).toFixed(3) + " " + (S - w - 78*k).toFixed(3) + ") scale(" + k.toFixed(4) + ")", opacity: 0 }); svg.appendChild(path); svg.appendChild(rays); const seg = (s, e) => { const len = Math.min(1, Math.max(0, e - s)) * F.P; path.setAttribute("stroke-dasharray", len.toFixed(3) + " " + Math.max(0, F.P - len).toFixed(3)); path.setAttribute("stroke-dashoffset", (-s * F.P).toFixed(3)); }; const target = (cur, ch) => { const [s2, e2] = LET[ch]; for (let q = -1; q < 6; q++) { if (s2 + q >= cur[0] - 1e-6 && e2 + q >= cur[1] - 1e-6) return [s2 + q, e2 + q]; } return [s2, e2]; }; const seq = o.sequence.split(""); let i = 0, cur = LET[seq[0]].slice(), raf, timer, stopped = false; seg(cur[0], cur[1]); rays.setAttribute("opacity", seq[0] === "L" ? 1 : 0); function next() { if (stopped) return; const j = (i + 1) % seq.length, to = target(cur, seq[j]), from = cur.slice(), wasL = seq[i] === "L", isL = seq[j] === "L"; const finish = () => { cur = to; const n = Math.floor(cur[0]); cur[0] -= n; cur[1] -= n; i = j; seg(cur[0], cur[1]); rays.setAttribute("opacity", isL ? 1 : 0); timer = setTimeout(next, o.hold); }; if (reduced()) { finish(); return; } const start = performance.now(); const step = now => { const t = Math.min(1, (now - start) / o.morph), u = t < 0.5 ? 4*t*t*t : 1 - Math.pow(-2*t + 2, 3) / 2; seg(from[0] + (to[0]-from[0])*u, from[1] + (to[1]-from[1])*u); rays.setAttribute("opacity", isL ? Math.max(0, (t - .6) / .4).toFixed(3) : wasL ? Math.max(0, 1 - t * 2.5).toFixed(3) : 0); if (t < 1) raf = requestAnimationFrame(step); else finish(); }; raf = requestAnimationFrame(step); } timer = setTimeout(next, o.hold); container.appendChild(svg); return { svg, stop: () => { stopped = true; cancelAnimationFrame(raf); clearTimeout(timer); } }; } global.LucioMorph = { wordmark, loader }; })(window);