Skip to content

Write HTML. Render video. Built for agents.

7.4 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>Clip Wipe</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=Poppins: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      #clip-wipe {\n        position: relative;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n        background: #0a0a0a;\n      }\n      .wp-overlay {\n        position: absolute;\n        inset: 0;\n        background: rgba(0, 0, 0, 0.45);\n        z-index: 1;\n        pointer-events: none;\n      }\n      #wp-container {\n        position: absolute;\n        inset: 0;\n        z-index: 10;\n        pointer-events: none;\n      }\n      .wp-group {\n        position: absolute;\n        bottom: 120px;\n        left: 0;\n        width: 100%;\n        display: flex;\n        flex-wrap: wrap;\n        align-items: flex-end;\n        justify-content: center;\n        gap: 24px;\n        padding: 0 100px;\n        visibility: hidden;\n      }\n      .wp-word {\n        font-family: \"Poppins\", sans-serif;\n        font-weight: 800;\n        font-size: 88px;\n        text-transform: uppercase;\n        color: #ffffff;\n        display: inline-block;\n        letter-spacing: 0.04em;\n        line-height: 1;\n        clip-path: inset(0 100% 0 0);\n        will-change: clip-path, color, opacity;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"clip-wipe\"\n      data-composition-id=\"caption-clip-wipe\"\n      data-start=\"0\"\n      data-duration=\"8\"\n      data-fps=\"30\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <div class=\"wp-overlay\"></div>\n      <div id=\"wp-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 KEYWORDS = new Set([8, 12, 15, 24, 27]); // HyperFrames, HTML, professional, code, cinema.\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(\"wp-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 = \"wp-group\";\n          grp.id = \"wp-grp-\" + gi;\n\n          var groupText = groupWords\n            .map(function (w) {\n              return w.text.toUpperCase();\n            })\n            .join(\" \");\n          var computedSize = fitFontSize(groupText, 88, \"800\", \"Poppins\", 1720);\n\n          groupWords.forEach(function (w, i) {\n            var wi = g.wordStart + i;\n            var span = document.createElement(\"span\");\n            span.className = \"wp-word\";\n            span.id = \"wp-w-\" + wi;\n            span.textContent = w.text.toUpperCase();\n            span.style.fontSize = computedSize + \"px\";\n            grp.appendChild(span);\n          });\n\n          container.appendChild(grp);\n\n          tl.set(grp, { visibility: \"visible\" }, g.start);\n\n          groupWords.forEach(function (w, i) {\n            var wi = g.wordStart + i;\n            var wordEl = document.getElementById(\"wp-w-\" + wi);\n            var isKW = KEYWORDS.has(wi);\n\n            tl.to(\n              wordEl,\n              { clipPath: \"inset(0 0% 0 0)\", duration: 0.3, ease: \"power2.out\" },\n              w.start,\n            );\n            if (isKW) {\n              tl.to(wordEl, { color: \"#FFD700\", duration: 0.05 }, w.start + 0.1);\n            }\n            tl.to(wordEl, { color: \"rgba(255,255,255,0.4)\", duration: 0.2 }, w.end);\n          });\n\n          var wordEls = grp.querySelectorAll(\".wp-word\");\n          tl.to(\n            wordEls,\n            {\n              clipPath: \"inset(0 0% 0 100%)\",\n              duration: 0.25,\n              stagger: 0.04,\n              ease: \"power2.in\",\n            },\n            g.end - 0.2,\n          );\n          tl.set(grp, { visibility: \"hidden\", opacity: 0 }, g.end);\n        });\n\n        tl.seek(0);\n        window.__timelines[\"caption-clip-wipe\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}