BackgroundsPremium

Neon Downpour

A pixel art neon city in the rain (canvas 2D): 3 building layers, rain in depth, splashes and a wet road reflecting neons.

CanvasPixel artSynthwaveRain

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Backgrounds has 55 effects, including 7 free. Explore the category →

3 usage examples

Full-background hero — a nocturnal music festival site — Neon Downpour example 1

① Full-background hero — a nocturnal music festival site

WhenHomepage of a nocturnal electronic music festival (NOCTEM): the scene fills the full width in the Ember palette, the left veil keeps the festival headline readable on the left side.
WhyThe animated cityscape delivers a rainy-night atmosphere with no video or external image; the scrolling road gives a sense of movement without distraction.
Settingsdata-swr-palette="ember", data-swr-veil="left" on .swr-veil, --swr-min-height: 360px (or 100vh in production), --swr-density: 1.2.
Animated cover art in a lo-fi music player — Neon Downpour example 2

② Animated cover art in a lo-fi music player

WhenA lo-fi radio player (DRIFT): the scene fills the album art thumbnail (~220 × 160 px) to the right of the control panel, Mint palette, larger pixels.
WhyThe animated city replaces a static cover and changes silently while the music plays; at that small size, the large pixels reinforce the 8-bit game aesthetic.
Settingsdata-swr-palette="mint", --swr-pixel: 3, --swr-density: 0.8, --swr-min-height: 160px. Pause button only, no swatches.
Section background on a nightlife venue agenda — Neon Downpour example 3

③ Section background on a nightlife venue agenda

WhenThe events agenda section of a late-night bar (LENOIR): the effect as a 360 px section background, low-density Neon palette, event cards floating on top.
WhyA low-density animated background sets the mood without competing for attention; cards with a semi-opaque background stay readable against the city.
Settingsdata-swr-palette="neon", --swr-density: 0.6, --swr-min-height: 360px. No .swr-content. Event cards are layered with position: relative; z-index: 1.

How it works

The scene is drawn inside a small canvas — roughly 240 × 150 pixels depending on the container width and --swr-pixel — scaled up without smoothing by image-rendering: pixelated. Each point becomes a solid block of CSS pixels: the authentic pixel art technique, which keeps the effect very light (around 36,000 pixels computed per frame, regardless of screen resolution). The city is generated from a seed (data-swr-seed, 886 by default): the same seed always gives the same skyline. Three silhouette layers are built once at startup, then rebuilt only when the container changes size (ResizeObserver).

Each layer (far, mid, near) is drawn on a separate canvas. Buildings have a lit face, a shadow face and a light rim; their windows (wins[]) turn on and off individually with a 1–2 s fade, never a flash. The mid layer carries the elevated metro viaduct: a train crosses the frame, waits off screen and comes back the other way. Neon signs with pre-computed halos pulse slowly on the near-layer buildings. Low clouds and a fog sheet (periodic textures twice as wide as the canvas) drift in a seamless loop between layers.

Three rain layers (far: thin trail, α 0.5; mid: full opacity; near: thick, edge-softened) fall at a wind angle that tracks the pointer or sweeps gently on its own. Each drop generates a splash at impact: ballistic droplets and an elliptical ring that move with the road (they stay attached to the pavement in perspective). The wet road is computed by accumulating the lights in the Lt layer (windows and signs without background) column by column, stretching them below the horizon line by line with a slow oscillation: a long, vivid streak in the distance, fading toward the foreground with a few advancing breaks. Animation is normalised to the real clock (dt in seconds), same render at 60 and 120 Hz.

Accessibility

  • Reduced motion: under prefers-reduced-motion: reduce, the loop does not start and the script draws a still image (a few splashes in place, city without animation). The pause button lets the user restart manually.
  • Built-in pause button: the .swr-toggle button stops all animation (WCAG 2.2.2). While paused, the canvas keeps the last drawn frame.
  • Off screen and hidden tab: an IntersectionObserver suspends computing as soon as the scene leaves the viewport, and visibilitychange stops it when the tab is hidden.
  • Decorative canvas: the canvas carries aria-hidden="true". Content placed in .swr-content remains accessible and readable independently of the animation.
  • Reduced transparency and high contrast: under prefers-reduced-transparency: reduce, the veil is removed and text rests on an opaque surface. The .swr-hc class on the root darkens the scene and places all text on opaque panels.

