Skip to content

Write HTML. Render video. Built for agents.

6.9 KB
Raw Blame
{"html":"<!doctype html>\n<!-- Demo plate for the catalog preview. Identical to hw-path-text.html except the\n     root background, which is opaque here so the transparent overlay reads.\n     Not installed by `hyperframes add` - registry-item.json lists hw-path-text.html only. -->\n<html lang=\"en\">\n  <head><base href=\"/public/catalog/items/hw-path-text/\">\n    <meta charset=\"utf-8\" />\n    <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js\"></script>\n    <style>\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-pt-root {\n        --hw-font-print: \"Caveat\", cursive;\n        --hw-font-script: \"Caveat\", cursive;\n        --hw-ink: #f4f2ec;\n\n        position: relative;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n        background: transparent;\n        font-family: var(--hw-font-print, \"Caveat\", cursive);\n      }\n      #hw-pt-svg {\n        position: absolute;\n        inset: 0;\n        width: 100%;\n        height: 100%;\n        overflow: visible;\n      }\n      /* The textPath carrier is geometry only — without fill:none it inherits\n         SVG's default black fill and renders as a solid blob under the text. */\n      #hw-pt-path {\n        fill: none;\n      }\n      #hw-pt-guide {\n        fill: none;\n        stroke: rgba(244, 242, 236, 0.22);\n        stroke-width: 3;\n        stroke-dasharray: 2 14;\n        stroke-linecap: round;\n      }\n      #hw-pt-svg text {\n        font-family: var(--hw-font-print, \"Caveat\", cursive);\n        font-weight: 700;\n        fill: var(--hw-ink);\n      }\n      #hw-pt-svg tspan {\n        opacity: 0;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"hw-pt-root\"\n      data-composition-id=\"hw-path-text\"\n      data-start=\"0\"\n      data-duration=\"6\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <svg id=\"hw-pt-svg\" viewBox=\"0 0 1920 1080\">\n        <path id=\"hw-pt-path\" d=\"\"></path>\n        <path id=\"hw-pt-guide\" d=\"\"></path>\n        <text id=\"hw-pt-text\" font-size=\"92\">\n          <textPath id=\"hw-pt-tp\" href=\"#hw-pt-path\" startOffset=\"4%\"></textPath>\n        </text>\n      </svg>\n      <div\n        id=\"hw-pt-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        /* ---- published parameters ----\n           Handwriting along any path — custom path text, natively via\n           SVG textPath (no Fusion overlay). CONFIG.d is the whole design. */\n        var CONFIG = {\n          text: \"come on this wild journey with me...\",\n          d: \"M 220 700 C 520 480, 900 820, 1230 560 S 1700 380, 1780 420\",\n          fontSize: 92,\n          showGuide: true, // faint dotted guide under the writing\n          typeCharDelay: 0.05,\n          seed: 12,\n          boil: { enabled: true, amp: 1.4, rot: 0.3, frameDrop: 3 },\n          animationOut: true,\n        };\n\n        var DUR = 6;\n        function clamp(v, lo, hi) {\n          return Math.min(hi, Math.max(lo, v));\n        }\n        var OUT = clamp(DUR * 0.06, 0.25, 0.6);\n\n        /* hw family runtime */\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        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        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        var pathEl = document.getElementById(\"hw-pt-path\");\n        var guide = document.getElementById(\"hw-pt-guide\");\n        pathEl.setAttribute(\"d\", CONFIG.d);\n        if (CONFIG.showGuide) guide.setAttribute(\"d\", CONFIG.d);\n        document.getElementById(\"hw-pt-text\").setAttribute(\"font-size\", CONFIG.fontSize);\n\n        /* per-char tspans along the path */\n        var NS = \"http://www.w3.org/2000/svg\";\n        var tp = document.getElementById(\"hw-pt-tp\");\n        Array.from(CONFIG.text).forEach(function (ch) {\n          var t = document.createElementNS(NS, \"tspan\");\n          t.textContent = ch;\n          tp.appendChild(t);\n        });\n\n        var tl = gsap.timeline({ paused: true });\n\n        /* guide draws first, then the handwriting types along it */\n        if (CONFIG.showGuide) {\n          var glen = guide.getTotalLength();\n          gsap.set(guide, { strokeDasharray: \"2 14\", strokeDashoffset: glen });\n          tl.to(guide, { strokeDashoffset: 0, duration: 0.9, ease: \"power2.inOut\" }, 0.2);\n        }\n        var chars = tp.querySelectorAll(\"tspan\");\n        var delay = Math.min(CONFIG.typeCharDelay, 2.6 / Math.max(1, chars.length));\n        tl.to(chars, { opacity: 1, duration: 0.03, stagger: delay, ease: \"none\" }, 0.7);\n\n        if (CONFIG.boil.enabled) {\n          window.hwBoil(tl, \"#hw-pt-svg\", {\n            amp: CONFIG.boil.amp,\n            rot: CONFIG.boil.rot,\n            frameDrop: CONFIG.boil.frameDrop,\n            seed: CONFIG.seed,\n          });\n        }\n\n        if (CONFIG.animationOut) {\n          tl.to(\"#hw-pt-svg\", { opacity: 0, duration: OUT, ease: \"power2.in\" }, DUR - OUT - 0.05);\n        }\n        tl.set(\"#hw-pt-root\", { visibility: \"hidden\" }, DUR - 0.02);\n\n        window.__timelines[\"hw-path-text\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}