Skip to content
Founding Lifetime: every Pro skillfirst 100 members · $169 onceUpgrade
Lookbk
Sign In
Effect guide

Fireflies animation for a website

Small glowing points that drift, blink on their own rhythm and slowly fall into step. How a fireflies animation works, a canvas starter you can paste and run, and the skill that builds a full meadow at dusk.

Free skills to start. Pro is $79 a year for every skill, or $9.99 a month for 10. See pricing

What is a fireflies animation?

A fireflies animation is a dark scene with tiny warm lights that wander and blink. It is calm by nature, so it suits sleep, wellness, nature, summer events, children’s products and anything that wants to feel gentle and a little magical.

What makes it convincing is the blinking, not the movement. Real fireflies glow for a moment and then go dark for longer, each on its own timing, and some species gradually fall into sync until whole fields flash together. Copying that rhythm is what separates fireflies from generic floating particles.

How the effect works

Each firefly has a position, a slow wandering direction and a blink phase. Move it a little each frame and turn its heading by a small random amount, so it meanders instead of flying straight. Draw it as a small bright core with a large soft glow, using additive blending so glows add up.

Give each one a phase that runs from 0 to 1 over a few seconds, lit only for a short part of the cycle. To make them sync, nudge every firefly’s phase a little toward its neighbors’ each time one of them flashes; over a minute the field drifts into waves of light.

  1. 01

    Wander, do not fly

    Speed of a few pixels per second, with the heading turning a little at random every frame.

  2. 02

    Draw core and glow

    A 1–2 px core and a radial-gradient glow 10–20 times wider, both with additive blending.

  3. 03

    Blink briefly

    Lit for around 15% of each cycle, with a fast rise and a slower fade.

  4. 04

    Pull phases together

    For a synchronized flash, move each phase slightly toward the average every cycle.

HTML

A canvas fireflies animation in plain JavaScript

Forty fireflies that wander, blink and slowly fall into sync, drawn with additive glow. Set SYNC to 0 to keep them out of step.

<canvas id="flies" style="position:fixed;inset:0;width:100%;height:100%;background:#081018"></canvas>
<script>
const canvas = document.getElementById('flies')
const g = canvas.getContext('2d')
const N = 40, PERIOD = 3, SYNC = 0.02
const still = matchMedia('(prefers-reduced-motion: reduce)').matches
let w, h, dpr
function size() {
  dpr = Math.min(devicePixelRatio, 2)
  w = canvas.width = innerWidth * dpr
  h = canvas.height = innerHeight * dpr
}
size(); addEventListener('resize', size)
const flies = Array.from({ length: N }, () => ({
  x: Math.random() * w, y: h * (0.3 + Math.random() * 0.7),
  a: Math.random() * 6.28, phase: Math.random(),
}))
let last = performance.now()
function glow(f) {
  const t = f.phase < 0.15 ? Math.sin((f.phase / 0.15) * Math.PI) : 0
  return still ? 0.6 : t
}
function frame(now) {
  const dt = Math.min(0.05, (now - last) / 1000); last = now
  g.globalCompositeOperation = 'source-over'
  g.fillStyle = '#081018'; g.fillRect(0, 0, w, h)
  g.globalCompositeOperation = 'lighter'
  const mean = Math.atan2(
    flies.reduce((s, f) => s + Math.sin(f.phase * 6.28), 0),
    flies.reduce((s, f) => s + Math.cos(f.phase * 6.28), 0)) / 6.28
  for (const f of flies) {
    if (!still) {
      f.a += (Math.random() - 0.5) * 0.3
      f.x = (f.x + Math.cos(f.a) * 12 * dpr * dt + w) % w
      f.y = Math.min(h, Math.max(h * 0.2, f.y + Math.sin(f.a) * 8 * dpr * dt))
      f.phase = (f.phase + dt / PERIOD + SYNC * dt * Math.sin((mean - f.phase) * 6.28)) % 1
      if (f.phase < 0) f.phase += 1
    }
    const k = glow(f)
    if (k <= 0) continue
    const r = 18 * dpr
    const halo = g.createRadialGradient(f.x, f.y, 0, f.x, f.y, r)
    halo.addColorStop(0, 'rgba(220,255,120,' + 0.9 * k + ')')
    halo.addColorStop(0.15, 'rgba(180,240,90,' + 0.4 * k + ')')
    halo.addColorStop(1, 'rgba(120,200,60,0)')
    g.fillStyle = halo
    g.beginPath(); g.arc(f.x, f.y, r, 0, Math.PI * 2); g.fill()
  }
  if (!still) requestAnimationFrame(frame)
}
requestAnimationFrame(frame)
</script>

