Skip to content

Write HTML. Render video. Built for agents.

5.5 KB
Raw Blame
{"html":"<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\" />\n    <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js\"></script>\n    <style>\n      *,\n      *::before,\n      *::after {\n        margin: 0;\n        padding: 0;\n        box-sizing: border-box;\n      }\n      body {\n        background: transparent;\n        overflow: hidden;\n      }\n      #mk-ch-root {\n        /* ---- mk tokens: override in the host to re-skin the family ---- */\n        --mk-font: \"Inter\", -apple-system, sans-serif;\n        --mk-ink: #1d1d1f;\n        /* faint = transient pre-sweep tier (tweens up to full ink) — distinct from the family --mk-ink-dim */\n        --mk-ink-faint: #bcbcc2;\n        --mk-ink-dark: #f5f5f7;\n        --mk-ink-faint-dark: rgba(245, 245, 247, 0.32);\n\n        position: relative;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n        background: transparent; /* overlays footage or mk-background */\n      }\n      #mk-ch-box {\n        position: absolute;\n        font-family: var(--mk-font);\n        font-weight: 500;\n        letter-spacing: -0.015em;\n      }\n      .mk-ch-word {\n        display: inline;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"mk-ch-root\"\n      data-composition-id=\"mk-callout-highlight\"\n      data-start=\"0\"\n      data-duration=\"8\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <div id=\"mk-ch-box\" data-layout-allow-occlusion></div>\n      <div\n        id=\"mk-ch-drv\"\n        class=\"clip\"\n        data-start=\"0\"\n        data-duration=\"8\"\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 (inspector-style CONFIG) ----\n           The mechanic: one scalar (highlight progress 0..1) sweeps word-by-word\n           emphasis across the sentence — a \"highlight amount\"\n           slider. Tween the scalar over the speaker's sentence to follow speech. */\n        var CONFIG = {\n          scheme: \"light\", // \"light\" (ink on light bg) | \"dark\" (white on footage)\n          text: \"Functionality was our goal from the very beginning\",\n          fontSize: 60,\n          lineHeight: 1.3,\n          maxWidth: 700, // px; sentence wraps inside this\n          x: 1030, // box left edge; null = centered horizontally\n          y: null, // box top edge; null = centered vertically\n          align: \"left\",\n          sweep: { start: 1.2, end: 6.2 }, // block-local seconds, linear\n          animationIn: true, // fade/rise entrance before the sweep\n          animationOut: true,\n        };\n\n        var DUR = 8;\n        var root = document.getElementById(\"mk-ch-root\");\n        var box = document.getElementById(\"mk-ch-box\");\n\n        var FULL = CONFIG.scheme === \"dark\" ? \"#f5f5f7\" : \"#1d1d1f\";\n        var FAINT = CONFIG.scheme === \"dark\" ? \"rgba(245,245,247,0.32)\" : \"#bcbcc2\";\n\n        box.style.fontSize = CONFIG.fontSize + \"px\";\n        box.style.lineHeight = String(CONFIG.lineHeight);\n        box.style.maxWidth = CONFIG.maxWidth + \"px\";\n        box.style.textAlign = CONFIG.align;\n\n        /* build word spans */\n        var wordEls = [];\n        CONFIG.text.split(/\\s+/).forEach(function (w, i) {\n          if (i > 0) box.appendChild(document.createTextNode(\" \"));\n          var span = document.createElement(\"span\");\n          span.id = \"mk-ch-w-\" + i;\n          span.className = \"mk-ch-word\";\n          span.textContent = w;\n          span.style.color = FAINT;\n          box.appendChild(span);\n          wordEls.push(span);\n        });\n\n        /* position (measure after building) */\n        var rect = box.getBoundingClientRect();\n        box.style.left =\n          (CONFIG.x === null ? Math.round((1920 - rect.width) / 2) : CONFIG.x) + \"px\";\n        box.style.top =\n          (CONFIG.y === null ? Math.round((1080 - rect.height) / 2) : CONFIG.y) + \"px\";\n\n        /* state proxy: GSAP animates st.p, render derives every word color from it */\n        var st = { p: 0 };\n        var mix = gsap.utils.interpolate(FAINT, FULL);\n        function render() {\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\n        var tl = gsap.timeline({ paused: true });\n\n        if (CONFIG.animationIn) {\n          gsap.set(box, { opacity: 0, y: 24 });\n          tl.to(box, { opacity: 1, y: 0, duration: 0.7, ease: \"power3.out\" }, 0.3);\n        }\n\n        /* the highlight sweep — one scalar, linear so it tracks speech evenly.\n           To follow a real voiceover, replace with several tweens between\n           per-phrase progress values (keyframes on the slider). */\n        tl.to(\n          st,\n          { p: 1, duration: CONFIG.sweep.end - CONFIG.sweep.start, ease: \"none\" },\n          CONFIG.sweep.start,\n        );\n\n        if (CONFIG.animationOut) {\n          tl.to(box, { opacity: 0, y: -16, duration: 0.4, ease: \"power2.in\" }, DUR - 0.5);\n        }\n        tl.set(root, { visibility: \"hidden\" }, DUR - 0.02);\n\n        tl.eventCallback(\"onUpdate\", render);\n        render();\n\n        window.__timelines[\"mk-callout-highlight\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}