active
Canvas Particle System
Safe
HTML5 Canvas particle fountain with gravity, color palettes, and fade trails. Beginner-friendly visual demo.
@api/canvas-particle-system
gamedev
canvas
visual
particles
beginner
Canvas Particle System
Difficulty: Beginner | Runtime: HTML5 Canvas | Output: Visual animation
Teach an AI agent to generate a colorful particle fountain with gravity, fade trails, and configurable color palettes using the HTML5 Canvas API.
What You'll Build
A self-contained HTML file that renders an animated particle system:
- Particles spray upward from the bottom center of the canvas
- Gravity pulls particles back down in natural arcs
- Each particle has a random color from a curated palette
- Particles fade out as they age, creating trailing effects
- The system runs at 60fps using
requestAnimationFrame
Core Concepts
1. Particle Data Structure
Each particle tracks position, velocity, age, and color:
javascript
{
x: number, // horizontal position
y: number, // vertical position
vx: number, // horizontal velocity
vy: number, // vertical velocity
life: number, // remaining life (0-1)
color: string, // HSL color string
size: number // radius in pixels
}
2. Physics Update Loop
Every frame:
- Emit new particles at the source point
- Update each particle's position:
x += vx,y += vy - Apply gravity:
vy += GRAVITY - Age particles:
life -= decay - Remove dead particles (
life <= 0) - Render each particle as a filled circle with alpha = life
3. Color Palettes
Use HSL color space for vibrant, varied particles:
- Fire: hues 0-60 (red → yellow)
- Ocean: hues 180-240 (cyan → blue)
- Forest: hues 90-150 (green spectrum)
- Rainbow: random hue 0-360
Instructions
- Create an HTML file with a full-viewport
<canvas> - Set up the animation loop with
requestAnimationFrame - Implement the particle emitter at bottom-center
- Add gravity and fade effects
- Use semi-transparent background fills for trail effects
Parameters
| Parameter | Default | Description |
|---|---|---|
PARTICLE_COUNT | 5 | Particles emitted per frame |
GRAVITY | 0.15 | Downward acceleration |
SPEED | 4 | Initial velocity magnitude |
DECAY | 0.012 | Life reduction per frame |
TRAIL_ALPHA | 0.08 | Background clear opacity (lower = longer trails) |
Dormant$0/mo
$20 more to next tier
Created by
Info
Created February 11, 2026
Version 1.0.0
User-invoked
HTML sandbox
Demo
Interactive sandbox
Embed
Add this skill card to any webpage.
<iframe src="https://skillslap.com/skill/428c22af-467c-4b0c-9b47-bc40e2e667d0/embed"
width="400" height="200"
style="border:none;border-radius:12px;"
title="SkillSlap Skill: Canvas Particle System">
</iframe>