A starting point written for this page, free to use in your own projects. The skills below build the finished version with checks, fallbacks and a recorded video.

What to get right on a real page

  1. 01

    Use yellow-green, not white

    Real fireflies glow a warm yellow-green. White points read as stars or dust.

  2. 02

    Keep most of them dark

    If every firefly is lit at once all the time, it looks like particles. Short flashes and long darks look alive.

  3. 03

    Give them a scene

    Grass, a horizon or mist in front of and behind the lights adds depth and keeps them low, where real fireflies fly.

  4. 04

    Hold a still glowing frame for reduced motion

    Respect prefers-reduced-motion: show one finished frame instead of the loop. A visitor who turned motion off still gets the look.

Skills that build a fireflies animation

A finished meadow-at-dusk hero with your colors, fonts, logo and words, and a seamless 1080p loop for launch posts.

  1. Firefly Meadow Hero: an example of what it makes
    web
    Firefly Meadow HeroClaude CodeCodexCursor+3 more agents

    Motion Heroes · Pro

    Firefly Meadow Hero

    Animated canvas hero · page + embed + 1080p video

    A meadow at dusk with an afterglow sky, a full or crescent moon, mist over the far field and four layers of swaying grass with dandelion clocks. Fireflies drift between the grass layers and blink to their own rhythms, then fall into step mid-loop and flash together in waves rolling across the meadow.

    Worth knowing: It is drawn in Canvas 2D on a fixed loop; fireflies do not follow the cursor.

    Needs: Node.js 18+, Chrome (or Chromium/Edge), and ffmpeg for the video

    See what Firefly Meadow Hero makes

Install

Build a fireflies animation with your agent

Each skill is a SKILL.md folder, so it installs the same way in Claude Code, Codex, Cursor and other agents. The example below uses Firefly Meadow Hero; each skill page has its own prompt.

1. Paste the install prompt

Your agent runs the installer. The first time, it shows a sign-in link so you can approve it in the browser.

Install the "Firefly Meadow Hero" skill from Lookbk (https://lookbk.dev/skills/firefly-meadow-hero).
1. Run: curl -fsSL https://lookbk.dev/cli.js | node - add firefly-meadow-hero
2. If it prints a sign-in link, show it to me. When I say I approved it, run the same command again.
3. When the install finishes, read the SKILL.md it installed and tell me what you need from me to make the first result.

Or run it in a terminal

curl -fsSL https://lookbk.dev/cli.js | node - add firefly-meadow-hero

2. Start a new session

Agents load skills when a session starts. The installer writes the folder where your agent looks:

Claude Code
~/.claude/skills/firefly-meadow-hero
Codex
~/.agents/skills/firefly-meadow-hero
Cursor
~/.agents/skills/firefly-meadow-hero

3. Ask for the result

Describe it in plain words, for example:

Build a Firefly Meadow hero for Hushwood, a sleep sounds app: navy sky, teal afterglow, yellow-green fireflies, full moon, headline 'Fall asleep somewhere quieter.', and record a 12-second loop.

Another agent? Install a skill in any agent

FAQ

Questions

Still stuck? The guides cover installing, agents and licensing in more detail.

Read the guides
How do I make a fireflies animation in CSS?

Position a dozen small dots with a box-shadow glow and animate each with its own opacity and translate keyframes, using different durations and delays. It works for a few lights; canvas handles dozens with smoother wandering.

How do synchronized fireflies work?

Each firefly runs its own clock, and when it sees neighbors flash it shifts its clock slightly toward theirs. Applied to every firefly, small nudges add up until they flash together. The starter does the same with the average phase.

Is a fireflies animation heavy on phones?

Forty glowing points on a 2D canvas are light. Cap the device pixel ratio at 2 and pause when the hero is out of view.

Can I get the meadow as a video?

Yes. Firefly Meadow Hero records a seamless 1080p loop for posts and places where scripts are not allowed.