Skip to content

Open-source design agent: on-brand stills, decks, diagrams, charts and motion graphics from a chat thread, built on Deep Agents.

2.9 KB
Raw Blame
<template id="text-wave-distort-template">
  <div
    data-composition-id="text-wave-distort"
    data-width="1920"
    data-height="1080"
    data-duration="2"
  >
    <style>
      :root {
        --hg-violet: #7c3aed;
        --hg-violet-2: #a855f7;
        --hg-cyan: #2afff0;
        --hg-bg: #0a0a0f;
        --hg-fg: #f5f5fa;
        --hg-dim: #6b6b78;
      }
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      .stage {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .wave-hero {
        font-family: "Playfair Display", serif;
        font-style: italic;
        font-weight: 900;
        font-size: 280px;
        letter-spacing: -0.02em;
        white-space: nowrap;
        text-shadow: 0 0 40px rgba(168, 85, 247, 0.5);
      }
      .wave-hero .char {
        display: inline-block;
        will-change: transform;
      }
      /* per-char solid colors marching across a violet→cyan ramp */
      .wave-hero .char:nth-child(1) {
        color: #7c3aed;
      }
      .wave-hero .char:nth-child(2) {
        color: #a855f7;
      }
      .wave-hero .char:nth-child(3) {
        color: #d946ef;
      }
      .wave-hero .char:nth-child(4) {
        color: #ec4899;
      }
      .wave-hero .char:nth-child(5) {
        color: #2afff0;
      }
    </style>
    <div class="stage">
      <div class="wave-hero" id="hero">
        <span class="char">f</span><span class="char">l</span><span class="char">u</span
        ><span class="char">i</span><span class="char">d</span>
      </div>
    </div>
    <script>
      window.__timelines = window.__timelines || {};
      const tl = gsap.timeline({ paused: true });

      // Explicit fromTo entry — safer than .from() in paused/seek mode
      tl.fromTo(
        "#hero .char",
        { y: 60, opacity: 0 },
        { y: 0, opacity: 1, stagger: 0.06, ease: "back.out(1.8)", duration: 0.5 },
        0.1,
      );

      // Continuous wave: phase 0→4 cycles over 1.5s, amplitude envelope rise→settle
      const state = { phase: 0 };
      tl.to(
        state,
        {
          phase: 4,
          duration: 1.5,
          ease: "none",
          onUpdate: function () {
            const chars = document.querySelectorAll("#hero .char");
            const p = state.phase / 4;
            let amp;
            if (p < 0.35) amp = (p / 0.35) * 24;
            else if (p < 0.7)
              amp = 24 - ((p - 0.35) / 0.35) * 12; // 24 → 12
            else amp = 12 - ((p - 0.7) / 0.3) * 4; // 12 → 8
            chars.forEach((c, i) => {
              const y = amp * Math.sin(state.phase * Math.PI * 2 + i * 0.45);
              // Use gsap.set so it cooperates with GSAP's transform tracking
              gsap.set(c, { y });
            });
          },
        },
        0.65,
      );

      window.__timelines["text-wave-distort"] = tl;
    </script>
  </div>
</template>