Skip to content

Write HTML. Render video. Built for agents.

9.4 KB
Raw Blame
{"html":"<!doctype html>\n<!-- Demo plate for the catalog preview. Identical to hw-title.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-title.html only. -->\n<html lang=\"en\">\n  <head><base href=\"/public/catalog/items/hw-title/\">\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-t-root {\n        /* ---- hw tokens ---- */\n        --hw-font-print: \"Caveat\", cursive;\n        --hw-font-script: \"Caveat\", cursive;\n        --hw-ink: #f4f2ec;\n        --hw-ink-dark: #26241f;\n        --hw-accent-warm: #ffb020;\n\n        position: relative;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n        background: transparent; /* overlays footage or a board */\n        font-family: var(--hw-font-print, \"Caveat\", cursive);\n      }\n      #hw-t-wrap {\n        position: absolute;\n        pointer-events: none;\n      }\n      #hw-t-line {\n        font-weight: 700;\n        line-height: 1.1;\n        white-space: nowrap;\n        text-shadow: 0 2px 18px rgba(0, 0, 0, 0.4);\n      }\n      #hw-t-line .w {\n        display: inline;\n      }\n      #hw-t-under {\n        overflow: visible;\n        display: block;\n      }\n      #hw-t-under path {\n        fill: none;\n        stroke: var(--hw-accent-warm);\n        stroke-width: 7;\n        stroke-linecap: round;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"hw-t-root\"\n      data-composition-id=\"hw-title\"\n      data-start=\"0\"\n      data-duration=\"6\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <div id=\"hw-t-wrap\">\n        <div id=\"hw-t-line\"></div>\n        <svg id=\"hw-t-under\" width=\"10\" height=\"34\"><path id=\"hw-t-under-path\"></path></svg>\n      </div>\n      <div\n        id=\"hw-t-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           Handwritten title with the highlight-sweep scalar (the shared\n           mk-callout-highlight mechanic) + squiggle underline + the boil.\n           Demonstrates the dispatcher composing sweep + boil on one\n           timeline (learning: one onUpdate — everything through hwOnUpdate). */\n        var CONFIG = {\n          text: \"shine like the star you are\",\n          fontSize: 120,\n          scheme: \"chalk\", // \"chalk\" (white, over footage) | \"ink\" (dark, boards)\n          sweep: { enabled: true, start: 0.8, end: 3.2 },\n          underline: { enabled: true, wobble: 6 },\n          boil: { enabled: true, amp: 1.4, rot: 0.3, frameDrop: 3 },\n          seed: 8,\n          x: null, // null = centered\n          y: null,\n          animationIn: true,\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 IN = clamp(DUR * 0.08, 0.3, 0.8);\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 FULL = CONFIG.scheme === \"ink\" ? \"#26241f\" : \"#f4f2ec\";\n        var FAINT = CONFIG.scheme === \"ink\" ? \"rgba(38,36,31,0.3)\" : \"rgba(244,242,236,0.32)\";\n\n        var wrap = document.getElementById(\"hw-t-wrap\");\n        var line = document.getElementById(\"hw-t-line\");\n        line.style.fontSize = CONFIG.fontSize + \"px\";\n\n        /* word spans */\n        var wordEls = [];\n        CONFIG.text.split(/\\s+/).forEach(function (w, i) {\n          if (i > 0) line.appendChild(document.createTextNode(\" \"));\n          var span = document.createElement(\"span\");\n          span.className = \"w\";\n          span.textContent = w;\n          span.style.color = CONFIG.sweep.enabled ? FAINT : FULL;\n          line.appendChild(span);\n          wordEls.push(span);\n        });\n\n        /* measure + position; build squiggle underline to match width */\n        var rect = line.getBoundingClientRect();\n        wrap.style.left =\n          (CONFIG.x === null ? Math.round((1920 - rect.width) / 2) : CONFIG.x) + \"px\";\n        wrap.style.top =\n          (CONFIG.y === null ? Math.round((1080 - rect.height) / 2) - 20 : CONFIG.y) + \"px\";\n\n        var underPath = document.getElementById(\"hw-t-under-path\");\n        if (CONFIG.underline.enabled) {\n          var uw = Math.round(rect.width);\n          var svg = document.getElementById(\"hw-t-under\");\n          svg.setAttribute(\"width\", uw);\n          svg.setAttribute(\"viewBox\", \"0 0 \" + uw + \" 34\");\n          var segs = Math.max(6, Math.round(uw / 90));\n          var d = \"M 2 \" + (16 + window.hwHash(0, CONFIG.seed) * 4).toFixed(1);\n          for (var i = 1; i <= segs; i++) {\n            var x = (uw / segs) * i;\n            var y = 16 + window.hwHash(i * 5 + 1, CONFIG.seed) * CONFIG.underline.wobble;\n            var cxp = x - uw / segs / 2 + window.hwHash(i * 5 + 2, CONFIG.seed) * 10;\n            var cyp = 16 + (i % 2 ? -1 : 1) * (8 + window.hwHash(i * 5 + 3, CONFIG.seed) * 4);\n            d +=\n              \" Q \" +\n              cxp.toFixed(1) +\n              \" \" +\n              cyp.toFixed(1) +\n              \" \" +\n              x.toFixed(1) +\n              \" \" +\n              y.toFixed(1);\n          }\n          underPath.setAttribute(\"d\", d);\n        } else {\n          document.getElementById(\"hw-t-under\").style.display = \"none\";\n        }\n\n        var tl = gsap.timeline({ paused: true });\n\n        if (CONFIG.animationIn) {\n          gsap.set(wrap, { opacity: 0 });\n          tl.to(wrap, { opacity: 1, duration: IN, ease: \"power2.out\" }, 0.1);\n        }\n\n        /* the sweep scalar — registered through the dispatcher so it\n           coexists with the boil on the same timeline */\n        if (CONFIG.sweep.enabled) {\n          var mix = gsap.utils.interpolate(FAINT, FULL);\n          var st = { p: 0 };\n          window.hwOnUpdate(tl, function () {\n            var k = st.p * wordEls.length;\n            for (var i = 0; i < wordEls.length; i++) {\n              var f = Math.max(0, Math.min(1, k - i));\n              wordEls[i].style.color = mix(f);\n            }\n          });\n          tl.to(\n            st,\n            { p: 1, duration: CONFIG.sweep.end - CONFIG.sweep.start, ease: \"none\" },\n            CONFIG.sweep.start,\n          );\n        }\n\n        /* underline draws as the sweep lands */\n        if (CONFIG.underline.enabled) {\n          var len = underPath.getTotalLength();\n          gsap.set(underPath, { strokeDasharray: len, strokeDashoffset: len });\n          var uAt = CONFIG.sweep.enabled ? CONFIG.sweep.end - 0.2 : 0.8;\n          tl.to(underPath, { strokeDashoffset: 0, duration: 0.7, ease: \"power2.inOut\" }, uAt);\n        }\n\n        if (CONFIG.boil.enabled) {\n          window.hwBoil(tl, \"#hw-t-wrap\", {\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(wrap, { opacity: 0, duration: OUT, ease: \"power2.in\" }, DUR - OUT - 0.05);\n        }\n        tl.set(\"#hw-t-root\", { visibility: \"hidden\" }, DUR - 0.02);\n\n        window.__timelines[\"hw-title\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}