{
  "id": "shader-gradient-background",
  "kind": "element",
  "title": "Shader gradient background",
  "summary": "A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.",
  "url": "https://enrichr.dev/elements/shader-gradient-background.html",
  "section": "background",
  "techniques": [
    "webgl"
  ],
  "stack": [
    "Vanilla JS",
    "WebGL"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "fluid",
    "modern"
  ],
  "intents": [
    "shader background",
    "liquid gradient hero",
    "webgl gradient",
    "animated mesh gradient",
    "fluid background"
  ],
  "status": "tested",
  "params": [
    {
      "key": "colorA",
      "label": "Colour A",
      "type": "color",
      "value": "#1b4d3e"
    },
    {
      "key": "colorB",
      "label": "Colour B",
      "type": "color",
      "value": "#c6f26b"
    },
    {
      "key": "speed",
      "label": "Speed",
      "type": "range",
      "min": 0.1,
      "max": 4,
      "step": 0.1,
      "value": 1
    },
    {
      "key": "scale",
      "label": "Pattern scale",
      "type": "range",
      "min": 0.8,
      "max": 6,
      "step": 0.1,
      "value": 2.2
    }
  ],
  "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 \"Shader gradient background\" element to this project.\n\nThis is the \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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/shader-gradient-background.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 \"Shader gradient background\" 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 \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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 \"Shader gradient background\" element to this codebase.\n\nThis is the \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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-shader-gradient-background.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Shader gradient background 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 \"Shader gradient background\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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- shader-gradient-background.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 \"./shader-gradient-background\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ShaderGradientBackground(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 \"Shader gradient background\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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- shader-gradient-background.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/ShaderGradientBackground.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./shader-gradient-background\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ShaderGradientBackground(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 \"Shader gradient background\" element.\n\nThis is the \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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), shader-gradient-background.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 \"Shader gradient background\" element. No packages, no server code.\n\nThis is the \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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 shader-gradient-background.js and then main.js), style.css (the CSS below), shader-gradient-background.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 \"Shader gradient background\" 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 \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.json\n\nWhat it does: A full-screen triangle runs a fragment shader that builds fractal noise, warps it with a second noise lookup, and mixes your two colours along the result. Time is the only animated uniform. The canvas renders at no more than 1.5 times device pixel ratio, and the loop stops when the element is off screen or the tab is hidden.\nAccessibility: Decorative and hidden from assistive technology. Reduced motion draws one still frame. If WebGL is unavailable the container keeps a plain CSS gradient in the same two colours.\n\nTunable settings:\n- Colour A: color, default #1b4d3e\n- Colour B: color, default #c6f26b\n- Speed: range 0.1 to 4, step 0.1, default 1\n- Pattern scale: range 0.8 to 6, step 0.1, default 2.2\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/shader-gradient-background.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 \"Shader gradient background\" 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 \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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 ShaderGradientBackground.\n2. Paste the JavaScript below into a separate code file named shader-gradient-background.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 \"./shader-gradient-background\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ShaderGradientBackground(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(ShaderGradientBackground, {\n  colorA: { type: ControlType.Color, title: \"Colour A\", defaultValue: \"#1b4d3e\" },\n  colorB: { type: ControlType.Color, title: \"Colour B\", defaultValue: \"#c6f26b\" },\n  speed: { type: ControlType.Number, title: \"Speed\", min: 0.1, max: 4, step: 0.1, defaultValue: 1 },\n  scale: { type: ControlType.Number, title: \"Pattern scale\", min: 0.8, max: 6, step: 0.1, defaultValue: 2.2 },\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 \"Shader gradient background\" 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 \"Shader gradient background\" element from the Enrichr Library: A slow, flowing noise gradient drawn with one WebGL fragment shader, with a CSS fallback.\nPage: https://enrichr.dev/elements/shader-gradient-background.html\nMachine-readable spec: https://enrichr.dev/elements/shader-gradient-background.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-shader-gradient-background\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-shader-gradient-background\"), { ...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": "Decorative and hidden from assistive technology. Reduced motion draws one still frame. If WebGL is unavailable the container keeps a plain CSS gradient in the same two colours.",
  "performance": "Four noise octaves at mediump precision, a capped pixel ratio, low-power preference and no animation when hidden. Check it on a low-end phone before putting text over it.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-shader\"><canvas class=\"ef-shader__c\" aria-hidden=\"true\"></canvas></div>",
    "css": ".ef-shader { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(135deg, var(--ef-a, #1b4d3e), var(--ef-b, #c6f26b)); }\r\n.ef-shader__c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }",
    "js": "// Shader gradient background: a slow, domain-warped noise gradient drawn with one WebGL fragment shader.\r\n// Falls back to the plain CSS gradient when WebGL is missing, and draws a single still frame for reduced motion.\r\n// Put it inside a positioned parent; the element fills it. mount(root, { colorA, colorB, speed, scale })\r\nfunction mount(root, o) {\r\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\r\n  var wrap = root.querySelector(\".ef-shader\");\r\n  var canvas = root.querySelector(\".ef-shader__c\");\r\n  var gl = canvas.getContext(\"webgl\", { antialias: false, alpha: false, powerPreference: \"low-power\" });\r\n  var opts = {}, raf = 0, visible = true, io = null, prog, u = {}, t0 = performance.now(), still = 2.0;\r\n  var VS = \"attribute vec2 p;void main(){gl_Position=vec4(p,0.,1.);}\";\r\n  var FS = \"precision mediump float;uniform vec2 uR;uniform float uT,uS;uniform vec3 uA,uB;\" +\r\n    \"float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}\" +\r\n    \"float n(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);return mix(mix(h(i),h(i+vec2(1.,0.)),f.x),mix(h(i+vec2(0.,1.)),h(i+vec2(1.,1.)),f.x),f.y);}\" +\r\n    \"float fbm(vec2 p){float v=0.,k=.5;for(int i=0;i<4;i++){v+=k*n(p);p*=2.;k*=.5;}return v;}\" +\r\n    \"void main(){vec2 uv=gl_FragCoord.xy/uR;uv.x*=uR.x/uR.y;vec2 p=uv*uS;\" +\r\n    \"float q=fbm(p+vec2(uT*.07,0.));float w=fbm(p+3.*q+vec2(0.,uT*.05));\" +\r\n    \"vec3 c=mix(uA,uB,smoothstep(.2,.8,w));c*=.65+.5*q;gl_FragColor=vec4(c,1.);}\";\r\n\r\n  function rgb(hex) {\r\n    var m = /^#?([0-9a-f]{6})$/i.exec(hex || \"\");\r\n    var v = parseInt(m ? m[1] : \"1b4d3e\", 16);\r\n    return [(v >> 16) / 255, ((v >> 8) & 255) / 255, (v & 255) / 255];\r\n  }\r\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; }\r\n  function setup() {\r\n    var v = sh(gl.VERTEX_SHADER, VS), f = sh(gl.FRAGMENT_SHADER, FS);\r\n    if (!v || !f) return false;\r\n    prog = gl.createProgram(); gl.attachShader(prog, v); gl.attachShader(prog, f); gl.linkProgram(prog);\r\n    if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) return false;\r\n    gl.useProgram(prog);\r\n    var b = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, b);\r\n    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\r\n    var loc = gl.getAttribLocation(prog, \"p\"); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\r\n    [\"uR\", \"uT\", \"uS\", \"uA\", \"uB\"].forEach(function (k) { u[k] = gl.getUniformLocation(prog, k); });\r\n    return true;\r\n  }\r\n  function size() {\r\n    var dpr = Math.min(window.devicePixelRatio || 1, 1.5);\r\n    var w = Math.max(1, Math.round(wrap.clientWidth * dpr)), hh = Math.max(1, Math.round(wrap.clientHeight * dpr));\r\n    if (canvas.width !== w || canvas.height !== hh) { canvas.width = w; canvas.height = hh; gl.viewport(0, 0, w, hh); }\r\n  }\r\n  function draw(t) {\r\n    size();\r\n    gl.uniform2f(u.uR, canvas.width, canvas.height);\r\n    gl.uniform1f(u.uT, t);\r\n    gl.uniform1f(u.uS, opts.scale);\r\n    gl.uniform3fv(u.uA, rgb(opts.colorA));\r\n    gl.uniform3fv(u.uB, rgb(opts.colorB));\r\n    gl.drawArrays(gl.TRIANGLES, 0, 3);\r\n  }\r\n  function loop(now) {\r\n    raf = requestAnimationFrame(loop);\r\n    if (visible && !document.hidden) draw(((now - t0) / 1000) * opts.speed);\r\n  }\r\n  function update(next) {\r\n    opts = Object.assign({ colorA: \"#1b4d3e\", colorB: \"#c6f26b\", speed: 1, scale: 2.2 }, opts, next || {});\r\n    wrap.style.setProperty(\"--ef-a\", opts.colorA);\r\n    wrap.style.setProperty(\"--ef-b\", opts.colorB);\r\n    if (gl && prog && (reduce || !raf)) draw(still);\r\n  }\r\n  var ok = gl && setup();\r\n  update(o);\r\n  if (!ok) { canvas.style.display = \"none\"; return { update: update, destroy: function () {} }; }\r\n  if (!reduce) {\r\n    if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(wrap); }\r\n    raf = requestAnimationFrame(loop);\r\n  } else {\r\n    draw(still);\r\n    window.addEventListener(\"resize\", function () { draw(still); });\r\n  }\r\n  return { update: update, destroy: function () { cancelAnimationFrame(raf); if (io) io.disconnect(); } };\r\n}"
  }
}