{
  "id": "hypnotic-spiral",
  "kind": "element",
  "title": "Hypnotic spiral",
  "summary": "A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.",
  "url": "https://enrichr.dev/elements/hypnotic-spiral.html",
  "section": "background",
  "techniques": [
    "webgl"
  ],
  "stack": [
    "Vanilla JS",
    "WebGL"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "kinetic",
    "playful"
  ],
  "intents": [
    "hypnotic spiral background",
    "rotating spiral animation",
    "spiral shader webgl",
    "optical illusion background",
    "swirl animated hero background"
  ],
  "status": "tested",
  "params": [
    {
      "key": "speed",
      "label": "Rotation speed (negative reverses)",
      "type": "range",
      "min": -2,
      "max": 2,
      "step": 0.01,
      "value": 0.5
    },
    {
      "key": "density",
      "label": "Spiral density",
      "type": "range",
      "min": 1,
      "max": 20,
      "step": 0.1,
      "value": 8
    },
    {
      "key": "fisheye",
      "label": "Fisheye warp",
      "type": "range",
      "min": 0,
      "max": 2,
      "step": 0.01,
      "value": 0.2
    },
    {
      "key": "fineDisp",
      "label": "Fine ripple",
      "type": "range",
      "min": 0,
      "max": 0.2,
      "step": 0.001,
      "value": 0.02
    },
    {
      "key": "warpAmp",
      "label": "Warp amplitude",
      "type": "range",
      "min": 0,
      "max": 0.5,
      "step": 0.01,
      "value": 0.1
    },
    {
      "key": "warpFreq",
      "label": "Warp frequency",
      "type": "range",
      "min": 1,
      "max": 20,
      "step": 0.1,
      "value": 5
    },
    {
      "key": "centerX",
      "label": "Centre offset (x)",
      "type": "range",
      "min": -0.5,
      "max": 0.5,
      "step": 0.01,
      "value": 0
    },
    {
      "key": "colorA",
      "label": "Spiral colour",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "colorB",
      "label": "Gap colour",
      "type": "color",
      "value": "#0c1e18"
    }
  ],
  "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 \"Hypnotic spiral\" element to this project.\n\nThis is the \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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/hypnotic-spiral.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 \"Hypnotic spiral\" 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 \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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 \"Hypnotic spiral\" element to this codebase.\n\nThis is the \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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-hypnotic-spiral.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Hypnotic spiral 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 \"Hypnotic spiral\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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- hypnotic-spiral.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 \"./hypnotic-spiral\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function HypnoticSpiral(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 \"Hypnotic spiral\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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- hypnotic-spiral.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/HypnoticSpiral.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./hypnotic-spiral\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function HypnoticSpiral(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 \"Hypnotic spiral\" element.\n\nThis is the \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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), hypnotic-spiral.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 \"Hypnotic spiral\" element. No packages, no server code.\n\nThis is the \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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 hypnotic-spiral.js and then main.js), style.css (the CSS below), hypnotic-spiral.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 \"Hypnotic spiral\" 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 \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.json\n\nWhat it does: One fragment shader paints the whole box. Each pixel is measured from the centre in units of the shorter side, moved sideways by the centre offset, then pushed outwards by one plus the fisheye amount times its distance squared, so the edges bulge. That point becomes an angle and a radius. The spiral is the angle plus the radius times twice the density, minus one and a half times the clock. A wobble along the arms (the sine of the angle times the warp frequency, plus the clock, times the warp amplitude) and a fine ripple (the sine of fifty times the radius plus twice the clock, times the ripple amount) are added, and the sign of the sine of the total picks one colour or the other, so the edges stay sharp. The clock steps by the speed times 0.05 every frame, scaled to 60 frames a second, and is wrapped every 4 pi, where all three terms repeat.\nAccessibility: The canvas is decorative and has a text label. A turning high-contrast spiral can be uncomfortable for people sensitive to motion, so with prefers-reduced-motion it draws one still frame and never turns. Keep the speed low on pages people read. Nothing here needs keyboard input.\n\nTunable settings:\n- Rotation speed (negative reverses): range -2 to 2, step 0.01, default 0.5\n- Spiral density: range 1 to 20, step 0.1, default 8\n- Fisheye warp: range 0 to 2, step 0.01, default 0.2\n- Fine ripple: range 0 to 0.2, step 0.001, default 0.02\n- Warp amplitude: range 0 to 0.5, step 0.01, default 0.1\n- Warp frequency: range 1 to 20, step 0.1, default 5\n- Centre offset (x): range -0.5 to 0.5, step 0.01, default 0\n- Spiral colour: color, default #e6ff55\n- Gap colour: color, default #0c1e18\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/hypnotic-spiral.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 \"Hypnotic spiral\" 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 \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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 HypnoticSpiral.\n2. Paste the JavaScript below into a separate code file named hypnotic-spiral.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 \"./hypnotic-spiral\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function HypnoticSpiral(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(HypnoticSpiral, {\n  speed: { type: ControlType.Number, title: \"Rotation speed\", min: -2, max: 2, step: 0.01, defaultValue: 0.5 },\n  density: { type: ControlType.Number, title: \"Spiral density\", min: 1, max: 20, step: 0.1, defaultValue: 8 },\n  fisheye: { type: ControlType.Number, title: \"Fisheye warp\", min: 0, max: 2, step: 0.01, defaultValue: 0.2 },\n  fineDisp: { type: ControlType.Number, title: \"Fine ripple\", min: 0, max: 0.2, step: 0.001, defaultValue: 0.02 },\n  warpAmp: { type: ControlType.Number, title: \"Warp amplitude\", min: 0, max: 0.5, step: 0.01, defaultValue: 0.1 },\n  warpFreq: { type: ControlType.Number, title: \"Warp frequency\", min: 1, max: 20, step: 0.1, defaultValue: 5 },\n  centerX: { type: ControlType.Number, title: \"Centre offset\", min: -0.5, max: 0.5, step: 0.01, defaultValue: 0 },\n  colorA: { type: ControlType.Color, title: \"Spiral colour\", defaultValue: \"#e6ff55\" },\n  colorB: { type: ControlType.Color, title: \"Gap colour\", defaultValue: \"#0c1e18\" },\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 \"Hypnotic spiral\" 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 \"Hypnotic spiral\" element from the Enrichr Library: A hard-edged two-colour spiral that turns on the spot, with a fisheye bulge, a fine ripple and a gentle wobble along its arms.\nPage: https://enrichr.dev/elements/hypnotic-spiral.html\nMachine-readable spec: https://enrichr.dev/elements/hypnotic-spiral.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-hypnotic-spiral\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-hypnotic-spiral\"), { ...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 is decorative and has a text label. A turning high-contrast spiral can be uncomfortable for people sensitive to motion, so with prefers-reduced-motion it draws one still frame and never turns. Keep the speed low on pages people read. Nothing here needs keyboard input.",
  "performance": "One full-screen triangle and a short fragment shader (two lengths, one arctangent, three sines) per pixel. The pixel ratio is capped at 2, the loop pauses off screen and in hidden tabs, and destroy() frees the buffer, the program and the WebGL context. Without WebGL a still CSS ring pattern stays in place.",
  "dependencies": [],
  "codepen": "https://codepen.io/Enrichr-Dev/pen/rayorQL",
  "source": {
    "markup": "<div class=\"ef-spiral\"><canvas class=\"ef-spiral__c\" role=\"img\" aria-label=\"A two-colour spiral that turns slowly, with a fisheye bulge, a fine ripple and a gentle wobble along its arms\"></canvas></div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-spiral { position: relative; width: 100%; min-height: 22rem; overflow: hidden; border-radius: 1rem; background: var(--ef-spiral-b, #0c1e18) repeating-radial-gradient(circle at 50% 50%, var(--ef-spiral-a, #e6ff55) 0 2.4rem, var(--ef-spiral-b, #0c1e18) 2.4rem 4.8rem); }\n.ef-spiral .ef-spiral__c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Hypnotic spiral: a hard-edged two-colour spiral that turns on the spot, drawn by one fullscreen WebGL1 fragment shader.\n// Each pixel is measured from the centre (moved sideways by the centre offset), pushed outwards by a fisheye bulge that\n// grows with the square of the distance, then turned into an angle and a radius. The spiral is the sine of angle plus\n// radius times density, minus time; a wobble along the arms (sine of the angle times the warp frequency) and a fine\n// ripple (sine of fifty times the radius) are added before the sign of the sine picks the colour, so the edges stay sharp.\n// The clock steps by speed x 0.05 every frame, scaled to 60 frames a second, exactly as in the original pen.\n// Reduced motion draws one still frame. The loop pauses off screen and in hidden tabs. Without WebGL a CSS ring pattern\n// stays in place.\n// mount(root, { speed (turn rate, negative reverses), density (arm tightness), fisheye (bulge), fineDisp (ripple),\n//               warpAmp (arm wobble), warpFreq (wobbles per turn), centerX (centre offset), colorA (arms), colorB (gaps) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-spiral\");\n  var canvas = root.querySelector(\".ef-spiral__c\");\n  var opts = {}, raf = 0, visible = true, io = null, ro = null, destroyed = false, last = 0;\n  var gl = null, prog = null, vb = null, u = {}, ok = false, t = 0, PERIOD = Math.PI * 4;\n  var DEF = { speed: 0.5, density: 8, fisheye: 0.2, fineDisp: 0.02, warpAmp: 0.1, warpFreq: 5, centerX: 0, colorA: \"#e6ff55\", colorB: \"#0c1e18\" };\n\n  var VS = \"attribute vec2 p;void main(){gl_Position=vec4(p,0.0,1.0);}\";\n  // the original pen's fragment shader, unchanged except that the two colours are uniforms\n  var FS = \"#ifdef GL_FRAGMENT_PRECISION_HIGH\\nprecision highp float;\\n#else\\nprecision mediump float;\\n#endif\\n\" +\n    \"uniform float time;uniform float density;uniform float fisheye;uniform float fineDisp;uniform float warpAmp;\" +\n    \"uniform float warpFreq;uniform float centerX;uniform vec2 resolution;uniform vec3 colorA;uniform vec3 colorB;\" +\n    \"void main(){vec2 uv=(gl_FragCoord.xy-0.5*resolution.xy)/min(resolution.y,resolution.x);\" +\n    \"uv.x-=centerX;float dist=length(uv);uv*=1.0+(dist*dist*fisheye);\" +\n    \"float r=length(uv);float a=atan(uv.y,uv.x);\" +\n    \"float spiral=a+(r*density*2.0)-(time*1.5);\" +\n    \"float warp=sin(a*warpFreq+time)*warpAmp;\" +\n    \"float ripple=sin(r*50.0+time*2.0)*fineDisp;\" +\n    \"float bands=sin(spiral+warp+ripple);\" +\n    \"vec3 color=bands>0.0?colorA:colorB;gl_FragColor=vec4(color,1.0);}\";\n\n  function num(v, d) { v = Number(v); return isFinite(v) ? v : d; }\n  function rgb(h, d) { var m = /^#?([0-9a-f]{6})$/i.exec(h || \"\"); var v = parseInt(m ? m[1] : d, 16); return [(v >> 16) / 255, ((v >> 8) & 255) / 255, (v & 255) / 255]; }\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    gl.deleteShader(v); gl.deleteShader(f);\n    if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) return false;\n    gl.useProgram(prog);\n    vb = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, vb);\n    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n    var loc = gl.getAttribLocation(prog, \"p\"); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n    [\"time\", \"density\", \"fisheye\", \"fineDisp\", \"warpAmp\", \"warpFreq\", \"centerX\", \"resolution\", \"colorA\", \"colorB\"].forEach(function (k) { u[k] = gl.getUniformLocation(prog, k); });\n    return true;\n  }\n  function size() {\n    var dpr = Math.min(window.devicePixelRatio || 1, 2);\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; gl.viewport(0, 0, w, h); }\n  }\n  function draw() {\n    if (!ok || destroyed || gl.isContextLost()) return;\n    size();\n    // every term repeats after 4 pi of time, so wrapping the clock changes nothing on screen and keeps precision\n    gl.uniform1f(u.time, t % PERIOD);\n    gl.uniform1f(u.density, opts.density);\n    gl.uniform1f(u.fisheye, opts.fisheye);\n    gl.uniform1f(u.fineDisp, opts.fineDisp);\n    gl.uniform1f(u.warpAmp, opts.warpAmp);\n    gl.uniform1f(u.warpFreq, opts.warpFreq);\n    gl.uniform1f(u.centerX, opts.centerX);\n    gl.uniform2f(u.resolution, canvas.width, canvas.height);\n    gl.uniform3fv(u.colorA, rgb(opts.colorA, \"e6ff55\"));\n    gl.uniform3fv(u.colorB, rgb(opts.colorB, \"0c1e18\"));\n    gl.drawArrays(gl.TRIANGLES, 0, 3);\n  }\n  function still() { t = 0.5 * 0.05 * 120; draw(); }\n  function loop(now) {\n    raf = requestAnimationFrame(loop);\n    var dt = Math.min(0.1, Math.max(0, (now - last) / 1000)); last = now;\n    if (!visible || document.hidden) return;\n    t = (t + opts.speed * 0.05 * dt * 60) % PERIOD;\n    draw();\n  }\n  function update(partial) {\n    opts = Object.assign({}, DEF, opts, partial || {});\n    [\"speed\", \"density\", \"fisheye\", \"fineDisp\", \"warpAmp\", \"warpFreq\", \"centerX\"].forEach(function (k) { opts[k] = num(opts[k], DEF[k]); });\n    wrap.style.setProperty(\"--ef-spiral-a\", opts.colorA);\n    wrap.style.setProperty(\"--ef-spiral-b\", opts.colorB);\n    if (destroyed) return;\n    if (reduce) still(); else draw();\n  }\n  function onLost(e) { e.preventDefault(); canvas.style.display = \"none\"; }\n\n  try { gl = canvas.getContext(\"webgl\", { antialias: false, alpha: false, powerPreference: \"low-power\" }); } catch (e) { gl = null; }\n  ok = !!gl && setup();\n  if (!ok) canvas.style.display = \"none\";\n  else canvas.addEventListener(\"webglcontextlost\", onLost);\n  update(o);\n  if (ok) {\n    if (!reduce) {\n      if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(wrap); }\n      last = performance.now(); raf = requestAnimationFrame(loop);\n    }\n    if (\"ResizeObserver\" in window) { ro = new ResizeObserver(function () { if (!destroyed) draw(); }); ro.observe(wrap); }\n  }\n  return {\n    update: update,\n    destroy: function () {\n      destroyed = true; cancelAnimationFrame(raf);\n      if (io) io.disconnect();\n      if (ro) ro.disconnect();\n      canvas.removeEventListener(\"webglcontextlost\", onLost);\n      if (gl) {\n        var ext = gl.getExtension(\"WEBGL_lose_context\");\n        if (vb) gl.deleteBuffer(vb); if (prog) gl.deleteProgram(prog);\n        if (ext) ext.loseContext();\n        gl = null;\n      }\n    }\n  };\n}"
  }
}