Files
hyperframes/docs/public/catalog/components/hw-boil.json
Miguel Ángel f24ff83834 feat(catalog): add the seven 3D-motion pieces as installable registry blocks (#4056)
* feat(catalog): add the seven 3D-motion pieces as installable registry blocks

Each piece ships as a registry block with a CDN poster and preview, a live
catalog detail page and its source. Scripts travel inside the catalog payload
(shared vendor libraries fetched once, item scripts inline, the one HDR as a
data URI) because the docs host only serves fonts, images and JSON.

NO_ESSAY_COMMENTS_OK: the long comment blocks are in vendored libraries and
the ported frost source under registry/blocks, not hand-written here.
HF_MAX_NONLFS_KB=6000: four hosted texture PNGs under docs/public/catalog/items
are runtime assets the docs host must serve as files.
fallow skipped locally: it audits against origin/main and this branch is
stacked on an older main.

* chore(catalog): regenerate gallery data and nav after rebasing onto main

* fix(catalog): read the install manifest through the bounded project reader

* fix(catalog): a script the inliner missed fails the payload instead of shipping a dead URL

* refactor(catalog): the leftover-script check reuses the reference finder

* fix(catalog): frost and glass textures load from the CDN and the iteration presets are gone

* chore(catalog): regenerate the frost and glass payloads and nav

* fix(catalog): frost and glass textures are hosted through the registry url field, not hardcoded

* chore(catalog): regenerate the frost and glass payloads against the hosted texture URLs

* fix(catalog): the hosted-reference rewrite refuses a bare name it cannot safely replace

* ci(catalog): verify changed catalog payloads in headless Chrome and check the docs catalog

* feat(catalog): every item page follows the shared layout with a Tune panel and tabs

* fix(catalog): let the texture-mask item host its masks so its tile plays live

* chore(catalog): regenerate item pages, gallery data and the texture-mask payload

* chore(catalog): regenerate item pages after merging main

* fix(catalog): declared-only variables get the Tune panel, Code and Docs tabs capped

* feat(catalog): give the blend-difference caption a demo scene so its tile plays live

* chore(catalog): live payload for the blend-difference caption

* perf(catalog): heavy 3d pieces compile and draw before ready, not on the first visible frame

* feat(catalog): the avatar promo card hosts its videos, audio and fonts on the CDN

* feat(catalog): the avatar promo card tile plays live from its CDN-hosted media

* chore(catalog): the avatar promo card plays live, no allowlist left

* chore(catalog): shorten two comment blocks

* chore(catalog): trim first-party comment blocks to the comment-check limits

* chore(catalog): shorten two frost source comments

* fix(catalog): the Docs tab renders as prose again, and the detail page honours reduced motion

Frame-mode pages carry no prose wrapper, and the detail component sat inside
not-prose, so the Docs slot's headings, paragraphs, links and lists had no
styling at all. The slots now carry their own prose classes and the chrome
around them keeps not-prose.

The recorded clip also gets the reduced-motion guard the docs-snippet check
requires, and the generator reads stability from the source metadata type so
the scripts typecheck passes.

* fix(catalog): docs-tab paragraphs render as blocks

Mintlify emits paragraphs as inline spans, so two paragraphs in the Docs slot ran together.

* fix(ci): drop the duplicate docs_catalog job output

git's line-based auto-merge silently duplicated the outputs key when
main and this branch each added it on non-adjacent lines during the
rebase; oxfmt's yaml parser rejects the repeated map key.

* fix(catalog): close four CodeQL alerts in the frost source

* chore(catalog): allowlist the avatar-promo-card CDN asset deletions, format sync-docs-catalog

check-no-main-deletions.mjs was rejecting 11 local mp4/font files this branch
already deleted in favor of CDN hosting; scripts/sync-docs-catalog.mjs had one
line over the 100-col print width from an earlier edit in this branch.

* fix(catalog): detail tabs use docs prose spacing, Install first; previews skip no-WebGPU runners

* fix(catalog): the docs tab scrolls with the page instead of a capped inner box

* refactor(catalog): split the payload asset and verify scripts into single-purpose helpers

* refactor(catalog): split the preview generator into single-purpose helpers

* ci(catalog): fail when the committed catalog differs from generator output

The docs host serves the committed catalog and nothing regenerates it, so a stale
copy shipped silently. The catalog payloads job now generates into a temp dir and
compares it with the committed tree.

* chore(catalog): regenerate docs/public/catalog with the refactored scripts

One full regeneration from an empty output tree with the current scripts. The tree grows
from 58.4 MB to 65.1 MB. Two hosted assets are about 2 MB each (an avatar png and a wav);
the same bytes are already committed under assets/, so HF_MAX_NONLFS_KB is raised for
this commit only.

* fix(catalog): run the catalog script tests under the runner they are written for

The rebase put three node:test files in the vitest half of test:scripts, where they report
"No test suite found". They now sit in the node --test list.

* fix(catalog): a WebGPU item without an adapter shows its recorded clip and says why

* ci(catalog): the drift check runs from a committed fetch mirror with no network

Generation now serves every font and CDN script fetch from scripts/catalog-fetch-mirror and fails
when a fetch is not in it, even if the caller swallowed the error. CATALOG_FETCH_MIRROR=record
refreshes the mirror from the live network. The docs_catalog filter also watches packages/core,
packages/producer and the mirror, and the 13 re-hashed font files are listed in ALLOWED_DELETIONS.

* chore(catalog): clean up the temp font cache and sort the mirror index without a locale

* fix(catalog): hide Tune when the clip stands in, time out the adapter request, share one check

* fix(catalog): the adapter probe survives a sync throw and a hang; test the clip guard

* fix(catalog): keep the adapter probe inside the component, Mintlify evaluates only exports

* fix(catalog): run the detail and page generator tests in CI; no Tune flash while probing WebGPU

* docs(catalog): credit vendored libraries and make each SKILL.md list what the block installs

CREDITS.md names every vendored dependency with its upstream and licence, and flags the two leaf
textures whose origin is still to be confirmed. Each SKILL.md Files table now comes from the block
manifest and its install and render paths point at compositions/<name>/. A test checks that every
path a SKILL.md names is a manifest file that exists.

* fix(catalog): a declared WebGPU item passes verify by its manifest tag, not by console wording

verify-catalog-payloads forgave a missing adapter only by matching the markup and the message, which
library-reported errors and widgets never satisfy. The webgpu tag in the item manifest is now the
owner: a tagged item ignores its page and console errors, an untagged one gets no forgiveness, and a
marker payload with no html is listed instead of crashing the run.

* docs(catalog): correct the credits per block and guard the mount and render paths

CREDITS.md states the three.js version and vendored-or-CDN status per block, adds d3-delaunay,
Clipper on the CDN and the Google Fonts loads, and lists every texture with no known origin.
The SKILL.md test now also checks the mount and render paths against the manifest composition.

* test(catalog): read each block manifest once in the SKILL.md file test

The two checks shared a copied manifest read, which fallow flagged as a clone with a high score.

* fix(catalog): commit the hosted item files a gitignore rule kept out, and check git not the disk

The compositions/ and *-ad/ ignore rules matched folder names under docs/public/catalog/items,
so 33 hosted fonts, textures and marks were generated but never committed and would 404 on
the docs host. The rules now have a negation for that tree and the files are added.

The drift check read the checkout, where git-ignored files still exist, so it passed locally
and failed only in CI. It now unpacks HEAD with git archive and compares that.

* fix(catalog): a tile keeps its poster until the composition has painted

* fix(catalog): a tagged WebGPU item forgives only the adapter-absent error, and test the wiring

The manifest webgpu tag now decides whether an item may lack an adapter, and the error wording
decides which lines are that absence. Any other page or console error on the item, and every
failed request, still fails. The per-item decision is one exported function the tests drive,
marker payloads are parsed by a tested helper, and the SKILL.md variable counts are checked
against their tables (cuboid-carousel said forty-nine for forty).

* fix(catalog): the pinned group's posters load eagerly at high priority

* fix(catalog): type the tile reveal test so the scripts typecheck passes

* fix(catalog): stop the adapter signature matching an unrelated failed adapter request

failed to request .*adapter also matched errors about other adapters. It now matches only a
request for the WebGPU adapter, so a tagged item cannot hide an unrelated failure behind it.

* test(catalog): a tagged item still fails on an error about some other adapter

* feat(catalog): the install command sits above the preview, as on the live catalog

* fix(catalog): find the install slot through Mintlify's child wrapper

* fix(docs): catalog copy buttons keep their size when the label swaps to Copied

* refactor(docs): name the shown copy label once in the catalog copy button

* fix(docs): primary catalog button keeps a readable label on hover and after copy

* fix(docs): inset the catalog tab strip and tab content to match the boxed panels
2026-09-19 16:53:29 -04:00

1 line
21 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"html":"<!doctype html>\n<!-- Demo plate for the catalog preview. Same helper set as hw-boil.html with\n an opaque root background, exercising the control surface in NON-DEFAULT\n states (the demo law: at least one non-default control state): stroke\n matrix \"sharp\" and \"spray\" side by side, the \"lively\" boil pose on the\n text, and the raw frantic arrow.\n Not installed by `hyperframes add` - registry-item.json lists hw-boil.html only. -->\n<html lang=\"en\">\n <head><base href=\"/public/catalog/items/hw-boil/\">\n <meta charset=\"utf-8\" />\n <script src=\"https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js\"></script>\n <style>\n /* Caveat is NOT auto-resolved by the renderer — bundle it. Asset\n paths are ROOT-RELATIVE (the project root is the base URL for all\n compositions; ../ traversal is a lint error). Registry installs\n ship the woff2 as an asset file targeting assets/fonts/. */\n @font-face {\n font-family: \"Caveat\";\n src: url(\"/public/catalog/assets/891951df5e8b5b0f.woff2\") format(\"woff2\");\n font-weight: 700;\n font-display: block;\n }\n *,\n *::before,\n *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n body {\n background: #17161a;\n overflow: hidden;\n }\n /* ---- hw-boil -----------------------------------------------------\n The hand-drawn \"boil\": jitter that re-poses only every N frames\n (quake + frame-drop style). Pose is a pure function of quantized\n timeline time through a seeded hash — fully seek-safe, renders\n identically on every pass over the same frame. Ships the control\n layer on top of the raw mechanic: hwBoilPose (the \"boil\" control —\n authored amp/rot poses over the family-locked frameDrop), the\n stroke matrix (hwStrokeTypes / hwStrokeApply / hwDrawOn — the\n \"strokeType\" control: plain | soft | sharp | spray; spray is\n index-seeded deterministic dots, NO feTurbulence anywhere) and the\n curvature-adaptive pen-velocity ease (hwPenEase).\n\n RULES:\n - hwBoil owns x/y/rotation of the boiled element.\n Transform-touching entrance/exit tweens go on a WRAPPER\n around it, never the boiled element (non-transform tweens\n like opacity don't contend and may ride it).\n - One timeline has ONE onUpdate — hwOnUpdate is the dispatcher\n that lets the boil coexist with sweep scalars etc. Register\n every onUpdate-style render through it.\n - Never boil an element carrying an SVG transform attribute —\n nest a positioning <g> (or div) and boil the clean inner group.\n - A textured path (sharp/spray) lives in its OWN svg inside the\n boiled wrapper, so the stroke-matrix mask in that svg's defs\n rides the boil with it (a mask left in a shared static svg\n would clip the texture at jitter extremes). */\n #hw-boil-root {\n --hw-font-print: \"Caveat\", cursive;\n --hw-font-script: \"Caveat\", cursive;\n --hw-ink: #f4f2ec;\n --hw-accent: #6d6dff;\n\n position: relative;\n width: 1920px;\n height: 1080px;\n overflow: hidden;\n background: #17161a;\n font-family: var(--hw-font-print, \"Caveat\", cursive);\n }\n #hw-boil-root svg {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n }\n #hw-boil-root path {\n fill: none;\n stroke: var(--hw-ink);\n stroke-width: 6;\n stroke-linecap: round;\n stroke-linejoin: round;\n }\n #hw-b-arrow {\n stroke: var(--hw-accent);\n stroke-width: 7;\n }\n .hw-b-label {\n position: absolute;\n font-weight: 700;\n font-size: 84px;\n color: var(--hw-ink);\n white-space: nowrap;\n }\n .hw-b-tag {\n position: absolute;\n font-family: \"Inter\", ui-sans-serif, sans-serif;\n font-weight: 500;\n font-size: 22px;\n letter-spacing: 0.12em;\n color: rgba(244, 242, 236, 0.62);\n }\n </style>\n </head>\n <body>\n <div\n id=\"hw-boil-root\"\n data-composition-id=\"hw-boil-demo\"\n data-start=\"0\"\n data-duration=\"6\"\n data-width=\"1920\"\n data-height=\"1080\"\n >\n <svg viewBox=\"0 0 1920 1080\">\n <g id=\"hw-b-arrow-g\">\n <path\n id=\"hw-b-arrow\"\n d=\"M 910 780 C 1030 840, 1250 860, 1400 760 M 1400 760 l -64 -6 M 1400 760 l -18 58\"\n ></path>\n </g>\n </svg>\n <!-- textured paths: own svg inside the boiled div — the stroke-matrix\n mask (in each svg's defs) rides the boil with its path -->\n <div\n id=\"hw-b-sharp-w\"\n style=\"position: absolute; left: 185px; top: 320px; width: 390px; height: 280px\"\n >\n <div id=\"hw-b-sharp-g\" style=\"position: absolute; inset: 0\">\n <svg viewBox=\"0 0 390 280\" style=\"overflow: visible\">\n <path id=\"hw-b-sharp\"></path>\n </svg>\n </div>\n </div>\n <div\n id=\"hw-b-spray-w\"\n style=\"position: absolute; left: 755px; top: 320px; width: 390px; height: 280px\"\n >\n <div id=\"hw-b-spray-g\" style=\"position: absolute; inset: 0\">\n <svg viewBox=\"0 0 390 280\" style=\"overflow: visible\">\n <path id=\"hw-b-spray\"></path>\n </svg>\n </div>\n </div>\n <div class=\"hw-b-label\" id=\"hw-b-word\" style=\"left: 1430px; top: 700px\">the boil</div>\n <div class=\"hw-b-tag\" style=\"left: 260px; top: 660px\">STROKE \"SHARP\" · BOIL \"CALM\"</div>\n <div class=\"hw-b-tag\" style=\"left: 830px; top: 660px\">STROKE \"SPRAY\" · BOIL \"CALM\"</div>\n <div class=\"hw-b-tag\" style=\"left: 1430px; top: 850px\">BOIL \"LIVELY\"</div>\n <div class=\"hw-b-tag\" style=\"left: 910px; top: 930px\">RAW hwBoil · FRAME DROP 1</div>\n <div\n id=\"hw-b-drv\"\n class=\"clip\"\n data-start=\"0\"\n data-duration=\"6\"\n data-track-index=\"0\"\n style=\"position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none\"\n ></div>\n </div>\n <script>\n (function () {\n window.__timelines = window.__timelines || {};\n\n // ---- copy these helpers into the host script ----\n\n // Dispatcher: a GSAP timeline has ONE onUpdate. Register every\n // per-frame render (boils, sweep scalars) through this instead of\n // setting eventCallback directly, and they all coexist.\n window.hwOnUpdate = function (tl, fn) {\n if (!tl.__hwRenders) {\n tl.__hwRenders = [];\n tl.eventCallback(\"onUpdate\", function () {\n for (var i = 0; i < tl.__hwRenders.length; i++) tl.__hwRenders[i]();\n });\n }\n tl.__hwRenders.push(fn);\n fn();\n };\n\n // Seeded hash -> [-1, 1]. Pure function of n — no Math.random().\n window.hwHash = function (n, seed) {\n var x = Math.sin(n * 127.1 + (seed || 1) * 311.7) * 43758.5453;\n return (x - Math.floor(x)) * 2 - 1;\n };\n\n // The boil. Owns x/y/rotation of its targets — put entrance tweens\n // on a wrapper. frameDrop = re-pose every N frames (3-4 classic).\n window.hwBoil = function (tl, target, opts) {\n opts = opts || {};\n var amp = opts.amp !== undefined ? opts.amp : 1.6;\n var rot = opts.rot !== undefined ? opts.rot : 0.5;\n var fps = opts.fps || 30;\n var drop = opts.frameDrop || 3;\n var seed = opts.seed || 1;\n var els = gsap.utils.toArray(target);\n window.hwOnUpdate(tl, function () {\n var step = Math.floor((tl.time() * fps) / drop);\n for (var i = 0; i < els.length; i++) {\n gsap.set(els[i], {\n x: window.hwHash(step * 3 + i * 97, seed) * amp,\n y: window.hwHash(step * 3 + 1 + i * 97, seed) * amp,\n rotation: (opts.baseRot || 0) + window.hwHash(step * 3 + 2 + i * 97, seed) * rot,\n });\n }\n });\n };\n\n // The boil CONTROL: authored amp/rot poses over the family-locked\n // frameDrop 3; seed stays locked. Unknown pose → \"calm\" + console\n // error (bounded-controls law).\n window.hwBoilPose = function (tl, target, pose, opts) {\n opts = opts || {};\n var poses = { calm: { amp: 1.6, rot: 0.5 }, lively: { amp: 2.6, rot: 0.9 } };\n if (pose === \"off\") return;\n var p = poses[pose];\n if (!p) {\n console.error('hw: unknown boil pose \"' + pose + '\" — falling back to \"calm\"');\n p = poses.calm;\n }\n window.hwBoil(tl, target, { amp: p.amp, rot: p.rot, frameDrop: 3, seed: opts.seed || 1 });\n };\n\n // Seeded hand-wobbled ellipse path (smooth quadratic chain).\n window.hwWobbleEllipse = function (cx, cy, rx, ry, seed, wobblePct) {\n wobblePct = wobblePct === undefined ? 3 : wobblePct;\n var N = 14,\n pts = [];\n for (var i = 0; i < N; i++) {\n var a = (i / N) * Math.PI * 2;\n var wr = 1 + window.hwHash(i * 13 + 5, seed) * (wobblePct / 100);\n pts.push([cx + Math.cos(a) * rx * wr, cy + Math.sin(a) * ry * wr]);\n }\n var mx = (pts[0][0] + pts[N - 1][0]) / 2,\n my = (pts[0][1] + pts[N - 1][1]) / 2;\n var d = \"M\" + mx.toFixed(1) + \" \" + my.toFixed(1);\n for (var j = 0; j < N; j++) {\n var p = pts[j],\n q = pts[(j + 1) % N];\n d +=\n \" Q\" +\n p[0].toFixed(1) +\n \" \" +\n p[1].toFixed(1) +\n \" \" +\n ((p[0] + q[0]) / 2).toFixed(1) +\n \" \" +\n ((p[1] + q[1]) / 2).toFixed(1);\n }\n return d;\n };\n\n /* ---- pen-velocity ease: pure function of the path geometry ----\n Sample 25–75 curvature-adaptive points, speed ∝ 1/(1+k·curvature)\n floored at 0.22 (a pen slows into curves, never stalls), integrate\n ds/speed, invert to a normalized time→distance ease. Seek-safe:\n no per-frame state. */\n window.hwPenEase = function (pathEl, opts) {\n opts = opts || {};\n var kCurve = opts.kCurve !== undefined ? opts.kCurve : 10;\n var L = pathEl.getTotalLength();\n if (L <= 0)\n return {\n ease: function (t) {\n return t;\n },\n samples: 2,\n inkTime: 1,\n len: 0,\n };\n var PRE = 48;\n var pts = [];\n for (var i = 0; i <= PRE; i++) pts.push(pathEl.getPointAtLength((L * i) / PRE));\n var curv = [0];\n for (i = 1; i < PRE; i++) {\n var ax = pts[i].x - pts[i - 1].x,\n ay = pts[i].y - pts[i - 1].y;\n var bx = pts[i + 1].x - pts[i].x,\n by = pts[i + 1].y - pts[i].y;\n var la = Math.hypot(ax, ay) || 1e-6,\n lb = Math.hypot(bx, by) || 1e-6;\n var dot = Math.max(-1, Math.min(1, (ax * bx + ay * by) / (la * lb)));\n curv.push(Math.acos(dot) / ((la + lb) / 2));\n }\n curv.push(0);\n var mass = 0;\n for (i = 0; i < curv.length; i++) mass += curv[i];\n var N = Math.max(25, Math.min(75, Math.round(25 + mass * 18)));\n var seg = L / N;\n var times = [0];\n var t = 0;\n for (i = 1; i <= N; i++) {\n var u = ((i - 0.5) / N) * PRE;\n var i0 = Math.floor(u),\n f = u - i0;\n var c = curv[Math.min(i0, PRE)] * (1 - f) + curv[Math.min(i0 + 1, PRE)] * f;\n var speed = Math.max(1 / (1 + kCurve * c * 14), 0.22);\n t += seg / speed;\n times.push(t);\n }\n var total = times[N];\n for (i = 0; i <= N; i++) times[i] /= total;\n var easeFn = function (p) {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n var lo = 0,\n hi = N;\n while (hi - lo > 1) {\n var mid = (lo + hi) >> 1;\n if (times[mid] <= p) lo = mid;\n else hi = mid;\n }\n var span = times[hi] - times[lo] || 1e-9;\n return (lo + (p - times[lo]) / span) / N;\n };\n return { ease: easeFn, samples: N, inkTime: total, len: L };\n };\n\n /* ---- stroke matrix: plain | soft | sharp | spray ------------------\n strokeType is a variant control. Authored constants per type;\n unknown value → default (\"plain\") + console error (bounded-controls\n law). sharp = micro stroke-dasharray gaps (dry marker) — draw-on\n must therefore ride a MASK clone (the visible dasharray never\n animates). spray = index-seeded deterministic dots along the path\n via hwHash: position a pure function of path parameter + seed; NO\n feTurbulence anywhere.\n Returns { draw: pathToDashAnimate, group: maskedGroupOrNull } */\n window.hwStrokeTypes = {\n plain: {},\n soft: { blur: 0.6 },\n sharp: { dash: [3.0, 1.55] }, // × stroke-width\n spray: {\n coreOpacity: 0.5,\n coreBlur: 0.4,\n density: 0.16,\n scatter: 2.6,\n rMin: 1.1,\n rMax: 2.6,\n },\n };\n window.hwStrokeApply = function (pathEl, type, opts) {\n opts = opts || {};\n var cfg = window.hwStrokeTypes[type];\n if (!cfg) {\n console.error('hw: unknown strokeType \"' + type + '\" — falling back to \"plain\"');\n type = \"plain\";\n cfg = window.hwStrokeTypes.plain;\n }\n var svg = pathEl.ownerSVGElement;\n var ns = \"http://www.w3.org/2000/svg\";\n var w = parseFloat(getComputedStyle(pathEl).strokeWidth) || 6;\n if (type === \"plain\") return { draw: pathEl, group: null, type: type };\n if (type === \"soft\") {\n pathEl.style.filter = \"blur(\" + cfg.blur + \"px)\";\n return { draw: pathEl, group: null, type: type };\n }\n // sharp + spray: wrap in a masked group, draw-on animates the mask clone\n var id =\n opts.id ||\n \"hwsm-\" + Math.abs(Math.round(window.hwHash((opts.seed || 1) * 13.7, 5) * 1e6));\n var defs = svg.querySelector(\"defs\");\n if (!defs) {\n defs = document.createElementNS(ns, \"defs\");\n svg.insertBefore(defs, svg.firstChild);\n }\n var mask = document.createElementNS(ns, \"mask\");\n mask.setAttribute(\"id\", id);\n mask.setAttribute(\"maskUnits\", \"userSpaceOnUse\");\n var clone = document.createElementNS(ns, \"path\");\n clone.setAttribute(\"d\", pathEl.getAttribute(\"d\"));\n clone.setAttribute(\"fill\", \"none\");\n clone.setAttribute(\"stroke\", \"#fff\");\n clone.setAttribute(\n \"stroke-width\",\n w * (type === \"spray\" ? 2 + (cfg.scatter * 2) / w : 1.7),\n );\n clone.setAttribute(\"stroke-linecap\", \"round\");\n clone.setAttribute(\"stroke-linejoin\", \"round\");\n mask.appendChild(clone);\n defs.appendChild(mask);\n var group = document.createElementNS(ns, \"g\");\n group.setAttribute(\"mask\", \"url(#\" + id + \")\");\n pathEl.parentNode.insertBefore(group, pathEl);\n group.appendChild(pathEl);\n if (type === \"sharp\") {\n pathEl.setAttribute(\n \"stroke-dasharray\",\n (cfg.dash[0] * w).toFixed(1) + \" \" + (cfg.dash[1] * w).toFixed(1),\n );\n } else {\n // spray: faint core + seeded dots\n pathEl.setAttribute(\"stroke-opacity\", cfg.coreOpacity);\n pathEl.style.filter = \"blur(\" + cfg.coreBlur + \"px)\";\n var len = pathEl.getTotalLength();\n var n = Math.round(len * cfg.density * (opts.densityScale || 1));\n var seed = opts.seed || 1;\n var dots = document.createElementNS(ns, \"g\");\n for (var i = 0; i < n; i++) {\n var t = Math.min(\n 1,\n Math.max(0, (i + 0.5) / n + (window.hwHash(i * 7, seed) * 0.35) / n),\n );\n var pt = pathEl.getPointAtLength(t * len);\n var pt2 = pathEl.getPointAtLength(Math.min(len, t * len + 0.5));\n var tx = pt2.x - pt.x,\n ty = pt2.y - pt.y;\n var tl2 = Math.hypot(tx, ty) || 1;\n var nx = -ty / tl2,\n nyv = tx / tl2;\n var off = window.hwHash(i * 7 + 1, seed) * (cfg.scatter + w * 0.55);\n var r = cfg.rMin + Math.abs(window.hwHash(i * 7 + 2, seed)) * (cfg.rMax - cfg.rMin);\n var c = document.createElementNS(ns, \"circle\");\n c.setAttribute(\"cx\", (pt.x + nx * off).toFixed(1));\n c.setAttribute(\"cy\", (pt.y + nyv * off).toFixed(1));\n c.setAttribute(\"r\", r.toFixed(2));\n c.setAttribute(\"fill\", getComputedStyle(pathEl).stroke);\n dots.appendChild(c);\n }\n group.appendChild(dots);\n }\n return { draw: clone, group: group, type: type };\n };\n\n /* Draw-on across the stroke matrix: dash-animate whatever\n hwStrokeApply says. Optionally pen-velocity eased (opts.pen: true). */\n window.hwDrawOn = function (tl, applied, at, dur, opts) {\n opts = opts || {};\n var p = applied.draw;\n var len = p.getTotalLength();\n // the draw target is always solid (plain/soft: the path itself; sharp/spray:\n // the mask clone — the visible path keeps its texture dasharray untouched)\n p.setAttribute(\"stroke-dasharray\", len + \" \" + len);\n p.setAttribute(\"stroke-dashoffset\", len);\n gsap.set(p, { opacity: 0 }); // kill the round-cap start nub pre-draw\n var ease = opts.pen ? window.hwPenEase(p, opts).ease : opts.ease || \"power2.inOut\";\n tl.set(p, { opacity: 1 }, at);\n tl.to(\n p,\n { strokeDashoffset: 0, duration: dur === undefined ? 0.7 : dur, ease: ease },\n at,\n );\n };\n\n // ---- demo scene: non-default control states, labeled ----\n var sharpPath = document.getElementById(\"hw-b-sharp\");\n sharpPath.setAttribute(\"d\", window.hwWobbleEllipse(195, 140, 175, 120, 4, 3.2));\n var sprayPath = document.getElementById(\"hw-b-spray\");\n sprayPath.setAttribute(\"d\", window.hwWobbleEllipse(195, 140, 175, 120, 7, 3.2));\n\n var tl = gsap.timeline({ paused: true });\n\n /* stroke matrix, non-default states side by side: sharp (pen-eased\n draw-on) and spray (index-seeded deterministic dots) — both drawn\n through the mask-safe hwDrawOn */\n var sharpApplied = window.hwStrokeApply(sharpPath, \"sharp\", {\n seed: 4,\n id: \"hw-b-mask-sharp\",\n });\n window.hwDrawOn(tl, sharpApplied, 0.3, 0.9, { pen: true });\n var sprayApplied = window.hwStrokeApply(sprayPath, \"spray\", {\n seed: 6,\n id: \"hw-b-mask-spray\",\n });\n window.hwDrawOn(tl, sprayApplied, 0.7, 0.9, { pen: true });\n\n /* raw draw-on entrance for the arrow (not routed through the matrix) */\n var arrow = document.getElementById(\"hw-b-arrow\");\n var alen = arrow.getTotalLength();\n gsap.set(arrow, { strokeDasharray: alen, strokeDashoffset: alen });\n tl.to(arrow, { strokeDashoffset: 0, duration: 0.8, ease: \"power2.inOut\" }, 1.1);\n\n gsap.set(\"#hw-b-word\", { opacity: 0 });\n tl.to(\"#hw-b-word\", { opacity: 1, duration: 0.5, ease: \"power2.out\" }, 1.6);\n\n /* boil control states (calm / calm / lively) + one raw frantic\n character, one dispatcher */\n window.hwBoilPose(tl, \"#hw-b-sharp-g\", \"calm\", { seed: 2 });\n window.hwBoilPose(tl, \"#hw-b-spray-g\", \"calm\", { seed: 6 });\n window.hwBoilPose(tl, \"#hw-b-word\", \"lively\", { seed: 9 });\n window.hwBoil(tl, \"#hw-b-arrow-g\", { amp: 2.6, rot: 0.7, frameDrop: 1, seed: 5 });\n\n tl.set(\"#hw-boil-root\", { visibility: \"hidden\" }, 5.98);\n window.__timelines[\"hw-boil-demo\"] = tl;\n })();\n </script>\n </body>\n</html>\n"}