{
  "id": "petal-spin-matrix",
  "kind": "element",
  "title": "Petal spin matrix",
  "summary": "A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.",
  "url": "https://enrichr.dev/elements/petal-spin-matrix.html",
  "section": "background",
  "techniques": [
    "stagger",
    "pointer-interaction"
  ],
  "stack": [
    "Vanilla JS",
    "Canvas"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "playful",
    "kinetic"
  ],
  "intents": [
    "spinning pattern background",
    "staggered rotation grid animation",
    "four petal star pattern background",
    "diagonal ripple spin animation",
    "animated geometric tile pattern"
  ],
  "status": "tested",
  "params": [
    {
      "key": "ease",
      "label": "Spin ease",
      "type": "select",
      "options": [
        [
          "power1.in",
          "Gentle ease in (power1.in)"
        ],
        [
          "power2.in",
          "Medium ease in (power2.in)"
        ],
        [
          "power3.in",
          "Strong ease in (power3.in)"
        ],
        [
          "power4.in",
          "Sharp ease in (power4.in)"
        ],
        [
          "back.in",
          "Pull back, then spin (back.in)"
        ],
        [
          "circ.in",
          "Circular (circ.in)"
        ],
        [
          "expo.in",
          "Exponential (expo.in)"
        ],
        [
          "bounce.in",
          "Bounce (bounce.in)"
        ],
        [
          "elastic.in",
          "Elastic (elastic.in)"
        ]
      ],
      "value": "power2.in"
    },
    {
      "key": "sequence",
      "label": "Stagger order",
      "type": "select",
      "options": [
        [
          "diagonal",
          "Diagonal ripple from a corner"
        ],
        [
          "radial",
          "Centre outward"
        ],
        [
          "row",
          "Rows, top to bottom"
        ],
        [
          "col",
          "Columns, left to right"
        ],
        [
          "random",
          "Random"
        ]
      ],
      "value": "diagonal"
    },
    {
      "key": "degrees",
      "label": "Spin per wave (degrees)",
      "type": "range",
      "min": 90,
      "max": 720,
      "step": 90,
      "value": 360
    },
    {
      "key": "duration",
      "label": "Spin duration (s)",
      "type": "range",
      "min": 0.3,
      "max": 3,
      "step": 0.1,
      "value": 1.2
    },
    {
      "key": "stagger",
      "label": "Stagger per star (s)",
      "type": "range",
      "min": 0,
      "max": 0.15,
      "step": 0.005,
      "value": 0.03
    },
    {
      "key": "rest",
      "label": "Rest between waves (s)",
      "type": "range",
      "min": 0,
      "max": 3,
      "step": 0.1,
      "value": 0.5
    },
    {
      "key": "tile",
      "label": "Tile size (px)",
      "type": "range",
      "min": 28,
      "max": 160,
      "step": 1,
      "value": 72
    },
    {
      "key": "petal",
      "label": "Petal scale",
      "type": "range",
      "min": 0.4,
      "max": 1.8,
      "step": 0.05,
      "value": 1
    },
    {
      "key": "angle",
      "label": "Grid angle (degrees)",
      "type": "range",
      "min": 0,
      "max": 360,
      "step": 1,
      "value": 0
    },
    {
      "key": "mode",
      "label": "Style",
      "type": "select",
      "options": [
        [
          "solid",
          "Two-tone solid"
        ],
        [
          "wireframe",
          "Outline"
        ],
        [
          "glow",
          "Neon halo"
        ],
        [
          "checker",
          "Checker"
        ]
      ],
      "value": "solid"
    },
    {
      "key": "glow",
      "label": "Glow (px)",
      "type": "range",
      "min": 0,
      "max": 30,
      "step": 1,
      "value": 0
    },
    {
      "key": "hover",
      "label": "Pointer reaction",
      "type": "select",
      "options": [
        [
          "1",
          "On"
        ],
        [
          "0",
          "Off"
        ]
      ],
      "value": "1"
    },
    {
      "key": "palette",
      "label": "Palette",
      "type": "select",
      "options": [
        [
          "enrichr",
          "Enrichr (cream and lime on ink)"
        ],
        [
          "noir",
          "Noir"
        ],
        [
          "forest",
          "Forest"
        ],
        [
          "ember",
          "Ember"
        ],
        [
          "cream",
          "Ink on cream"
        ]
      ],
      "value": "enrichr"
    },
    {
      "key": "primary",
      "label": "Petals",
      "type": "color",
      "value": "#fbf8f1"
    },
    {
      "key": "secondary",
      "label": "Accent while spinning",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "background",
      "label": "Background",
      "type": "color",
      "value": "#0c1e18"
    },
    {
      "key": "stroke",
      "label": "Petal outline",
      "type": "color",
      "value": "#085e3d"
    }
  ],
  "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 \"Petal spin matrix\" element to this project.\n\nThis is the \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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/petal-spin-matrix.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 \"Petal spin matrix\" 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 \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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 \"Petal spin matrix\" element to this codebase.\n\nThis is the \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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-petal-spin-matrix.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Petal spin matrix 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 \"Petal spin matrix\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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- petal-spin-matrix.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 \"./petal-spin-matrix\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function PetalSpinMatrix(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 \"Petal spin matrix\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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- petal-spin-matrix.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/PetalSpinMatrix.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./petal-spin-matrix\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function PetalSpinMatrix(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 \"Petal spin matrix\" element.\n\nThis is the \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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), petal-spin-matrix.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 \"Petal spin matrix\" element. No packages, no server code.\n\nThis is the \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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 petal-spin-matrix.js and then main.js), style.css (the CSS below), petal-spin-matrix.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 \"Petal spin matrix\" 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 \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.json\n\nWhat it does: The stars sit on a square grid as wide as the box's diagonal plus four spare tiles, centred, so the grid can be turned to any angle and still cover the corners. Each star is the same four-petal vector path. A hand-built timeline replaces the original's GSAP timeline: every star gets a delay of its position factor times the stagger times the number of stars. The diagonal factor is (column plus row) divided by (columns plus rows); centre outward uses the distance from the middle, rows and columns use their index, random uses a random number. Each star then turns by the spin angle over the spin duration, through the same ease formulas GSAP uses (power2.in is progress cubed, back.in pulls back first, bounce.in and elastic.in use GSAP's constants). After the last star finishes and the rest has passed, the timeline repeats and every star snaps back to its start angle, which looks the same because the star has four-fold symmetry. A star's colour moves from the petal colour toward the accent as it turns. Near the pointer, stars grow by up to 25%, fatten their petals by up to 30%, lean toward the accent and glow; a click spins the stars around that point at once, on top of the wave.\nAccessibility: The canvas is decorative and has a text label. With prefers-reduced-motion it draws one still frame part way through a wave, so the band of turned stars still shows, and it ignores the pointer. Spins are smooth turns, not flashes. The click spin is a pointer extra; nothing needs the keyboard and the canvas adds no tab stop.\n\nTunable settings:\n- Spin ease: select (Gentle ease in (power1.in) / Medium ease in (power2.in) / Strong ease in (power3.in) / Sharp ease in (power4.in) / Pull back, then spin (back.in) / Circular (circ.in) / Exponential (expo.in) / Bounce (bounce.in) / Elastic (elastic.in)), default power2.in\n- Stagger order: select (Diagonal ripple from a corner / Centre outward / Rows, top to bottom / Columns, left to right / Random), default diagonal\n- Spin per wave (degrees): range 90 to 720, step 90, default 360\n- Spin duration (s): range 0.3 to 3, step 0.1, default 1.2\n- Stagger per star (s): range 0 to 0.15, step 0.005, default 0.03\n- Rest between waves (s): range 0 to 3, step 0.1, default 0.5\n- Tile size (px): range 28 to 160, step 1, default 72\n- Petal scale: range 0.4 to 1.8, step 0.05, default 1\n- Grid angle (degrees): range 0 to 360, step 1, default 0\n- Style: select (Two-tone solid / Outline / Neon halo / Checker), default solid\n- Glow (px): range 0 to 30, step 1, default 0\n- Pointer reaction: select (On / Off), default 1\n- Palette: select (Enrichr (cream and lime on ink) / Noir / Forest / Ember / Ink on cream), default enrichr\n- Petals: color, default #fbf8f1\n- Accent while spinning: color, default #e6ff55\n- Background: color, default #0c1e18\n- Petal outline: color, default #085e3d\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/petal-spin-matrix.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 \"Petal spin matrix\" 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 \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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 PetalSpinMatrix.\n2. Paste the JavaScript below into a separate code file named petal-spin-matrix.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 \"./petal-spin-matrix\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function PetalSpinMatrix(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(PetalSpinMatrix, {\n  ease: { type: ControlType.Enum, title: \"Spin ease\", options: [\"power1.in\",\"power2.in\",\"power3.in\",\"power4.in\",\"back.in\",\"circ.in\",\"expo.in\",\"bounce.in\",\"elastic.in\"], optionTitles: [\"Gentle ease in (power1.in)\",\"Medium ease in (power2.in)\",\"Strong ease in (power3.in)\",\"Sharp ease in (power4.in)\",\"Pull back, then spin (back.in)\",\"Circular (circ.in)\",\"Exponential (expo.in)\",\"Bounce (bounce.in)\",\"Elastic (elastic.in)\"], defaultValue: \"power2.in\" },\n  sequence: { type: ControlType.Enum, title: \"Stagger order\", options: [\"diagonal\",\"radial\",\"row\",\"col\",\"random\"], optionTitles: [\"Diagonal ripple from a corner\",\"Centre outward\",\"Rows, top to bottom\",\"Columns, left to right\",\"Random\"], defaultValue: \"diagonal\" },\n  degrees: { type: ControlType.Number, title: \"Spin per wave\", min: 90, max: 720, step: 90, defaultValue: 360 },\n  duration: { type: ControlType.Number, title: \"Spin duration\", min: 0.3, max: 3, step: 0.1, defaultValue: 1.2 },\n  stagger: { type: ControlType.Number, title: \"Stagger per star\", min: 0, max: 0.15, step: 0.005, defaultValue: 0.03 },\n  rest: { type: ControlType.Number, title: \"Rest between waves\", min: 0, max: 3, step: 0.1, defaultValue: 0.5 },\n  tile: { type: ControlType.Number, title: \"Tile size\", min: 28, max: 160, step: 1, defaultValue: 72 },\n  petal: { type: ControlType.Number, title: \"Petal scale\", min: 0.4, max: 1.8, step: 0.05, defaultValue: 1 },\n  angle: { type: ControlType.Number, title: \"Grid angle\", min: 0, max: 360, step: 1, defaultValue: 0 },\n  mode: { type: ControlType.Enum, title: \"Style\", options: [\"solid\",\"wireframe\",\"glow\",\"checker\"], optionTitles: [\"Two-tone solid\",\"Outline\",\"Neon halo\",\"Checker\"], defaultValue: \"solid\" },\n  glow: { type: ControlType.Number, title: \"Glow\", min: 0, max: 30, step: 1, defaultValue: 0 },\n  hover: { type: ControlType.Enum, title: \"Pointer reaction\", options: [\"1\",\"0\"], optionTitles: [\"On\",\"Off\"], defaultValue: \"1\" },\n  palette: { type: ControlType.Enum, title: \"Palette\", options: [\"enrichr\",\"noir\",\"forest\",\"ember\",\"cream\"], optionTitles: [\"Enrichr (cream and lime on ink)\",\"Noir\",\"Forest\",\"Ember\",\"Ink on cream\"], defaultValue: \"enrichr\" },\n  primary: { type: ControlType.Color, title: \"Petals\", defaultValue: \"#fbf8f1\" },\n  secondary: { type: ControlType.Color, title: \"Accent while spinning\", defaultValue: \"#e6ff55\" },\n  background: { type: ControlType.Color, title: \"Background\", defaultValue: \"#0c1e18\" },\n  stroke: { type: ControlType.Color, title: \"Petal outline\", defaultValue: \"#085e3d\" },\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 \"Petal spin matrix\" 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 \"Petal spin matrix\" element from the Enrichr Library: A grid of four-petal stars that spin one after another in staggered waves, with GSAP-style eases, stagger patterns and a pointer halo.\nPage: https://enrichr.dev/elements/petal-spin-matrix.html\nMachine-readable spec: https://enrichr.dev/elements/petal-spin-matrix.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-petal-spin-matrix\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-petal-spin-matrix\"), { ...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. With prefers-reduced-motion it draws one still frame part way through a wave, so the band of turned stars still shows, and it ignores the pointer. Spins are smooth turns, not flashes. The click spin is a pointer extra; nothing needs the keyboard and the canvas adds no tab stop.",
  "performance": "Each star is one Path2D fill and outline; a 1280 by 720 box holds about 600 stars at the default tile size, and the grid is capped near 6,000. Canvas glow is the costly part, so Glow defaults to 0 and only the stars under the pointer glow. In a test at 1280 by 720 with a GPU it held 60 frames a second. The pixel ratio is capped at 2 and the loop pauses off screen or in a hidden tab.",
  "dependencies": [],
  "codepen": "https://codepen.io/Enrichr-Dev/pen/dPvwjwd",
  "source": {
    "markup": "<div class=\"ef-psm\"><canvas class=\"ef-psm__c\" role=\"img\" aria-label=\"A grid of four-petal stars that spin one after another in a slow wave sweeping across the pattern\"></canvas></div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-psm { position: relative; width: 100%; min-height: 24rem; overflow: hidden; border-radius: 1rem; background: #0c1e18; touch-action: pan-y; }\n.ef-psm .ef-psm__c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Petal spin matrix: a grid of four-petal stars (one vector motif drawn on a canvas) that spin in staggered waves. It\n// re-creates a GSAP timeline by hand: every star gets a delay from its place in the grid (diagonal ripple, centre outward,\n// rows, columns or random) times the stagger interval times the number of stars, then turns by the spin angle over the spin\n// duration on a GSAP-style ease (power1-4.in, back.in, circ.in, expo.in, bounce.in, elastic.in use GSAP's own formulas).\n// The timeline repeats after a rest, snapping each star back to its start angle, which looks the same because the star has\n// four-fold symmetry. While a star turns its colour slides from the primary toward the accent. Near the pointer stars grow,\n// fatten and glow; a click spins the stars around that point at once. Changing a timing setting restarts the wave.\n// Reduced motion draws one still frame partway through the first wave and ignores the pointer. The loop pauses off screen\n// and in hidden tabs.\n// mount(root, { ease, sequence (stagger pattern), degrees (spin per wave), duration (s), stagger (s per star), rest (s),\n//               tile (px), petal (petal scale), angle (grid angle, deg), mode (solid, wireframe, glow, checker), glow (px),\n//               hover (1 on, 0 off), palette, primary, secondary (accent while spinning), background, stroke })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-psm\");\n  var canvas = root.querySelector(\".ef-psm__c\");\n  var ctx = canvas.getContext(\"2d\");\n  // the quad-petal motif from the original pen, drawn in a 480 x 480 box centred on (240, 240)\n  var MOTIF = new Path2D(\"M70.9 69.7 69.7 71a85.2 85.2 0 0 0 43.6 143.8L240 240l-25.4-126.7A85.2 85.2 0 0 0 71 69.7ZM69.7 409.1l1.2 1.2a85.2 85.2 0 0 0 143.8-43.6L240 240l-126.7 25.3a85.2 85.2 0 0 0-43.6 143.8ZM410.3 70.9l-1.2-1.2a85.2 85.2 0 0 0-143.8 43.6L240 240l126.7-25.4A85.2 85.2 0 0 0 410.3 71ZM366.7 265.4 240 240l25.4 126.7A85.2 85.2 0 0 0 409 410.3l1.2-1.2a85.2 85.2 0 0 0-43.6-143.7Z\");\n  var MAX_TILES = 6000;\n\n  // GSAP 3 ease formulas (\"in\" versions are 1 - out(1 - p) where GSAP defines them that way)\n  function bounceOut(p) {\n    var n = 7.5625, c = 2.75, n1 = 1 / c;\n    return p < n1 ? n * p * p : p < 2 * n1 ? n * Math.pow(p - 1.5 / c, 2) + 0.75 : p < 2.5 * n1 ? n * Math.pow(p - 2.25 / c, 2) + 0.9375 : n * Math.pow(p - 2.625 / c, 2) + 0.984375;\n  }\n  var EP = 2 * Math.PI / 0.3, ES = 0.3 / (2 * Math.PI) * Math.asin(1); // elastic: amplitude 1, period 0.3\n  function elasticOut(p) { return p === 1 ? 1 : Math.pow(2, -10 * p) * Math.sin((p - ES) * EP) + 1; }\n  function backOut(p) { var s = 1.70158; return p ? ((--p) * p * ((s + 1) * p + s) + 1) : 0; }\n  var EASES = {\n    \"power1.in\": function (p) { return p * p; },\n    \"power2.in\": function (p) { return p * p * p; },\n    \"power3.in\": function (p) { return p * p * p * p; },\n    \"power4.in\": function (p) { return p * p * p * p * p; },\n    \"back.in\": function (p) { return 1 - backOut(1 - p); },\n    \"circ.in\": function (p) { return -(Math.sqrt(1 - p * p) - 1); },\n    \"expo.in\": function (p) { return p ? Math.pow(2, 10 * (p - 1)) : 0; },\n    \"bounce.in\": function (p) { return 1 - bounceOut(1 - p); },\n    \"elastic.in\": function (p) { return 1 - elasticOut(1 - p); }\n  };\n  var PALETTES = {\n    enrichr: { primary: \"#fbf8f1\", secondary: \"#e6ff55\", background: \"#0c1e18\", stroke: \"#085e3d\" },\n    noir: { primary: \"#fbf8f1\", secondary: \"#d9d3c4\", background: \"#050d0a\", stroke: \"#0c1e18\" },\n    forest: { primary: \"#1a7a4c\", secondary: \"#e6ff55\", background: \"#050d0a\", stroke: \"#003d28\" },\n    ember: { primary: \"#e54c1e\", secondary: \"#fbf8f1\", background: \"#0c1e18\", stroke: \"#050d0a\" },\n    cream: { primary: \"#0c1e18\", secondary: \"#4b1a9a\", background: \"#fbf8f1\", stroke: \"#e4ddcc\" }\n  };\n  var COLOR_KEYS = [\"primary\", \"secondary\", \"background\", \"stroke\"];\n  var DEF = { ease: \"power2.in\", sequence: \"diagonal\", degrees: 360, duration: 1.2, stagger: 0.03, rest: 0.5, tile: 72, petal: 1, angle: 0,\n    mode: \"solid\", glow: 0, hover: 1, palette: \"enrichr\", primary: \"#fbf8f1\", secondary: \"#e6ff55\", background: \"#0c1e18\", stroke: \"#085e3d\" };\n\n  var opts = {}, col = {}, custom = {}, mounted = false;\n  var raf = 0, visible = true, io = null, ro = null, destroyed = false, last = 0;\n  var W = 0, H = 0, dpr = 1, S = 72, tiles = [], tl = null, spins = [];\n  var mouse = { x: -1000, y: -1000, active: false };\n\n  function num(v, d) { v = Number(v); return isFinite(v) ? v : d; }\n  function rgb(h) { var m = /^#?([0-9a-f]{6})$/i.exec(h || \"\"); var v = parseInt(m ? m[1] : \"000000\", 16); return [v >> 16, (v >> 8) & 255, v & 255]; }\n  function mixColor(a, b, f) {\n    f = Math.max(0, Math.min(1, f));\n    return \"rgb(\" + Math.round(a[0] + f * (b[0] - a[0])) + \", \" + Math.round(a[1] + f * (b[1] - a[1])) + \", \" + Math.round(a[2] + f * (b[2] - a[2])) + \")\";\n  }\n\n  // grid: square, as wide as the box diagonal plus four spare tiles, centred, so a rotated grid still covers every corner\n  function build() {\n    S = opts.tile;\n    var diag = Math.hypot(W, H), n = Math.ceil(diag / S) + 4;\n    while (n * n > MAX_TILES) { S *= 1.05; n = Math.ceil(diag / S) + 4; }\n    var rows = n, cols = n, startX = W / 2 - cols * S / 2, startY = H / 2 - rows * S / 2, maxDiag = Math.hypot(cols, rows), seq = opts.sequence;\n    tiles = [];\n    for (var r = 0; r < rows; r++) {\n      for (var c = 0; c < cols; c++) {\n        var f = 0;\n        if (seq === \"radial\") f = Math.hypot(r - rows / 2, c - cols / 2) / (maxDiag / 2);\n        else if (seq === \"row\") f = r / rows;\n        else if (seq === \"col\") f = c / cols;\n        else if (seq === \"random\") f = Math.random();\n        else f = (c + r) / (cols + rows);\n        tiles.push({ r: r, c: c, cx: startX + c * S + S / 2, cy: startY + r * S + S / 2, rotation: 0, factor: f, delay: 0, from: null, to: 0 });\n      }\n    }\n    trigger();\n  }\n\n  // a fresh timeline: every star tweens from where it is now to (its angle now + degrees) after its own delay\n  function trigger() {\n    spins = [];\n    var total = 0, stag = opts.stagger * tiles.length;\n    for (var i = 0; i < tiles.length; i++) {\n      var t = tiles[i];\n      t.delay = t.factor * stag; t.from = null; t.to = t.rotation + opts.degrees;\n      if (t.delay + opts.duration > total) total = t.delay + opts.duration;\n    }\n    tl = { time: 0, local: -1e-4, iter: 0, total: total, cycle: Math.max(0.001, total + opts.rest), dur: Math.max(0.001, opts.duration), ease: EASES[opts.ease] || EASES[\"power2.in\"] };\n  }\n  // the playhead moved from a to b: render every tween it touched (started, running, or just finished)\n  function renderRange(a, b) {\n    if (b <= a) return;\n    for (var i = 0; i < tiles.length; i++) {\n      var t = tiles[i], s = t.delay;\n      if (b < s || a >= s + tl.dur) continue;\n      if (t.from === null) t.from = t.rotation;\n      var p = (b - s) / tl.dur; p = p > 1 ? 1 : p;\n      t.rotation = t.from + (t.to - t.from) * tl.ease(p);\n    }\n  }\n  function step(dt) {\n    tl.time += dt;\n    var iter = Math.floor(tl.time / tl.cycle), local = Math.min(tl.time - iter * tl.cycle, tl.total);\n    if (iter !== tl.iter) {\n      renderRange(tl.local, tl.total); // finish the pass\n      for (var i = 0; i < tiles.length; i++) if (tiles[i].from !== null) tiles[i].rotation = tiles[i].from; // repeat: back to the start\n      tl.iter = iter; tl.local = -1e-4;\n    }\n    renderRange(tl.local, local);\n    tl.local = local;\n    // clicked stars: separate tweens that run on top of the timeline, like gsap.to() calls\n    for (var j = spins.length - 1, k; j >= 0; j--) {\n      k = spins[j]; k.t += dt;\n      if (k.from === null) k.from = k.tile.rotation;\n      var q = Math.min(1, k.t / k.dur);\n      k.tile.rotation = k.from + (k.to - k.from) * k.ease(q);\n      if (q >= 1) spins.splice(j, 1);\n    }\n  }\n\n  function motif(cx, cy, size, dist, rot, fill, stroke, width) {\n    ctx.save();\n    ctx.translate(cx, cy);\n    ctx.rotate(rot * Math.PI / 180);\n    var s = size / 480 * dist;\n    ctx.scale(s, s);\n    ctx.translate(-240, -240);\n    if (fill) { ctx.fillStyle = fill; ctx.fill(MOTIF); }\n    if (stroke) { ctx.strokeStyle = stroke; ctx.lineWidth = width / s; ctx.stroke(MOTIF); }\n    ctx.restore();\n  }\n\n  function draw() {\n    var cx = W / 2, cy = H / 2, ga = opts.angle * Math.PI / 180, ca = Math.cos(ga), sa = Math.sin(ga);\n    var c1 = rgb(col.primary), c2 = rgb(col.secondary), live = !reduce && opts.hover && mouse.active, mode = opts.mode;\n    var strokeOn = col.stroke.toLowerCase() !== col.background.toLowerCase() ? col.stroke : null;\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    ctx.shadowBlur = 0;\n    ctx.fillStyle = col.background;\n    ctx.fillRect(0, 0, W, H);\n    ctx.save();\n    ctx.translate(cx, cy); ctx.rotate(ga); ctx.translate(-cx, -cy);\n    for (var i = 0; i < tiles.length; i++) {\n      var t = tiles[i], hb = 0;\n      if (live) {\n        var dx = t.cx - cx, dy = t.cy - cy;\n        var d = Math.hypot(cx + dx * ca - dy * sa - mouse.x, cy + dx * sa + dy * ca - mouse.y);\n        if (d < 180) hb = Math.pow(1 - d / 180, 2);\n      }\n      var size = S * (1 + hb * 0.25), dist = opts.petal * (1 + hb * 0.3);\n      var color = mixColor(c1, c2, Math.abs((t.rotation % 360) / 360 * 0.8 + hb * 0.4));\n      if (opts.glow > 0 || hb > 0) { ctx.shadowColor = color; ctx.shadowBlur = (opts.glow + hb * 20) * dpr; }\n      else ctx.shadowBlur = 0;\n      if (mode === \"wireframe\") motif(t.cx, t.cy, size, dist, t.rotation, null, color, 2);\n      else if (mode === \"glow\") {\n        motif(t.cx, t.cy, size, dist, t.rotation, null, color, 3);\n        motif(t.cx, t.cy, size * 0.5, dist, -t.rotation, col.secondary, null, 0);\n      } else if (mode === \"checker\") motif(t.cx, t.cy, size, dist, t.rotation, (t.c + t.r) % 2 === 0 ? color : col.secondary, null, 0);\n      else motif(t.cx, t.cy, size, dist, t.rotation, color, strokeOn, 1);\n    }\n    ctx.restore();\n    ctx.shadowBlur = 0;\n  }\n\n  // reduced motion: one still frame 40% of the way through the first wave, so the spinning band still shows\n  function still() {\n    if (!tl) return;\n    var at = tl.total * 0.4;\n    for (var i = 0; i < tiles.length; i++) {\n      var t = tiles[i], p = (at - t.delay) / tl.dur;\n      p = p <= 0 ? 0 : p >= 1 ? 1 : p;\n      t.rotation = p > 0 ? t.to * tl.ease(p) : 0;\n    }\n    draw();\n  }\n\n  function loop(now) {\n    raf = requestAnimationFrame(loop);\n    var dt = (now - last) / 1000 || 0; last = now;\n    if (dt > 0.5) dt = 0.033; // like GSAP's lag smoothing: a long stall resumes instead of jumping\n    if (!visible || document.hidden || !tl) return;\n    step(dt);\n    draw();\n  }\n\n  function size() {\n    var w = wrap.clientWidth, h = wrap.clientHeight, nd = Math.min(window.devicePixelRatio || 1, 2);\n    if (w === W && h === H && nd === dpr && tiles.length) return;\n    var rebuild = w !== W || h !== H || !tiles.length;\n    W = Math.max(1, w); H = Math.max(1, h); dpr = nd;\n    canvas.width = Math.round(W * dpr); canvas.height = Math.round(H * dpr);\n    if (rebuild) build();\n    if (reduce) still(); else draw();\n  }\n\n  function point(e) { var r = wrap.getBoundingClientRect(); return { x: e.clientX - r.left, y: e.clientY - r.top }; }\n  function onMove(e) { var p = point(e); mouse.x = p.x; mouse.y = p.y; mouse.active = true; }\n  function onLeave() { mouse.active = false; }\n  function onClick(e) {\n    if (reduce) return;\n    var p = point(e), cx = W / 2, cy = H / 2, ga = opts.angle * Math.PI / 180, ca = Math.cos(ga), sa = Math.sin(ga);\n    for (var i = 0; i < tiles.length; i++) {\n      var t = tiles[i], dx = t.cx - cx, dy = t.cy - cy;\n      if (Math.hypot(cx + dx * ca - dy * sa - p.x, cy + dx * sa + dy * ca - p.y) < opts.tile * 1.5) {\n        spins.push({ tile: t, from: null, to: t.rotation + opts.degrees, t: 0, dur: Math.max(0.001, opts.duration), ease: EASES[opts.ease] || EASES[\"power2.in\"] });\n      }\n    }\n  }\n\n  function update(partial) {\n    partial = partial || {};\n    var prev = opts;\n    opts = Object.assign({}, DEF, opts, partial);\n    opts.degrees = num(opts.degrees, 360); opts.duration = Math.max(0.05, num(opts.duration, 1.2));\n    opts.stagger = Math.max(0, num(opts.stagger, 0.03)); opts.rest = Math.max(0, num(opts.rest, 0.5));\n    opts.tile = Math.max(12, num(opts.tile, 72)); opts.petal = num(opts.petal, 1); opts.angle = num(opts.angle, 0);\n    opts.glow = Math.max(0, num(opts.glow, 0)); opts.hover = String(opts.hover) === \"1\" || opts.hover === true;\n    // colours: the palette sets all four; a colour you pick yourself wins for that role\n    if (!mounted) { COLOR_KEYS.forEach(function (k) { custom[k] = partial[k] != null && String(partial[k]).toLowerCase() !== DEF[k]; }); }\n    else {\n      if (\"palette\" in partial) custom = {};\n      COLOR_KEYS.forEach(function (k) { if (k in partial) custom[k] = true; });\n    }\n    var pal = PALETTES[opts.palette] || PALETTES.enrichr;\n    COLOR_KEYS.forEach(function (k) { col[k] = custom[k] ? String(opts[k]) : pal[k]; });\n    wrap.style.background = col.background;\n    if (destroyed || !mounted) return;\n    if (prev.tile !== opts.tile || prev.sequence !== opts.sequence) build();\n    else if (prev.ease !== opts.ease || prev.degrees !== opts.degrees || prev.duration !== opts.duration || prev.stagger !== opts.stagger || prev.rest !== opts.rest) trigger();\n    if (reduce) still(); else draw();\n  }\n\n  update(o);\n  mounted = true;\n  size();\n  wrap.addEventListener(\"pointermove\", onMove);\n  wrap.addEventListener(\"pointerleave\", onLeave);\n  wrap.addEventListener(\"pointercancel\", onLeave);\n  wrap.addEventListener(\"click\", onClick);\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) size(); }); ro.observe(wrap); }\n  return {\n    update: update,\n    destroy: function () {\n      destroyed = true; cancelAnimationFrame(raf);\n      wrap.removeEventListener(\"pointermove\", onMove);\n      wrap.removeEventListener(\"pointerleave\", onLeave);\n      wrap.removeEventListener(\"pointercancel\", onLeave);\n      wrap.removeEventListener(\"click\", onClick);\n      if (io) io.disconnect();\n      if (ro) ro.disconnect();\n      tiles = []; spins = [];\n    }\n  };\n}"
  }
}