Skip to content
animorio
IT
Back to the library

Rain radar

SVG, HoverGSAP, CanvasMediumCompressed weight: Demo 9.3 KBGSAP 28 KBFreeDownload the zip

The rain radar of Nimbly, a made-up weather app, in a card on warm paper: a line map with the coast, a river, a few roads and three towns, and over it the rain cells in three levels, light, moderate and heavy, drifting with the wind, growing, bending and melting away. Below, the time from an hour ago to an hour ahead, to drag or to play, with the clock rolling and a line saying when the rain reaches Calder. Hover the map to read the rain at that spot. Minimal style.

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 radar" 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>Rain radar</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>
  <main class="stage">
    <!-- the rain radar of a made-up weather app: a line map with the coast, a river, a few roads and three towns, the
         rain cells drifting over it with the wind, your position, and under the map the time from an hour ago to an
         hour ahead, to drag or to play. Hover the map to read the rain at that spot. -->
    <section class="card" aria-labelledby="titolo">
      <span class="card__sheen" aria-hidden="true"></span>

      <header class="head">
        <div class="head__l">
          <span class="brand">
            <svg class="brand__mark" viewBox="0 0 20 20" aria-hidden="true"><path d="M5.2 13.6a3.4 3.4 0 0 1 .4-6.8 4.6 4.6 0 0 1 8.8 1.2 2.8 2.8 0 0 1-.2 5.6Z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M7.4 15.8 6.8 17.4M10.6 15.8 10 17.4M13.8 15.8l-.6 1.6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
            <span>Nimbly</span>
          </span>
          <h1 id="titolo" class="title">Rain radar</h1>
        </div>
        <div class="head__r">
          <span class="when"><span class="roll" aria-hidden="true"><span class="roll__row" data-clock>14:30</span></span></span>
          <span class="rel"><span class="roll" aria-hidden="true"><span class="roll__row" data-rel>Now</span></span></span>
        </div>
      </header>

      <p class="forecast">
        <svg class="forecast__ico" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2.2c2.4 3 3.9 5.2 3.9 7.2a3.9 3.9 0 0 1-7.8 0c0-2 1.5-4.2 3.9-7.2Z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>
        <span class="roll" aria-hidden="true"><span class="roll__row" data-say>Rain starts in 18 min in Calder</span></span>
      </p>
      <p class="sr" data-sr aria-live="polite"></p>

      <div class="map" data-map>
        <svg class="map__lines" viewBox="0 0 1000 620" preserveAspectRatio="none" aria-hidden="true">
          <path class="sea" d="M0 400 C 80 392 132 446 224 434 S 352 500 420 620 L 0 620 Z"/>
          <path class="coast" d="M0 400 C 80 392 132 446 224 434 S 352 500 420 620"/>
          <path class="road road--main" d="M30 92 C 300 140 520 210 990 300"/>
          <path class="road" d="M318 0 C 390 200 520 420 600 620"/>
          <path class="road" d="M620 300 C 760 380 860 460 1000 520"/>
          <path class="road" d="M840 0 C 830 90 860 160 900 240"/>
          <path class="river" d="M1000 120 C 860 150 790 228 706 262 S 560 300 520 380 S 420 458 360 506"/>
          <circle class="ring" cx="620" cy="300" r="110"/>
          <circle class="ring" cx="620" cy="300" r="220"/>
        </svg>
        <canvas class="map__rain" data-rain aria-hidden="true"></canvas>
        <div class="towns" aria-hidden="true">
          <span class="town" style="left:25%;top:69.4%"><i></i>Wrenmouth</span>
          <span class="town" style="left:84%;top:22.6%"><i></i>Ashby Fen</span>
          <span class="town town--you" style="left:62%;top:48.4%"><i class="you"><b></b></i>Calder</span>
        </div>
        <span class="probe" data-probe aria-hidden="true"></span>
        <div class="tip" data-tip aria-hidden="true">
          <span class="tip__k" data-tip-k>Light rain</span>
          <span class="tip__v" data-tip-v>0.4 mm/h</span>
        </div>
        <div class="map__north" aria-hidden="true">
          <svg viewBox="0 0 16 16"><path d="M8 2.5 10.6 12 8 10.3 5.4 12Z" fill="currentColor"/></svg>N
        </div>
      </div>

      <div class="time">
        <button class="play" type="button" data-play aria-label="Play">
          <svg class="play__i play__i--go" viewBox="0 0 16 16" aria-hidden="true"><path d="M5.2 3.6v8.8a.6.6 0 0 0 .9.5l6.6-4.4a.6.6 0 0 0 0-1L6.1 3.1a.6.6 0 0 0-.9.5Z" fill="currentColor"/></svg>
          <svg class="play__i play__i--stop" viewBox="0 0 16 16" aria-hidden="true"><rect x="4.2" y="3.4" width="2.6" height="9.2" rx=".8" fill="currentColor"/><rect x="9.2" y="3.4" width="2.6" height="9.2" rx=".8" fill="currentColor"/></svg>
        </button>
        <div class="bar" data-bar role="slider" tabindex="0" aria-label="Time" aria-valuemin="-60" aria-valuemax="60" aria-valuenow="0" aria-valuetext="Now">
          <div class="bar__track" aria-hidden="true">
            <span class="bar__fill" data-fill></span>
            <span class="bar__ticks" data-ticks></span>
          </div>
          <span class="knob" data-knob aria-hidden="true"></span>
          <div class="bar__labels" aria-hidden="true"><span>-1 h</span><span>Now</span><span>+1 h</span></div>
        </div>
      </div>

      <div class="legend" aria-hidden="true">
        <span><i class="l1"></i>Light</span><span><i class="l2"></i>Moderate</span><span><i class="l3"></i>Heavy</span>
        <span class="legend__src">Radar · 5 min</span>
      </div>
    </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.

