Build an Interactive Particle Network Background with Live Controls in HTML
A prompt that produces one HTML file with a cursor-reactive canvas particle network and live sliders for density, link distance, color and speed.
The prompt
Act as a senior front-end developer who specializes in canvas animation. Build "Constellation Drift", a full-screen interactive particle network background for a landing page hero. Small glowing dots drift slowly across a dark navy canvas. Any two dots closer than the link distance are joined by a thin line that fades with distance. Dots near the cursor or a finger are gently pulled toward it and linked to it. Rules: 1) Add a compact floating control panel with labeled range sliders for density, link distance, color hue and speed, each showing its live value. Include a Pause/Play button with aria-pressed, a Shuffle button and a Hide toggle that collapses the panel. 2) Scale the particle count with screen area, reduce it on screens narrower than 600px, cap it for performance, and show the live count in the panel. 3) Support mouse, touch and keyboard: pointer movement attracts, a click or tap sends a soft burst outward, Space pauses and R reshuffles. 4) Keep the canvas sharp on high-DPI screens with the pixel ratio capped at 2, and rebuild it on window resize. 5) Use a small palette: dark navy background, off-white text, and one accent hue driven by the color slider. Overlay a short hero headline and one line of copy with readable contrast. 6) Respect prefers-reduced-motion with slower drift and no burst. Use no external libraries, fonts or storage. Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.Example output
Tips and common edits
Why this works
- Tying particle count to screen area, with a hard cap, keeps the pairwise line drawing fast on both phones and wide monitors.
- Clamping devicePixelRatio and rebuilding on resize gives crisp lines without overloading high-DPI screens.
- Requiring live value labels, aria-pressed and keyboard shortcuts makes the controls usable and testable straight away.
Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as an .html file and open it in any browser, or run it in the chat's preview or canvas panel.
Common edits
- Change the default hue and background color to match your brand, or swap attraction for repulsion by flipping the force sign.
- Lower the density cap or the link distance for a calmer effect, or add a slider for dot size.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Build an Interactive Particle Network Background With Mouse and Touch Controls
A single HTML file with a full-screen canvas particle network that links nearby dots, reacts to mouse and touch, and has density, color and low-power controls.
Build a Confetti and Fireworks Celebration Effect in a Single HTML File
A ready-to-paste prompt that builds a reusable canvas confetti and fireworks layer with color theme presets, burst size control, Web Audio pops and automatic particle cleanup.
Build a Click-to-Launch Fireworks Celebration Animation in One HTML File
A prompt that produces a single HTML page where clicks, taps or keys launch fireworks with gravity, fading trails, soft synthesized pops and a mute toggle.
Build an Animated Dawn-to-Night Landscape Scene in a Single HTML File
You get one HTML file that draws a canvas valley village whose sky, sun, moon, stars, clouds and window lights all follow a single time-of-day scrubber with autoplay.
Build an Animated SVG World Clock with Sweeping Hands and Five Time Zones
A single HTML file with a crisp SVG analog clock whose hands glide continuously and ease smoothly between five world cities, each with a labeled UTC offset.
Build a Parallax Starfield Night Sky Hero Section on Canvas in One HTML File
A prompt that produces a single HTML hero section with a three-layer canvas starfield, pointer and tilt parallax, shooting stars, a density slider and a calm mode.