Skip to content

Write HTML. Render video. Built for agents.

8.9 KB
Raw Blame
{"html":"<!doctype html>\n<!-- Demo plate for the catalog preview. Identical to hw-underline.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-underline.html only. -->\n<html lang=\"en\">\n  <head><base href=\"/public/catalog/items/hw-underline/\">\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-underline ------------------------------------------------\n         Squiggle underline / strikethrough / bracket marks that draw on.\n         Size the wrapper over the text they annotate. Requires the hw-boil\n         helpers in the host. */\n      .hw-mark {\n        position: absolute;\n        pointer-events: none;\n      }\n      .hw-mark svg {\n        width: 100%;\n        height: 100%;\n        overflow: visible;\n      }\n      .hw-mark path {\n        fill: none;\n        stroke: var(--hw-mark-color, var(--hw-accent-warm, #ffb020));\n        stroke-width: var(--hw-mark-w, 7);\n        stroke-linecap: round;\n        stroke-linejoin: round;\n      }\n      /* self-preview scene */\n      #hw-un-scene {\n        position: absolute;\n        inset: 0;\n        background: #17161a;\n        font-family: var(--hw-font-print, \"Caveat\", cursive);\n        font-weight: 700;\n        font-size: 84px;\n        color: #f4f2ec;\n      }\n      #hw-un-scene div {\n        position: absolute;\n        left: 480px;\n        white-space: nowrap;\n      }\n    </style>\n  </head>\n  <body>\n    <!-- Self-preview. WIRING: copy the .hw-mark CSS + markup pattern, the\n         hwMarkPath / hwMarkOn / hwMarkOff helpers, AND the hw-boil helpers.\n         Then:\n\n           document.querySelector(\"#hw-my-mark path\")\n             .setAttribute(\"d\", hwMarkPath(420, 34, \"underline\", 4));\n           hwMarkOn(tl, \"#hw-my-mark\", 2.0);\n           hwBoil(tl, \"#hw-my-mark\", { frameDrop: 3, seed: 4 });\n    -->\n    <div\n      id=\"hw-un-root\"\n      data-composition-id=\"hw-underline\"\n      data-start=\"0\"\n      data-duration=\"4\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <div id=\"hw-un-scene\">\n        <div style=\"top: 260px\">underline the point</div>\n        <div style=\"top: 460px\">cross this out</div>\n        <div style=\"top: 660px\">bracket the aside</div>\n      </div>\n      <div\n        class=\"hw-mark\"\n        id=\"hw-un-m1\"\n        style=\"left: 470px; top: 350px; width: 620px; height: 34px\"\n      >\n        <svg viewBox=\"0 0 620 34\"><path></path></svg>\n      </div>\n      <div\n        class=\"hw-mark\"\n        id=\"hw-un-m2\"\n        style=\"left: 470px; top: 500px; width: 480px; height: 34px\"\n      >\n        <svg viewBox=\"0 0 480 34\"><path></path></svg>\n      </div>\n      <div\n        class=\"hw-mark\"\n        id=\"hw-un-m3\"\n        style=\"left: 440px; top: 650px; width: 40px; height: 110px\"\n      >\n        <svg viewBox=\"0 0 40 110\"><path></path></svg>\n      </div>\n      <div\n        id=\"hw-un-drv\"\n        class=\"clip\"\n        data-start=\"0\"\n        data-duration=\"4\"\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        /* ---- hw-boil helpers (shared family runtime — copy once per host) ---- */\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        // ---- hw-mark helpers (copy these too) ----\n        // style: \"underline\" (squiggle) | \"strike\" (double pass) | \"bracket\"\n        window.hwMarkPath = function (w, h, style, seed) {\n          seed = seed || 1;\n          function wob(n, range) {\n            return window.hwHash(n, seed) * (range === undefined ? 5 : range);\n          }\n          var mid = h / 2;\n          if (style === \"bracket\") {\n            return (\n              \"M \" +\n              (w * 0.9 + wob(1, 3)) +\n              \" \" +\n              (2 + wob(2, 3)) +\n              \" Q \" +\n              wob(3, 4) +\n              \" \" +\n              (2 + wob(4)) +\n              \" \" +\n              (4 + wob(5, 3)) +\n              \" \" +\n              (h * 0.5 + wob(6)) +\n              \" Q \" +\n              wob(7, 4) +\n              \" \" +\n              (h - 2 + wob(8)) +\n              \" \" +\n              (w * 0.9 + wob(9, 3)) +\n              \" \" +\n              (h - 2 + wob(10, 3))\n            );\n          }\n          if (style === \"strike\") {\n            return (\n              \"M \" +\n              (2 + wob(1, 3)) +\n              \" \" +\n              (mid + wob(2)) +\n              \" L \" +\n              (w - 4 + wob(3, 3)) +\n              \" \" +\n              (mid - 3 + wob(4)) +\n              \" M \" +\n              (w - 10 + wob(5, 4)) +\n              \" \" +\n              (mid + 7 + wob(6)) +\n              \" L \" +\n              (8 + wob(7, 4)) +\n              \" \" +\n              (mid + 3 + wob(8))\n            );\n          }\n          /* underline squiggle */\n          var segs = Math.max(5, Math.round(w / 95));\n          var d = \"M 2 \" + (mid + wob(0, 4));\n          for (var i = 1; i <= segs; i++) {\n            var x = (w / segs) * i;\n            d +=\n              \" Q \" +\n              (x - w / segs / 2 + wob(i * 4 + 1, 9)) +\n              \" \" +\n              (mid + (i % 2 ? -1 : 1) * (9 + wob(i * 4 + 2, 4))) +\n              \" \" +\n              x.toFixed(1) +\n              \" \" +\n              (mid + wob(i * 4 + 3, 4));\n          }\n          return d;\n        };\n        window.hwMarkOn = function (tl, target, at, dur) {\n          var p = document.querySelector(target + \" path\");\n          var len = p.getTotalLength();\n          gsap.set(p, { strokeDasharray: len, strokeDashoffset: len });\n          tl.to(\n            p,\n            { strokeDashoffset: 0, duration: dur === undefined ? 0.55 : dur, ease: \"power2.inOut\" },\n            at,\n          );\n        };\n        window.hwMarkOff = function (tl, target, at) {\n          tl.to(target, { opacity: 0, duration: 0.3, ease: \"power2.in\" }, at);\n        };\n\n        // ---- self-preview ----\n        document\n          .querySelector(\"#hw-un-m1 path\")\n          .setAttribute(\"d\", window.hwMarkPath(620, 34, \"underline\", 4));\n        document\n          .querySelector(\"#hw-un-m2 path\")\n          .setAttribute(\"d\", window.hwMarkPath(480, 34, \"strike\", 6));\n        document\n          .querySelector(\"#hw-un-m3 path\")\n          .setAttribute(\"d\", window.hwMarkPath(40, 110, \"bracket\", 8));\n        var tl = gsap.timeline({ paused: true });\n        window.hwMarkOn(tl, \"#hw-un-m1\", 0.4);\n        window.hwMarkOn(tl, \"#hw-un-m2\", 1.0);\n        window.hwMarkOn(tl, \"#hw-un-m3\", 1.6);\n        window.hwBoil(tl, [\".hw-mark\"], { amp: 1.5, rot: 0.4, frameDrop: 3, seed: 5 });\n        tl.to([\".hw-mark\"], { opacity: 0, duration: 0.3, ease: \"power2.in\" }, 3.5);\n        tl.set(\"#hw-un-root\", { visibility: \"hidden\" }, 3.98);\n        window.__timelines[\"hw-underline\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}