--- name: algorithmic-art description: Turns a visual idea into a seeded, self-contained generative art piece written in p5.js, with a few live controls and a way to page through variations. Use when a user says "make generative art", "code me a flow field", "give me an abstract background I can regenerate", "particle animation for my site", or wants a one-of-a-kind visual rather than a stock image. --- # Algorithmic Art Writes original generative artwork as code. The result is a single HTML file that draws with p5.js, produces the same picture from the same seed, and lets the user explore variations without asking you again. ## When to use this - The user wants a distinctive background, poster, cover, badge or loop that no one else will have. - The user describes a mood, a subject or a natural process (wind, coral, constellations, erosion) and wants it drawn by an algorithm. - The user wants to browse several directions before committing to one. Do not use it for photo editing, logos that must be exact, or illustrations that need recognizable figures. ## Procedure 1. **Ask four quick questions**, or infer them if the user already answered: where it will be used, the canvas size or ratio, whether it should be still or animated, and any colors or moods to avoid. Default to a 1600 by 1000 still if the user has no preference. 2. **Write a three-sentence concept before any code.** Name the process (for example "thousands of particles following a slowly rotating field"), the visual result, and what makes it feel like the idea rather than generic noise. If the user wanted options, write three concepts that differ in structure, not just color, and wait for a pick. 3. **Choose a palette of 3 to 5 colors** with a background, one dominant color and one accent. Write the hex values into a `PALETTE` constant. Avoid pure black on pure white unless the concept demands it. 4. **Make everything deterministic.** Hold a `seed` value and call `randomSeed(seed)` and `noiseSeed(seed)` at the start of every draw. Never call `Math.random()`. The same seed must always give the same image. 5. **Expose 3 to 5 parameters** as named constants in one `params` object at the top (density, scale, speed, line weight, turbulence). Pick ranges that stay attractive at both ends, and test the extremes in your head: nothing should blank the canvas or freeze the browser. 6. **Write the sketch.** Load p5.js from a CDN script tag with a pinned version. Include setup, a `generate()` function that rebuilds the piece from the seed and params, and a `draw()` loop (or `noLoop()` for stills). Prefer layered passes: a quiet background layer, the main structure, then small details. Cap total elements so frames stay near 60 per second. 7. **Add a small control strip** in plain HTML: previous and next seed buttons, a random seed button, a row of sliders bound to `params`, and a save-image button that calls `saveCanvas`. Show the current seed number so the user can write down favorites. 8. **Review the result against the concept.** Ask: does it read as the idea within two seconds? Is there a focal area and some empty space? Does the accent color stay rare? Fix the weakest of those, then deliver. 9. **Offer a refinement round.** Suggest two specific changes, such as slowing the motion or reducing density near the edges, rather than asking an open question. ## Output format - One complete HTML file in a single code block, ready to save and open in a browser. - Before the code: the concept (three sentences) and the palette. - After the code: how to use the controls, three seeds worth trying, and the two suggested refinements. ## Guardrails - Write the algorithm fresh for each request; do not paste a stock snippet unchanged. - Keep the file self-contained apart from the p5.js script tag. No external images or fonts. - Do not imitate a living artist's signature style or a named brand's artwork. - If the user cannot run HTML, offer an SVG export or describe how to open the file. - Warn the user when a setting is heavy on older laptops, and provide a lower-density default. ## Quality checks Before sending, confirm each of these: - Changing only the seed changes the picture, and returning to a seed restores it exactly. - At the lowest and highest slider values the canvas still shows something intentional. - The piece still reads at thumbnail size and at full screen. - Colors come only from `PALETTE`; no stray default fills or strokes. - The save button produces an image at the requested size, not the window size. - The first frame looks finished, so a screenshot taken immediately is usable.