{
  "id": "wave-image-webgl",
  "kind": "element",
  "title": "Wave image WebGL",
  "summary": "A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.",
  "url": "https://enrichr.dev/elements/wave-image-webgl.html",
  "section": "hero",
  "techniques": [
    "webgl",
    "pointer-interaction"
  ],
  "stack": [
    "Vanilla JS",
    "WebGL",
    "Canvas"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "fluid",
    "cinematic"
  ],
  "intents": [
    "image ripple effect on hover",
    "wavy image webgl",
    "water wave image hero",
    "pointer reactive image distortion",
    "sine wave image animation"
  ],
  "status": "tested",
  "params": [
    {
      "key": "strength",
      "label": "Wave strength",
      "type": "range",
      "min": 0,
      "max": 1.5,
      "step": 0.05,
      "value": 0.6
    },
    {
      "key": "frequency",
      "label": "Wave count",
      "type": "range",
      "min": 1,
      "max": 12,
      "step": 0.5,
      "value": 5
    },
    {
      "key": "speed",
      "label": "Speed",
      "type": "range",
      "min": 0,
      "max": 3,
      "step": 0.1,
      "value": 1
    },
    {
      "key": "colorA",
      "label": "Artwork green",
      "type": "color",
      "value": "#005236"
    },
    {
      "key": "colorB",
      "label": "Artwork accent",
      "type": "color",
      "value": "#e6ff55"
    }
  ],
  "license": "Free to use in personal and client projects during the preview. Final licence terms will be published here before any paid tier starts; ask before reselling the code as a collection.",
  "contract": "function mount(root, opts) -> { update(partialOpts), destroy() }; root must contain the element markup",
  "exports": {
    "claude": "Add the \"Wave image WebGL\" element to this project.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSteps:\n1. Look at the project first to see its framework and where components, styles and static files live. Follow its conventions.\n2. Fetch https://enrichr.dev/elements/wave-image-webgl.json if you can read URLs (fields: source.markup, source.css, source.js, params); otherwise use the source at the end of this message.\n3. Add the files, mount it where I tell you (default: the top of the home page), and pass the settings below as the opts.\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n5. Run the dev server and check it. with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "chatgpt": "I want the \"Wave image WebGL\" element on my website. Below is its complete source. Please:\n1. Build one self-contained index.html that I can open locally to see it working (put the CSS in a <style> tag and the JavaScript in a <script> tag, with the markup in the body).\n2. Then explain, step by step, which parts go where in my own site, and how to mount it. My stack is: [tell me yours, or say \"plain HTML\"].\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "cursor": "Add the \"Wave image WebGL\" element to this codebase.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nUse Composer / agent mode. First search the repo for how components, styles and scripts are organised, then add the files in the matching places, mount it on the page I name, and run the app to confirm it works. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nOptional: save this as .cursor/rules/enrichr-wave-image-webgl.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Wave image WebGL element\nalwaysApply: false\n---\nmount(root, opts) expects the element markup inside root and returns { update, destroy }. Always call destroy() on unmount and never edit the ef- class names.",
    "v0": "Create a Next.js (App Router) client component for the \"Wave image WebGL\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- wave-image-webgl.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nUse this component as the wrapper (adjust the import paths):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./wave-image-webgl\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function WaveImageWebgl(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRender it on the home page so I can see it. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "lovable": "Add the \"Wave image WebGL\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- wave-image-webgl.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nWrapper component (src/components/WaveImageWebgl.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./wave-image-webgl\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function WaveImageWebgl(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRemove the \"use client\" line if it is not needed. Show it on the home page. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "bolt": "Create a small Vite project (vanilla JavaScript, no framework unless I already have one) that shows the \"Wave image WebGL\" element.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, then a script tag), style.css (the CSS below), wave-image-webgl.js (the JavaScript below) and main.js that sets the container's innerHTML to the markup and calls mount(container, opts) with the settings below. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "replit": "Create a new HTML, CSS and JavaScript Repl that shows the \"Wave image WebGL\" element. No packages, no server code.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, link style.css, load wave-image-webgl.js and then main.js), style.css (the CSS below), wave-image-webgl.js (the JavaScript below), main.js (sets the container's innerHTML to the markup, then calls mount(container, opts) with the settings below). Press Run to preview. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "figma": "Designer handoff notes for the \"Wave image WebGL\" element (Enrichr Library). Figma cannot run this JavaScript inside a design file, so use it as a motion reference and hand the code to a developer.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nWhat it does: The artwork is painted once on an offscreen canvas and uploaded as a WebGL texture. A grid of 72 by 48 vertices is displaced in the vertex shader by three summed sine waves, plus a radial ripple centred on the smoothed pointer position. The ripple height follows pointer speed and decays when you stop. The wave height also tilts the texture lookup and brightens the crests, which sells the surface without any extra geometry.\nAccessibility: The canvas has a text label and the effect is decorative. With prefers-reduced-motion the picture is drawn flat and never animates, and pointer movement is ignored. If WebGL is missing the same artwork is drawn on a plain 2D canvas.\n\nTunable settings:\n- Wave strength: range 0 to 1.5, step 0.05, default 0.6\n- Wave count: range 1 to 12, step 0.5, default 5\n- Speed: range 0 to 3, step 0.1, default 1\n- Artwork green: color, default #005236\n- Artwork accent: color, default #e6ff55\n\nCurrent settings:\n{{SETTINGS}}\n\nFor the developer: Element contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nIn Figma:\n- Draw the resting state as a frame and the end state as a second frame; link them with Smart Animate to show the motion in a prototype.\n- Put the settings above in the frame's notes or Dev Mode annotations so the developer matches them.\n- Link https://enrichr.dev/elements/wave-image-webgl.html in the handoff: the live demo and the copy-ready code are there. Developers can paste the prompts for Claude, Cursor or v0 from the Export menu.\nNothing is copied from another designer's file; this is original code from Enrichr.",
    "framer": "Add the \"Wave image WebGL\" element to Framer as a code component. Framer code components are React, so wrap the vanilla code like this. Check it in the Framer editor, as Framer's component API can change.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. In Framer: Assets > Code > New component. Name it WaveImageWebgl.\n2. Paste the JavaScript below into a separate code file named wave-image-webgl.js in the same project, with  export { mount };  and  export const markup = \"<the markup string>\";  added. Put the CSS into the component as a <style> tag.\n3. Component:\n```tsx\nimport { addPropertyControls, ControlType } from \"framer\"\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./wave-image-webgl\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function WaveImageWebgl(props: any) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n\naddPropertyControls(WaveImageWebgl, {\n  strength: { type: ControlType.Number, title: \"Wave strength\", min: 0, max: 1.5, step: 0.05, defaultValue: 0.6 },\n  frequency: { type: ControlType.Number, title: \"Wave count\", min: 1, max: 12, step: 0.5, defaultValue: 5 },\n  speed: { type: ControlType.Number, title: \"Speed\", min: 0, max: 3, step: 0.1, defaultValue: 1 },\n  colorA: { type: ControlType.Color, title: \"Artwork green\", defaultValue: \"#005236\" },\n  colorB: { type: ControlType.Color, title: \"Artwork accent\", defaultValue: \"#e6ff55\" },\n})\n```\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "webflow": "Add the \"Wave image WebGL\" element to a Webflow site with an Embed element. Test it on the published or preview site: scripts in embeds may not run inside the Designer canvas.\n\nThis is the \"Wave image WebGL\" element from the Enrichr Library: A generated artwork on a raw WebGL mesh that ripples with sine waves and swells where the pointer moves.\nPage: https://enrichr.dev/elements/wave-image-webgl.html\nMachine-readable spec: https://enrichr.dev/elements/wave-image-webgl.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. Add an Embed element where it should appear. Paste a <style> block with the CSS, one container <div id=\"enrichr-wave-image-webgl\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-wave-image-webgl\"), { ...your settings... });\n   (set the container's innerHTML to the markup first, as in the contract).\n2. Embed elements have a size limit (check Webflow's current number). If the code is longer, host the JS and CSS as files and link them from Custom code in the page settings, then keep only the container and the mount call in the Embed.\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}"
  },
  "exportTools": [
    "claude",
    "chatgpt",
    "cursor",
    "v0",
    "lovable",
    "bolt",
    "replit",
    "figma",
    "framer",
    "webflow"
  ],
  "accessibility": "The canvas has a text label and the effect is decorative. With prefers-reduced-motion the picture is drawn flat and never animates, and pointer movement is ignored. If WebGL is missing the same artwork is drawn on a plain 2D canvas.",
  "performance": "One draw call of about 7,000 triangles per frame, a capped pixel ratio of 1.5, no antialiasing and a low-power GPU hint. The loop pauses when the element is off screen or the tab is hidden, and the WebGL context is released on destroy.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-wave\"><canvas class=\"ef-wave__c\" role=\"img\" aria-label=\"A generated landscape artwork rippling with waves that follow the pointer\"></canvas></div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-wave { position: relative; width: 100%; min-height: 20rem; overflow: hidden; border-radius: 1rem; background: linear-gradient(160deg, #0c1e18, var(--ef-wa, #005236)); touch-action: pan-y; cursor: crosshair; }\n.ef-wave__c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Wave image WebGL: a canvas-painted artwork is mapped onto a mesh in raw WebGL and rippled by sine waves. Moving the pointer adds a ripple that follows it, and faster movement means taller waves.\n// The artwork is generated in code (no image files). Without WebGL the still artwork is drawn on a 2D canvas; reduced motion shows the flat, calm picture.\n// mount(root, { strength (0-1.5, wave height), frequency (1-12, wave count), speed (0-3), colorA (artwork green), colorB (artwork accent) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-wave\");\n  var canvas = root.querySelector(\".ef-wave__c\");\n  var opts = {}, raf = 0, visible = true, io = null, ro = null, gl = null, prog, u = {}, tex, art = null, ctx2 = null, nIdx = 0;\n  var t0 = performance.now(), tx = 0, ty = 0, mx = 0, my = 0, energy = 0, lastX = null, lastY = 0, lastT = 0, destroyed = false;\n  var OV = 1.1, COLS = 72, ROWS = 48;\n  var VS = \"attribute vec2 p;uniform float uT,uAmp,uFreq,uE,uAsp;uniform vec2 uM,uS;varying vec2 vUv;varying float vH;\" +\n    \"void main(){vec2 q=p*\" + OV.toFixed(2) + \";\" +\n    \"float w=sin(q.x*uFreq+uT)*.5+sin(q.y*uFreq*.9-uT*1.3+q.x*1.5)*.35+sin((q.x+q.y)*uFreq*.5+uT*.7)*.15;\" +\n    \"vec2 d=(q-uM)*vec2(uAsp,1.);float r=length(d);\" +\n    \"float rip=sin(r*16.-uT*5.)*exp(-r*2.4)*uE;\" +\n    \"float h=w*uAmp+rip*(.25+uAmp);vH=h;\" +\n    \"vec2 pos=q;pos.y+=h*.045;\" +\n    \"vUv=p*.5*uS+.5+vec2(h*.012,h*.02);\" +\n    \"gl_Position=vec4(pos,0.,1.-h*.22);}\";\n  var FS = \"precision mediump float;uniform sampler2D uT0;varying vec2 vUv;varying float vH;\" +\n    \"void main(){vec3 c=texture2D(uT0,clamp(vUv,0.,1.)).rgb;\" +\n    \"c*=1.+vH*.5;c+=pow(max(vH,0.),3.)*.18;gl_FragColor=vec4(c,1.);}\";\n\n  function hex(h, d) {\n    var m = /^#?([0-9a-f]{6})$/i.exec(h || \"\"); var v = parseInt(m ? m[1] : d, 16);\n    return [v >> 16, (v >> 8) & 255, v & 255];\n  }\n  function mix(a, b, t) { return \"rgb(\" + [0, 1, 2].map(function (i) { return Math.round(a[i] + (b[i] - a[i]) * t); }).join(\",\") + \")\"; }\n  function seeded(s) { return function () { s = (s * 1664525 + 1013904223) >>> 0; return s / 4294967296; }; }\n\n  function makeArt() {\n    var W = 1280, H = 800, c = document.createElement(\"canvas\"); c.width = W; c.height = H;\n    var g = c.getContext(\"2d\"), A = hex(opts.colorA, \"005236\"), B = hex(opts.colorB, \"e6ff55\"), D = [12, 30, 24], C = [251, 248, 241];\n    var bg = g.createLinearGradient(0, 0, 0, H);\n    bg.addColorStop(0, mix(D, A, 0.15)); bg.addColorStop(0.55, mix(D, A, 0.75)); bg.addColorStop(1, mix(A, B, 0.25));\n    g.fillStyle = bg; g.fillRect(0, 0, W, H);\n    var sx = W * 0.64, sy = H * 0.42, sr = H * 0.24;\n    var glow = g.createRadialGradient(sx, sy, sr * 0.4, sx, sy, sr * 2.6);\n    glow.addColorStop(0, \"rgba(\" + B.join(\",\") + \",.45)\"); glow.addColorStop(1, \"rgba(\" + B.join(\",\") + \",0)\");\n    g.fillStyle = glow; g.fillRect(0, 0, W, H);\n    var sun = g.createLinearGradient(0, sy - sr, 0, sy + sr);\n    sun.addColorStop(0, mix(B, C, 0.35)); sun.addColorStop(1, mix(B, A, 0.15));\n    g.fillStyle = sun; g.beginPath(); g.arc(sx, sy, sr, 0, 7); g.fill();\n    g.fillStyle = mix(D, A, 0.55);\n    for (var i = 0; i < 7; i++) { var y = sy + sr * 0.05 + i * sr * 0.14; g.fillRect(sx - sr, y, sr * 2, 3 + i * 2.2); }\n    var rnd = seeded(7);\n    for (var k = 0; k < 4; k++) {\n      var base = H * (0.58 + k * 0.1), amp = 34 + k * 10, ph = rnd() * 6, f1 = 0.004 + k * 0.0016, f2 = 0.011 + k * 0.003;\n      g.beginPath(); g.moveTo(0, H);\n      for (var x = 0; x <= W; x += 8) g.lineTo(x, base + Math.sin(x * f1 + ph) * amp + Math.sin(x * f2 + ph * 2) * amp * 0.4);\n      g.lineTo(W, H); g.closePath();\n      g.fillStyle = mix(A, D, 0.2 + k * 0.22); g.fill();\n      g.strokeStyle = \"rgba(\" + C.join(\",\") + \",\" + (0.1 + k * 0.06) + \")\"; g.lineWidth = 2; g.stroke();\n    }\n    g.strokeStyle = \"rgba(\" + C.join(\",\") + \",.1)\"; g.lineWidth = 1;\n    for (var vx = 0; vx < W; vx += 26) { g.beginPath(); g.moveTo(vx + 0.5, 0); g.lineTo(vx + 0.5, H); g.stroke(); }\n    g.strokeStyle = \"rgba(\" + C.join(\",\") + \",.35)\"; g.lineWidth = 2;\n    for (var r = 1; r <= 3; r++) { g.beginPath(); g.arc(W * 0.2, H * 0.28, 34 * r, 0, 7); g.stroke(); }\n    g.fillStyle = \"rgb(\" + B.join(\",\") + \")\"; g.beginPath(); g.arc(W * 0.2, H * 0.28, 9, 0, 7); g.fill();\n    g.fillStyle = \"rgba(255,255,255,.035)\";\n    for (var n = 0; n < 7000; n++) g.fillRect(rnd() * W, rnd() * H, 1.5, 1.5);\n    return c;\n  }\n\n  function sh(type, src) { var s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return gl.getShaderParameter(s, gl.COMPILE_STATUS) ? s : null; }\n  function setup() {\n    var v = sh(gl.VERTEX_SHADER, VS), f = sh(gl.FRAGMENT_SHADER, FS);\n    if (!v || !f) return false;\n    prog = gl.createProgram(); gl.attachShader(prog, v); gl.attachShader(prog, f); gl.linkProgram(prog);\n    if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) return false;\n    gl.useProgram(prog);\n    var verts = [], idx = [], x, y;\n    for (y = 0; y <= ROWS; y++) for (x = 0; x <= COLS; x++) verts.push(x / COLS * 2 - 1, y / ROWS * 2 - 1);\n    for (y = 0; y < ROWS; y++) for (x = 0; x < COLS; x++) {\n      var a = y * (COLS + 1) + x, b = a + 1, c = a + COLS + 1, d = c + 1;\n      idx.push(a, b, c, b, d, c);\n    }\n    nIdx = idx.length;\n    var vb = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, vb); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verts), gl.STATIC_DRAW);\n    var ib = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ib); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(idx), gl.STATIC_DRAW);\n    var loc = gl.getAttribLocation(prog, \"p\"); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n    [\"uT\", \"uAmp\", \"uFreq\", \"uE\", \"uAsp\", \"uM\", \"uS\", \"uT0\"].forEach(function (k) { u[k] = gl.getUniformLocation(prog, k); });\n    tex = gl.createTexture();\n    gl.uniform1i(u.uT0, 0);\n    return true;\n  }\n  function upload() {\n    if (!gl || !tex) return;\n    gl.bindTexture(gl.TEXTURE_2D, tex);\n    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);\n    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, art);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n  }\n  function cover(w, h) {\n    var a = w / h, i = art.width / art.height;\n    return a > i ? [1, i / a] : [a / i, 1];\n  }\n  function size() {\n    var dpr = Math.min(window.devicePixelRatio || 1, 1.5);\n    var w = Math.max(1, Math.round(wrap.clientWidth * dpr)), h = Math.max(1, Math.round(wrap.clientHeight * dpr));\n    if (canvas.width !== w || canvas.height !== h) { canvas.width = w; canvas.height = h; if (gl) gl.viewport(0, 0, w, h); }\n  }\n  function drawStill() {\n    size();\n    var s = cover(canvas.width, canvas.height), sw = art.width * s[0], sh2 = art.height * s[1];\n    ctx2.drawImage(art, (art.width - sw) / 2, (art.height - sh2) / 2, sw, sh2, 0, 0, canvas.width, canvas.height);\n  }\n  function draw(t, flat) {\n    size();\n    var s = cover(canvas.width, canvas.height);\n    gl.uniform1f(u.uT, t);\n    gl.uniform1f(u.uAmp, flat ? 0 : opts.strength * 0.6);\n    gl.uniform1f(u.uFreq, opts.frequency);\n    gl.uniform1f(u.uE, flat ? 0 : energy * opts.strength);\n    gl.uniform1f(u.uAsp, canvas.width / canvas.height);\n    gl.uniform2f(u.uM, mx, my);\n    gl.uniform2f(u.uS, s[0], s[1]);\n    gl.drawElements(gl.TRIANGLES, nIdx, gl.UNSIGNED_SHORT, 0);\n  }\n  function loop(now) {\n    raf = requestAnimationFrame(loop);\n    if (!visible || document.hidden) return;\n    mx += (tx - mx) * 0.14; my += (ty - my) * 0.14;\n    energy *= 0.95;\n    draw(((now - t0) / 1000) * opts.speed, false);\n  }\n  function onMove(e) {\n    var r = wrap.getBoundingClientRect();\n    var nx = (e.clientX - r.left) / r.width * 2 - 1, ny = -((e.clientY - r.top) / r.height * 2 - 1);\n    var now = performance.now();\n    if (lastX !== null) {\n      var dt = Math.max(8, now - lastT), sp = Math.hypot(nx - lastX, ny - lastY) / dt * 16;\n      energy = Math.min(1.2, Math.max(energy, sp * 2.2));\n    }\n    lastX = nx; lastY = ny; lastT = now; tx = nx; ty = ny;\n  }\n  function onLeave() { lastX = null; }\n  function update(next) {\n    var prev = opts;\n    opts = Object.assign({ strength: 0.6, frequency: 5, speed: 1, colorA: \"#005236\", colorB: \"#e6ff55\" }, opts, next || {});\n    wrap.style.setProperty(\"--ef-wa\", opts.colorA);\n    if (!art || prev.colorA !== opts.colorA || prev.colorB !== opts.colorB) { art = makeArt(); if (gl) upload(); }\n    if (destroyed) return;\n    if (reduce) { if (gl) draw(0, true); else if (ctx2) drawStill(); }\n    else if (!gl && ctx2) drawStill();\n  }\n\n  gl = canvas.getContext(\"webgl\", { antialias: false, alpha: false, powerPreference: \"low-power\" });\n  var ok = !!gl && setup();\n  if (!ok) {\n    if (gl) { var c2 = canvas.cloneNode(false); canvas.parentNode.replaceChild(c2, canvas); canvas = c2; gl = null; }\n    ctx2 = canvas.getContext(\"2d\");\n  }\n  update(o);\n  if (ok) {\n    upload();\n    if (!reduce) {\n      wrap.addEventListener(\"pointermove\", onMove);\n      wrap.addEventListener(\"pointerleave\", onLeave);\n      if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(wrap); }\n      raf = requestAnimationFrame(loop);\n    } else draw(0, true);\n  }\n  if (\"ResizeObserver\" in window) {\n    ro = new ResizeObserver(function () { if (destroyed) return; if (!ok && ctx2) drawStill(); else if (ok && reduce) draw(0, true); });\n    ro.observe(wrap);\n  }\n  return {\n    update: update,\n    destroy: function () {\n      destroyed = true; cancelAnimationFrame(raf);\n      wrap.removeEventListener(\"pointermove\", onMove); wrap.removeEventListener(\"pointerleave\", onLeave);\n      if (io) io.disconnect();\n      if (ro) ro.disconnect();\n      if (gl) { var ext = gl.getExtension(\"WEBGL_lose_context\"); if (tex) gl.deleteTexture(tex); if (prog) gl.deleteProgram(prog); if (ext) ext.loseContext(); }\n    }\n  };\n}"
  }
}