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.
You getone complete HTML file in a single code block, then 3 short ideas to extend it.
The prompt
Act as a senior front-end developer and motion designer. Build "Driftlink", an interactive particle background for a landing page. It is a full-window canvas of softly drifting dots over a deep navy gradient, with a short centered headline and subtitle on top. Particles connect to nearby particles with thin lines that fade with distance. Lines near the pointer glow brighter, and extra lines join the pointer to every particle within reach.
Rules:
1. Mouse and touch both steer the field. Particles either move toward the pointer, keeping a small empty ring so they do not clump, or move away from it. A button and the M key switch between the two.
2. A bottom control bar holds a density slider (20-100%), five color theme swatches that also recolor the UI accent, a Low power toggle, a Pause button, and a live particle and fps readout.
3. Low power mode caps particles at 70, renders at 30 fps, uses a 1x pixel ratio and skips the pointer glow. Turn it on automatically on small touch screens and when prefers-reduced-motion is set, which also slows the drift.
4. Particle count scales with screen area. The canvas resizes sharply with the window and devicePixelRatio.
5. Keyboard: Space pauses, C cycles color, L toggles low power, and plus and minus change density. All buttons have visible focus rings and aria-pressed states.
6. Use plain canvas 2D only, with no libraries, and wrap the script in an IIFE.
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
- Sets exact limits for low power (70 particles, 30 fps, 1x pixel ratio) so the result runs smoothly on phones the first time.
- Asks for an empty ring around the pointer, which stops particles from collapsing into one blob when they are pulled in.
- Ties density to screen area and resizes with devicePixelRatio, so the canvas looks sharp and evenly filled at any frame width.
Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as driftlink.html and open it in any browser, or view it in the chat's preview or canvas panel.
Common edits
- Change the theme colors or the headline text to match your own site, then drop the canvas behind a real hero section.
- Make the link distance or the pointer radius bigger for a denser web, or lower the speed for a calmer background.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
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.
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.