39 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 radar” 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

A white card on warm paper: at the top Nimbly, the title Rain radar and on the right the time, 14:30, with «Now» below in blue. A line says «Rain starts in 18 min in Calder». The map is drawn in lines: the sea at the bottom left, the coast and a river in pale blue, four grey roads, two dashed circles around Calder, your town, marked by a blue dot with a ring. Over it the rain cells drift east, light blue, blue and deep blue where it pours, with soft edges that bend and breathe. Below there is the play button and the time bar from -1 h to +1 h with ticks every quarter of an hour: drag the knob and the rain goes forward and back, the clock and the minutes roll and the line changes («Light rain in Calder · ends in 34 min»). Over the map a small circle follows the pointer and a dark bubble says what rain there is, for example «Moderate rain · 2.6 mm/h». If nobody touches it, the radar plays the whole hour by itself and reads the rain over Calder.

How it works

A rain field

The rain is a function of place and time: eight cells, each a soft bump (exp(-d²/r²)) moving with the wind at WIND units a minute, born, growing and fading around its t0. A 3D noise shifts the points before measuring, so the edges bend and change over time.

Small, then large

The field is computed on a 200 by 124 canvas; each point takes the colour of its level (light, moderate, heavy) with a soft step of SOFT around the thresholds. Then it is drawn large with the browser's smoothing: the steps turn into soft contour lines, cheaply.

The map underneath

Coast, sea, river, roads and the circles around Calder are an SVG with preserveAspectRatio none in the same proportion as the field (1000 by 620), so every point of rain lands on the right point of the map at any size.

The time

A single variable, t, runs from -60 to +60 minutes: the bar, the knob, the clock, the minutes and the line all come from it. Play is a tween of t with ease none; dragging sets t from the pointer's position on the bar, and the arrow keys move by 5 minutes (15 with Shift).

The line

To say when the rain arrives the field over Calder is measured minute by minute from the chosen time forward: the first minute above the light-rain threshold is «Rain starts in N min», or if it is already raining the first dry minute is «ends in N min». The line rolls only when it changes.

Under the pointer

On hover the field is read at the mouse and the bubble gives the level and the millimetres per hour; near the edges it flips to the other side. On a phone a tap opens the bubble and a second tap on the same spot closes it.

Values to change

NameFileDefaultWhat it changes
PLAYscript.js11How many seconds play takes to go from an hour ago to an hour ahead.
HOLDscript.js2.2How long the last frame stays before the loop starts again by itself.
WINDscript.js3.4How fast the rain drifts east, in map units per minute (the map is 1000 wide).
WOBBLEscript.js40How much the edges of the cells bend and breathe.
SOFTscript.js0.05How soft the step between two rain levels is (0 = sharp contours).
OPACITYscript.js0.82How strong the rain is over the map.
IDLEscript.js4After how many seconds without a touch the radar starts playing by itself again.
START_ATscript.js0Where the time bar starts, in minutes from now.

Try them in the Playground

When to use it

In a weather app or website, on the page of an outdoor event (a festival, a race, a garden wedding) to decide whether to bring an umbrella, on a hotel or campsite page, or in any map with data changing over time and a bar to scrub it.

On phones

Everything is sized in em and the text size follows the window's width and height together: the card with the map fits whole in the box. The canvas redraws at the new size on every change. The bar is dragged with a finger and a tap on the map opens the bubble.

With reduced motion

No rain playing by itself: the map stays still on one moment with rain over Calder, the bar can be dragged and the rain changes at once, with no springs; the lines change with a fade.

Pitfalls

  • The field must be computed small and drawn large: computing it for every pixel of the map at 60 frames a second stalls a phone.
  • The SVG map and the canvas must share the same proportion (preserveAspectRatio none and aspect-ratio 1000 / 620), otherwise the rain does not land on the point of the map the bubble reads.
  • The level colours are read from :root once: change them in the CSS and the rain changes too.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 25 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