Skip to content
animorio
IT
Back to the library

Rain on water background

Backgrounds, HoverGSAP, Canvas, CSS onlyAdvancedCompressed weight: Demo 9.2 KBGSAP 28 KBFreeDownload the zip

A page background to put behind a headline, for the opening of a made-up rain sounds app, Nightpond: a lake at night, almost black, with the long amber reflection of a lamp on the far shore, broken into soft moving bars. Drops fall: each one flashes for an instant and opens rings that bend the reflection and catch the light on their crests, small towards the far shore and wide up close. The pointer touches the water and leaves a wake, a click is a big drop, and Start listening brings on the heavy rain, with the millimetre counter rising and a sound meter moving inside the button.

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>
<!--
  "Rain on water 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 rain on dark water with the light rippling</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/full-italic.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the hero of an invented rain sounds app, Nightpond: behind the words a lake at night, almost black, with the long
       amber reflection of a lamp on the far shore; drops of rain land on it, every drop opens rings that bend the
       reflection, and the pointer touches the water and leaves a wake. Start listening makes the rain heavier. -->
  <main class="stage" data-stage>
    <canvas class="water" data-water aria-hidden="true"></canvas>
    <span class="mist" aria-hidden="true"></span>
    <span class="veil" aria-hidden="true"></span>
    <span class="grain" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="pill" data-in>
        <svg class="pill__mark" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.6c2.7 3.4 4.4 6 4.4 8.2a4.4 4.4 0 0 1-8.8 0c0-2.2 1.7-4.8 4.4-8.2z"/><path d="M3 17.4c2.3-1 4.6-1 7 0s4.7 1 7 0"/></svg>
        <span class="pill__tag">Nightpond</span>
        <span class="pill__text">Rain sounds for sleep</span>
      </p>
      <h1 class="title" id="hero-title" data-in>Let the rain<br><em>carry you off</em></h1>
      <p class="lede" data-in>Eight hours of real rain on a still lake, mixed live for the room you sleep in.</p>
      <div class="actions" data-in>
        <button class="cta" type="button" data-cta aria-pressed="false">
          <span class="cta__shine" aria-hidden="true"></span>
          <span class="cta__face">
            <span class="cta__row" data-row>
              <svg class="cta__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M5.2 3.6v8.8L12.4 8z"/></svg>
              <span class="cta__label">Start listening</span>
            </span>
            <span class="cta__row cta__row--on" data-on aria-hidden="true">
              <span class="meter" aria-hidden="true"><i data-bar></i><i data-bar></i><i data-bar></i><i data-bar></i></span>
              <span class="cta__label">Listening</span>
              <span class="cta__time" data-time>7:59:58</span>
            </span>
          </span>
        </button>
        <span class="note">Free for seven nights</span>
      </div>
    </section>

    <p class="readout" data-readout aria-hidden="true"><span data-rate>Light rain</span><span class="readout__sep"></span><span data-mm>1.2 mm/h</span></p>

    <svg class="ghost" data-ghost viewBox="0 0 20 20" aria-hidden="true"><path d="M4 2.5v13.2l3.5-3.3 2.4 5.3 2.3-1-2.4-5.2 4.8-.2z"></path></svg>
  </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.

30 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 “Rain on water 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 whole screen is a lake at night: at the top the far water is a touch lighter, as if the sky were in it, then nearly black close to us, with a low mist at the top. In the middle, from the far shore down to our feet, falls the reflection of a lamp, a narrow amber column with an almost white core, broken into soft bars that slide slowly; the lamp sways a hair in the wind. On top sit the pill «Nightpond · Rain sounds for sleep», the headline «Let the rain carry you off» with the second line in amber italics, a quieter line, the light «Start listening» button and, at the bottom, the pill that tells the rain: «Light rain · 1.2 mm/h». Drops fall at random, smaller and sparser towards the far shore: each one flashes for an instant and opens rings that widen, cross, bend the reflection where they pass and light up the crests that face the light, cool away from the lamp, warm inside the reflection. Moving the pointer opens a wake in the water; a click is a big drop. Press the button and the label rolls away for «Listening», with a small sound meter moving and the hours left, from 8:00:00; a big ring leaves from under the button, the rain turns heavy in two and a half seconds and the counter climbs to «Steady rain · 4.6 mm/h». With no pointer, a drawn arrow strokes the water, presses the button, draws a circle and presses it again.

How it works

A small height field

The water is a grid of cells about 5 pixels wide (at most 300 by 220), two Float32Arrays for the height now and the height before. At each step every cell becomes half the sum of its four neighbours minus its previous value, times CALM: the simplest wave equation, and the rings widen, cross and die out by themselves.

The drop

A drop is a small dent with a raised rim, a cosine from the centre to the edge; its radius and strength shrink towards the far shore, so the water looks seen at a slant. In the same cell a flash lights up and fades to 82% per step.

The reflection read through the slope

For each cell the slope is the difference between the neighbours to the right and left, above and below. The lamp's reflection is a narrow Gaussian around an x, but the x is read shifted by the slope: where a ring passes, the column bends. The soft bars are a sine sliding along the column.

Crests catching the light

Slopes that face the light light up: cool and faint away from the lamp, warm and strong inside the reflection. The others darken a little: that is what makes the rings visible even on black water.

The browser stretches, the grain smooths

The image is written with putImageData on a canvas as large as the grid, and CSS stretches it to the whole page: the browser softens it by itself. On top, an SVG grain removes banding and a mist at the top gives depth.

The heavy rain

Drops per second are a number GSAP takes from RAIN to three times as many in 2.4 seconds, together with the counter's millimetres; a debt of fractional drops keeps them falling evenly at any frame rate.

The button

The label leaves upwards and the new one arrives from below with back.out, the button squashes to 0.96 and springs back, a band of light crosses it, four small bars move at random and the hours count down from 8:00:00. The press sends a big ring out from under the button.

Values to change

NameFileDefaultWhat it changes
RAINscript.js7Drops per second in light rain (three times as many while listening).
DROPscript.js1How strong the drops are.
CALMscript.js0.984How long the rings last: lower dies out sooner.
BENDscript.js1How much the waves bend the lamp's reflection.
LAMPscript.js1How bright the amber reflection is.
WAKEscript.js1How strong the pointer's wake is.
CELLscript.js5Side of one water cell in pixels: smaller means finer waves and more work.
AUTO_PILOTscript.js3After how many seconds without a pointer the drawn one comes (0 never).

Try them in the Playground

When to use it

For the opening of a sleep, meditation or relaxing sounds app, a spa, a lakeside hotel, a record or a late-night podcast: when you need a dark background that moves slowly and can be touched, without stealing the headline's place.

On phones

Same animations: the grid is measured on the page width, so on the phone the waves stay fine; the finger leaves the wake and a tap makes a big drop. Headline, text and button fit the frame, sized on height too; below 460 pixels of height the rain pill hides.

With reduced motion

With reduced motion the lake is frozen in one moment, with a few rings already open and the reflection bent; the words only fade in and the button changes label with a fade, without a wave.

Pitfalls

  • A full-resolution simulation costs too much: the grid is small and the browser stretches it, softening it for free.
  • On black water the rings don't show if only the light is coloured: the dark slopes are needed too, acting as shadow.
  • Drops the same size everywhere make the water look like a wall: towards the far shore they must be smaller and sparser.
  • Drops per second are fractional: without a debt that accumulates, at low frame rates the rain stops or stutters.
  • Time comes from gsap.ticker, not performance.now: that way the preview and the video can drive it.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, Fraunces (font variabile) 5.3.0.

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

Testing

Tested on 8 November 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