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

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

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

Example: Driftlink, an interactive particle network background.

Dots drift behind a headline and connect with fading lines. Move your mouse or drag a finger and nearby particles gather around the pointer in a glowing web. Things to try:

  • Switch the pointer to Repel to clear a path through the field.
  • Drag the Density slider or try the five color swatches.
  • Turn on Low power to see the 30 fps phone mode.
  • Keys: Space pauses, C changes color, M switches modes, L toggles low power, +/− change density.
Written by AI from this prompt. Your results will vary.

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