Skip to content
animorio
IT
Back to the library

Bat flock background

Backgrounds, HoverGSAP, Canvas, CSS onlyMediumCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

An animated Halloween background, in the minimal style: the night behind the headline of an invented screening, with a thin moon, a few real bats, dark silhouettes with a hair of moonlight on their edge (membrane wings with fingers, a scalloped edge, ears) flying on soft curves, banking into their turns and swerving away from the pointer, and a pumpkin-coloured mist breathing at the bottom. Canvas 2D, one orange accent.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Bat flock background" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The background of a flock of bats behind the headline</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the night behind the headline of an invented Halloween screening: a thin moon, a flock of bats drawn with two
       lines each that fly together and swerve away from the pointer, and a low pumpkin mist breathing at the bottom -->
  <main class="stage" data-stage>
    <canvas class="sky" data-sky aria-hidden="true"></canvas>
    <span class="mist" data-mist aria-hidden="true"><span class="mist__inner"></span></span>
    <span class="veil" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="kicker" data-in>Hollow Lane Cinema presents</p>
      <h1 class="title" id="hero-title" data-title>Halloween Night</h1>
      <span class="rule" data-rule aria-hidden="true"></span>
      <p class="when" data-in>Saturday 31 October <span class="when__sep" aria-hidden="true"></span> Doors at 9 pm</p>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

18 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Bat flock background” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

The first screen of an invented cinema’s Halloween Night, the Hollow Lane Cinema, under a violet night sky that lightens around the moon. As it opens, the bats fly in from both sides already on the wing, while the letters of the headline rise one after another narrow and light, open on the width axis, go one pixel too far and settle; below it a thin pumpkin-coloured line draws itself. Each bat is a dark, solid violet-black silhouette, set apart from the sky only by a hair of moonlight on the top edge of its wings, its ears and its fur; in front of the moon it turns black, backlit. It is really drawn: a teardrop body with fur at the neck, a head with two tall ears and pumpkin eyes, legs, and membrane wings stretched between four fingers, with the thumb and its claw on the leading edge and a scalloped trailing edge. The wing comes in two pieces: the arm turns from the shoulder and the hand from the wrist, down fast and up more slowly with the hand folding; now and then the wings stay open and the bat glides. With every wingbeat the body rises. Each one flies its own soft curve, banks into the turn and swings wide around the headline; the far ones are smaller, slower, and fainter, and the low ones catch a breath of the orange mist. The pointer makes them swerve away; a click startles the nearby ones, which bank away beating harder, the mist below brightens and the line under the headline gives a small elastic bounce. If nobody touches anything, a gust startles them by itself every so often.

How it works

A real bat, in a canvas

Each wing is a path: from the shoulder to the wrist along the arm, then out to the tip of the first finger and from tip to tip with concave arcs, the scallops, pulled towards the wrist, down to the hip. The membrane is a near-opaque violet black; over it the finger bones, just a little lighter, the thumb with its claw and the wrist. A hair of moonlight runs along the top of the arm and the first finger, strongest at the wrist. The left wing is the right one mirrored.

A beat in two pieces

The arm turns from the shoulder between minus 41 and 33 degrees: down in 38% of the cycle, up in the rest, always on a soft curve. The hand turns from the wrist with a lag: on the way down it is stretched and the fingers open, on the way up it bends down and the fingers close, so the membrane changes shape. A wing seen edge-on at the top and bottom looks a little shorter. The body rises with every beat.

Flight on soft curves

Each bat chases its own slow point, two sines per axis at frequencies that never line up. The heading never snaps: the turn rate is limited and smoothed, so the path is always a curve; the bank follows the turn. Diving it flies faster, climbing it beats faster, and it glides mostly on the way down.

The headline is a calm hole

Around the headline there is an ellipse measured on the real text: whoever comes close is steered outwards, and a little room is kept between bats, so they never fly through each other and the words stay readable.

Depth

The first three are near and big, the others further away: smaller, slower, just melting into the sky’s haze. Near the moon the rim of light brightens and the silhouette turns black, backlit; the low ones catch a hair of the mist’s orange on their lower edge. The sky is a violet night that lightens around the moon, so the silhouettes always read.

Values to change

NameFileDefaultWhat it changes
BATSscript.js9Bats on a computer (fewer on a phone, in proportion).
SPEEDscript.js1Flight speed (2 twice as fast).
FLAPscript.js1Wingbeat speed (2 twice as fast).
SIZEscript.js1Size of the bats.
FLEEscript.js150How far they swerve from the pointer, in pixels (0 never).
MISTscript.js1How bright the pumpkin mist is (0 off).

Try them in the Playground

When to use it

For the page of a Halloween party, screening or sale, the cover of a night event, a shop dressing up for 31 October: when you want the mood without cartoon scenes or clip art.

On phones

Same animations: there are fewer bats, in proportion to the space, sized on the screen’s short side; the headline is sized on the height too and fits in the box; a finger makes them swerve and a tap scatters them.

With reduced motion

With reduced motion the flock is frozen in flight, already drawn around the moon, and the headline, the line and the mist fade in.

Pitfalls

  • Without the hole around the headline the flock flies over it and smudges the words: the ellipse must be measured on the real text and measured again once the fonts arrive and on resize.
  • A symmetric wingbeat looks like a toy: the downstroke must be faster than the rise, and the glides break the rhythm.
  • Identical bats look copied: depth changes size, line weight and opacity, and the far ones are drawn first.
  • With large dt (a background tab) the simulation blows up: the step must be capped at five hundredths.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 11 KB; the libraries: GSAP 28 KB.

Testing

Tested on 30 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations