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

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

One HTML file. Save it and open it in any browser.Open full screen

Example: Constellation Drift, a cursor-reactive particle network hero.

Glowing dots drift across a navy sky and link up when they come close. Move your mouse or drag a finger to pull nearby stars into a cluster, and click or tap to scatter them in a soft burst. The panel's sliders change density, link distance, hue and speed live. Press Space to pause and R to reshuffle. Try a hue around 320 with a long link distance for a neon web.

Written by AI from this prompt. Your results will vary.

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 in Animations & Effects