Skip to content

Write HTML. Render video. Built for agents.

8.5 KB
Raw Blame
{"html":"<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=1920, height=1080\" />\n    <title>Highlight</title>\n    <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" />\n    <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin />\n    <link\n      href=\"https://fonts.googleapis.com/css2?family=Montserrat:wght@800&display=swap\"\n      rel=\"stylesheet\"\n    />\n    <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js\"></script>\n    <style>\n      *,\n      *::before,\n      *::after {\n        box-sizing: border-box;\n      }\n      html,\n      body {\n        width: 1920px;\n        height: 1080px;\n        margin: 0;\n        overflow: hidden;\n        background: #0a0a0a;\n      }\n      #highlight {\n        position: relative;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n        background: #0a0a0a;\n      }\n      #hl-video {\n        position: absolute;\n        inset: 0;\n        z-index: 0;\n        width: 100%;\n        height: 100%;\n        object-fit: cover;\n      }\n      .hl-overlay {\n        position: absolute;\n        inset: 0;\n        background: rgba(0, 0, 0, 0.4);\n        z-index: 1;\n        pointer-events: none;\n      }\n      #hl-container {\n        position: absolute;\n        inset: 0;\n        z-index: 10;\n        pointer-events: none;\n      }\n      .hl-group {\n        position: absolute;\n        bottom: 140px;\n        left: 0;\n        width: 100%;\n        display: flex;\n        flex-wrap: wrap;\n        align-items: flex-end;\n        justify-content: center;\n        gap: 8px;\n        padding: 0 100px;\n        opacity: 0;\n        visibility: hidden;\n      }\n      .hl-word {\n        font-family: \"Montserrat\", sans-serif;\n        font-weight: 800;\n        font-size: 80px;\n        text-transform: uppercase;\n        color: #ffffff;\n        display: inline-block;\n        letter-spacing: 0.02em;\n        line-height: 1;\n        position: relative;\n        padding: 6px 12px 8px;\n        text-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n        transform-origin: 50% 58%;\n        will-change: transform, filter;\n      }\n      .hl-word-bg {\n        position: absolute;\n        inset: 0;\n        background: linear-gradient(135deg, #ff1745 0%, #df1238 100%);\n        border-radius: 10px;\n        box-shadow: 0 12px 30px rgba(229, 20, 58, 0.32);\n        opacity: 0;\n        transform: scaleX(0);\n        transform-origin: 0% 50%;\n        z-index: -1;\n      }\n      .hl-word-text {\n        position: relative;\n        z-index: 1;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"highlight\"\n      data-composition-id=\"caption-highlight\"\n      data-start=\"0\"\n      data-duration=\"8\"\n      data-fps=\"30\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <div class=\"hl-overlay\"></div>\n      <div id=\"hl-container\"></div>\n    </div>\n\n    <script>\n      (function () {\n        window.__timelines = window.__timelines || {};\n\n        var _fitCanvas = document.createElement(\"canvas\");\n        var _fitCtx = _fitCanvas.getContext(\"2d\");\n        function fitFontSize(text, baseFontSize, fontWeight, fontFamily, maxWidth) {\n          var size = baseFontSize;\n          var minSize = Math.floor(baseFontSize * 0.45);\n          while (size > minSize) {\n            _fitCtx.font = fontWeight + \" \" + size + \"px \" + fontFamily;\n            if (_fitCtx.measureText(text).width <= maxWidth) return size;\n            size -= 2;\n          }\n          return minSize;\n        }\n\n        var WORDS = [\n          { text: \"Every\", start: 0.0, end: 0.3 },\n          { text: \"great\", start: 0.3, end: 0.55 },\n          { text: \"video\", start: 0.55, end: 0.85 },\n          { text: \"starts\", start: 0.85, end: 1.1 },\n          { text: \"with\", start: 1.1, end: 1.25 },\n          { text: \"a\", start: 1.25, end: 1.35 },\n          { text: \"single\", start: 1.35, end: 1.65 },\n          { text: \"frame.\", start: 1.65, end: 2.0 },\n          { text: \"HyperFrames\", start: 2.1, end: 2.65 },\n          { text: \"lets\", start: 2.65, end: 2.85 },\n          { text: \"you\", start: 2.85, end: 2.95 },\n          { text: \"write\", start: 2.95, end: 3.15 },\n          { text: \"HTML\", start: 3.15, end: 3.55 },\n          { text: \"and\", start: 3.55, end: 3.65 },\n          { text: \"render\", start: 3.65, end: 3.95 },\n          { text: \"professional\", start: 3.95, end: 4.45 },\n          { text: \"video.\", start: 4.45, end: 4.8 },\n          { text: \"No\", start: 4.9, end: 5.05 },\n          { text: \"timeline.\", start: 5.05, end: 5.45 },\n          { text: \"No\", start: 5.5, end: 5.65 },\n          { text: \"drag\", start: 5.65, end: 5.85 },\n          { text: \"and\", start: 5.85, end: 5.95 },\n          { text: \"drop.\", start: 5.95, end: 6.25 },\n          { text: \"Just\", start: 6.35, end: 6.55 },\n          { text: \"code\", start: 6.55, end: 6.8 },\n          { text: \"that\", start: 6.8, end: 6.95 },\n          { text: \"becomes\", start: 6.95, end: 7.3 },\n          { text: \"cinema.\", start: 7.3, end: 7.7 },\n        ];\n\n        var RAW_GROUPS = [\n          [0, 3],\n          [4, 7],\n          [8, 8],\n          [9, 12],\n          [13, 15],\n          [16, 16],\n          [17, 19],\n          [20, 22],\n          [23, 24],\n          [25, 27],\n        ];\n        var GROUPS = RAW_GROUPS.map(function (pair, gi) {\n          var ws = pair[0],\n            we = pair[1];\n          var nextStart = gi + 1 < RAW_GROUPS.length ? WORDS[RAW_GROUPS[gi + 1][0]].start : 8.0;\n          var gEnd = Math.min(WORDS[we].end + 0.5, nextStart - 0.05);\n          return { wordStart: ws, wordEnd: we, start: WORDS[ws].start, end: gEnd };\n        });\n\n        var container = document.getElementById(\"hl-container\");\n        var tl = gsap.timeline({ paused: true });\n\n        GROUPS.forEach(function (g, gi) {\n          var groupWords = WORDS.slice(g.wordStart, g.wordEnd + 1);\n          var grp = document.createElement(\"div\");\n          grp.className = \"hl-group\";\n          grp.id = \"hl-grp-\" + gi;\n\n          var groupText = groupWords\n            .map(function (w) {\n              return w.text.toUpperCase();\n            })\n            .join(\" \");\n          var computedSize = fitFontSize(groupText, 80, \"800\", \"Montserrat\", 1620);\n\n          groupWords.forEach(function (w, i) {\n            var wi = g.wordStart + i;\n            var wordEl = document.createElement(\"span\");\n            wordEl.className = \"hl-word\";\n            wordEl.id = \"hl-w-\" + wi;\n            wordEl.style.fontSize = computedSize + \"px\";\n\n            var bgEl = document.createElement(\"span\");\n            bgEl.className = \"hl-word-bg\";\n            bgEl.id = \"hl-bg-\" + wi;\n\n            var textEl = document.createElement(\"span\");\n            textEl.className = \"hl-word-text\";\n            textEl.textContent = w.text.toUpperCase();\n\n            wordEl.appendChild(bgEl);\n            wordEl.appendChild(textEl);\n            grp.appendChild(wordEl);\n          });\n\n          container.appendChild(grp);\n\n          tl.set(grp, { visibility: \"visible\" }, g.start);\n          tl.fromTo(\n            grp,\n            { opacity: 0 },\n            { opacity: 1, duration: 0.12, ease: \"power2.out\" },\n            g.start,\n          );\n\n          groupWords.forEach(function (w, i) {\n            var wi = g.wordStart + i;\n            var bgEl = document.getElementById(\"hl-bg-\" + wi);\n            var wordEl = document.getElementById(\"hl-w-\" + wi);\n\n            tl.to(bgEl, { opacity: 1, scaleX: 1, duration: 0.15, ease: \"power2.out\" }, w.start);\n            tl.to(\n              wordEl,\n              { filter: \"brightness(1.05)\", duration: 0.08, ease: \"power2.out\" },\n              w.start,\n            );\n            tl.to(\n              wordEl,\n              { filter: \"brightness(1)\", duration: 0.16, ease: \"power2.out\" },\n              w.start + 0.08,\n            );\n            tl.to(bgEl, { opacity: 0, scaleX: 1.02, duration: 0.1, ease: \"power2.in\" }, w.end);\n            tl.set(bgEl, { scaleX: 0 }, w.end + 0.1);\n          });\n\n          tl.to(grp, { opacity: 0, duration: 0.1, ease: \"power2.in\" }, g.end - 0.1);\n          tl.set(grp, { opacity: 0, visibility: \"hidden\" }, g.end);\n        });\n\n        tl.seek(0);\n        window.__timelines[\"caption-highlight\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}