Build a Canvas Cursor Trail Effects Playground with Four Styles in One HTML File

Produces a single HTML page with a canvas cursor trail that switches between comet, sparkle, ink and ribbon styles, with touch support, a particle cap and an off switch for reduced motion.

You getFull HTML in one code block, table and risks and next actions

The prompt

Prompt
Role: You are a creative front-end developer who builds lightweight canvas effects for marketing sites.Context: Northlight Studio portfolio (example value for {site_name}) wants a cursor trail effect. The job to be done is to let the team compare styles and choose one that feels on-brand without hurting readability or performance.

Inputs:
- Site: Northlight Studio portfolio (example value for {site_name})
- Default trail style: comet (example value for {trail_style})
- Accent colors: #FF6B6B, #FFD93D, #6BCBFF (example value for {accent_colors})
- Maximum live particles: 250 (example value for {max_particles})
List any assumptions separately under Assumptions.

Task: Build ONE self-contained HTML file with a full-viewport canvas behind a short sample hero text. No libraries or external assets.

Workflow:
1. Track pointer movement with pointermove, including touch, and interpolate between events so fast moves leave no gaps.
2. Implement four styles: comet (fading tail), sparkle (small stars with drift and twinkle), ink (width varies with speed), ribbon (smooth curve through the last 20 points).
3. Add a small control panel: style selector, color swatches from #FF6B6B, #FFD93D, #6BCBFF (example value for {accent_colors}), size slider, fade-length slider, and a Trail on/off toggle.
4. Use requestAnimationFrame with delta time, pool particles instead of allocating new ones, and enforce the 250 (example value for {max_particles}) cap.
5. Handle devicePixelRatio and window resize without blurring.

Constraints:
- Canvas has pointer-events: none so links and buttons stay clickable.
- If prefers-reduced-motion is set, start with the trail off.
- Pause the loop when the tab is hidden or nothing is alive.
- No more than 300 lines; comment each style function in one line.

Output format:
1. Assumptions
2. Full HTML in one code block
3. Table: style, feel, relative cost (low/medium/high), best use
4. Risks and next actions (for example contrast over text, low-end phones)

Acceptance criteria:
- Moving the mouse produces a trail within one frame.
- Switching styles clears the old trail cleanly.
- Particle count never exceeds the cap.
- Hero text stays readable and clickable.

Quality checks: Confirm there is no memory growth over time, the loop idles when nothing is drawn, DPR scaling is correct, and every {variable} is used. Tool note: in Claude, return a single HTML artifact; in ChatGPT, one code block; in Gemini, avoid external CDN links; in Cursor, create index.html only.

Dashed parts are example values, so the prompt runs as copied. Change them in Fill in the blanks.

Good for portfolio and campaign pages. Compare the four styles on a real device, then ask the model to strip the unused ones to cut the file size. Avoid heavy trails on pages with dense body text.

Make it repeatable

Keep using this prompt without pasting it in every time.

Keep exploring

More in Animations & Effects