Browser compatibility

Canvas 2D, ResizeObserver and IntersectionObserver, no dependency. Canvas 2D available since Chrome 4, Firefox 2, Safari 3.1. IntersectionObserver since Chrome 51, Firefox 55, Safari 12.1. ResizeObserver since Chrome 64, Firefox 69, Safari 13.1 — real limit. Without JavaScript: a linear CSS gradient (sky → horizon → road) defined on .swr-root.

Chrome 64+✓ Full (measured)
Firefox 69+✓ Full (measured)
Safari 13.1+✓ Full (measured)
Edge 79+✓ Full (measured)
Mobile iOS 13.4+✓ Not verified on a real phone
Android Chrome 64+✓ Not verified on a real phone

Without JavaScript, .swr-root shows its linear CSS gradient (sky → horizon → road) matching the active palette colors. The script needs both ResizeObserver and IntersectionObserver: in a browser missing either (before Chrome 64, Firefox 69, Safari 13.1), it stops on an error right after drawing its first frame. The city stays displayed but frozen, with no rain.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0890-root">
  <div class="swr-root" data-swr-palette="neon">
    <canvas class="swr-canvas" aria-hidden="true"></canvas>
    <div class="swr-veil"></div>
    <div class="swr-content">
      <p class="swr-kicker">…</p>
      <p class="swr-title">…</p>
    </div>
    <div class="swr-bar">
      <button type="button" class="swr-swatch" data-swr-set="neon" aria-pressed="true" aria-label="…"></button>
      <button type="button" class="swr-swatch" data-swr-set="ember" aria-pressed="false" aria-label="…"></button>
      <button type="button" class="swr-swatch" data-swr-set="mint" aria-pressed="false" aria-label="…"></button>
      <button type="button" class="swr-toggle" aria-pressed="false" aria-label="…"></button>
    </div>
    <p class="swr-sr" aria-live="polite"></p>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Palette (HTML — data-swr-palette) neon (magenta / cyan) ember (orange / gold) or mint (green / glacier). For a custom palette, override --swr-sky, --swr-dusk, --swr-haze, --swr-neon-a, --swr-neon-b, --swr-tower, --swr-road and --swr-warm.
Rain density (CSS — --swr-density) 1 0 = dry sky, buildings and road only; 2 = downpour. The variable is re-read on each rebuild (refresh()), or changed live via setDensity(n).
Pixel size (CSS — --swr-pixel) 0 (auto: width ÷ 270) 2 = fine grain close to half-point Retina; 3–4 = large blocks readable at small sizes. Triggers a rebuild.
City seed (HTML — data-swr-seed) 886 Any integer produces a different skyline. The same seed always gives the same city. Set before the first render or follow with a refresh() call.
Minimum height (CSS — --swr-min-height) 300px 100vh for a full-screen hero, 200px for a shallow section background.
Side veil (HTML — data-swr-veil="left" on .swr-veil) top veil (vertical gradient) Horizontal gradient: opaque left to transparent right. Ideal for text placed on the left side of the scene.
Script control (JS — window.NeonDownpour.get(el)) auto .setPalette('ember'), .setDensity(0.5), .play(), .pause(), .refresh() (re-reads CSS variables and rebuilds the city with a cross-fade).

FAQ

No, only standard canvas 2D. The lightness comes from the small canvas size (≈ 240 × 150 points) scaled up without smoothing by image-rendering: pixelated: even on a Retina screen, the compute resolution stays low. The CPU draws around 36,000 pixels per frame, not the millions of a full-resolution canvas.
Yes. Each .swr-root is an independent scene. Give different values to data-swr-seed on each instance to get distinct skylines. A single requestAnimationFrame loop drives all visible scenes; those off screen are automatically paused.
Set --swr-density: 0 on .swr-root: all three rain layers and splashes disappear, while windows keep switching, the train keeps passing and clouds keep drifting. The variable is re-read on each rebuild; to change it live, call NeonDownpour.get(el).setDensity(0).