Liquid✨ Premium

Deep Dream Pattern

A full-frame rainbow plasma: three sine waves that cross and drift over time, turned into colors that run through the whole spectrum and ripple endlessly — computed live on a 2D canvas, 3.1 KB of JavaScript, smooth on Retina screens, paused off screen, a still image when the user reduces motion.

CanvasPlasmaGeneratif

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Liquid has 31 effects, including 6 free. Explore the category →

3 usage examples

Animated poster for a psychedelic rock festival — Deep Dream Pattern example 1

① Animated poster for a psychedelic rock festival

WhenThe festival's name, "Electric Spiral", in large capitals at the center of the poster, over the plasma; dates, venue and bands below.
WhySaturated color waves that warp are the look of late-60s posters and light shows.
SettingsFull-frame block (position: absolute; inset: 0), aria-hidden="true"; dark oval glow at the center (62% radial gradient) under the title; title in 50 and 38 px Arial Black, shadow offset by 3 × 4 px.
"Spirals & waves" collection — banner for a hand-dyed T-shirt shop — Deep Dream Pattern example 2

② "Spirals & waves" collection — banner for a hand-dyed T-shirt shop

WhenThe collection banner, title and tagline over the plasma at the top; below, three T-shirts with their name and fabric.
WhyThe rippling color bands recall the marbling of tie-dye, with no photo to load: each T-shirt shows a different pattern at every moment.
SettingsA single full-frame plasma; dark bottom band in SVG (fill-rule: evenodd) with three T-shirt shapes cut out, through which the plasma shows like dye; title in 34 px Georgia italic with a drop shadow.
Why do we see colors? — welcome kiosk in the color room of a museum of optics — Deep Dream Pattern example 3

③ Why do we see colors? — welcome kiosk in the color room of a museum of optics

WhenThe question in large type on a dark card at the center of the screen, the "Start" button below; every hue of the spectrum flows around it.
WhyThe 120° offsets between red, green and blue send the whole spectrum through the frame: a direct prop for talking about how colors mix.
SettingsFull-frame plasma; top bar in 72% black; 360 px central card in 74% black, 18 px corners; the button reveals the first answer (scene script).

How it works

The .fx-0418-root block is 300 px high and takes the full available width. It holds a <canvas class="ai-dream-canvas"> set to display: block at 100% of its container: the height comes from the root's CSS and the canvas fits into it (20 resizes in a row, 0 px of drift, Chromium and Firefox). Despite its name, the effect uses no neural network, no fractal and no "deep dream": it is a plasma, a classic of graphics demos, made of a sum of sine functions. The name stays the catalog's.

For each point, the script maps the position onto a 0 to 4 scale (nx, ny) and adds three waves: sin(3·nx + t) · cos(2·ny + 0.7·t), a grid of sliding cells; sin(3·√(nx² + ny²) − t), rings spreading from the top left corner; cos(nx·ny + 0.5·t), curved bands. Their average v, between -1 and 1, gives the color: red, green and blue equal 128 + 127 · sin(π·v + offset), with offsets of 0, 120 and 240° that also drift over time at three speeds (t, 0.7·t, 0.3·t). The same value of v therefore changes hue as seconds go by: the frame runs through the whole spectrum. Time t advances by 0.01 per frame, a full color cycle in about 630 frames (10 s at 60 Hz).

The computation runs on a grid of one point per 2 × 2 CSS pixels, in a small canvas off the page (320 × 150 for a 640 × 300 block), then that image is scaled up with smoothing onto the visible canvas, at the screen's density (up to 2): gradients stay continuous, with no steps, and a Retina screen costs no extra computation. Measured per frame: 2.8 ms in Chromium, 3 ms in Firefox and 1 ms in WebKit at 640 × 300; 9, 9 and 4 ms at 1,200 × 500. The loop pauses as soon as the block leaves the screen (IntersectionObserver, 0 frames computed, measured) and when the tab is hidden. The script animates every .fx-0418-root on the page separately.

Accessibility

  • Reduced motion: under prefers-reduced-motion: reduce, the loop does not start: the canvas shows a single frame of the plasma (at time 0). Measured in Chromium, Firefox and WebKit: 0% of pixels change in 500 ms. Without that preference, the whole frame changes continuously (100% of pixels in 500 ms): keep the effect for a short background or an area visitors can scroll past.
  • Readability: the plasma goes from very light yellow to midnight blue within a few seconds, under the same text. No text color holds on its own: put text on a dark panel at 70% or more, or give it a heavy drop shadow, as in the three examples.
  • Saturated colors in motion: large, highly saturated areas that keep changing can bother some people who are sensitive to visual stimulation. The change stays slow (no flashing: a color takes several seconds to give way), but avoid spreading it over a whole reading page.
  • Decorative content: the canvas carries no information. Add aria-hidden="true" to the root when the plasma is a background, as in the examples.

Browser compatibility

Canvas 2D (createImageData, putImageData, drawImage with smoothing), ResizeObserver, IntersectionObserver, matchMedia: 3.1 KB of JavaScript, no dependency. Measured in Chromium 151, Firefox 153 and WebKit 26: same plasma, canvas at 1,280 × 600 on a Retina screen, paused off screen, still image under reduced motion, 0 errors. Time advances per displayed frame: on a 120 Hz screen the colors cycle twice as fast as at 60 Hz.

Chrome 64+✓ Full
Firefox 69+✓ Full
Safari 13.1+✓ Full
Edge 79+✓ Full
Mobile iOS 13.4+✓ Full
Android Chrome 64+✓ Full

Without ResizeObserver, the script follows the window resize event; without IntersectionObserver, the loop keeps running off screen. Without JavaScript, the block stays a dark rectangle (#0a0a0f): add a fallback gradient on .ai-dream-container if the background must stay colorful.

The code

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

index.html — structure
<div class="fx-0418-root">
  <div class="ai-dream-container">
    <canvas class="ai-dream-canvas"></canvas>
  </div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Speed (JS — time += 0.01) 0.01 per frame: one color cycle in about 10 s at 60 Hz 0.004 for a slow background behind long text; 0.02 for a livelier poster.
Pattern size (JS — x / w * 4 and y / h * 4) 4 2 gives broad sheets of color; 8, patterns twice as tight. Change both values together to keep round patterns.
Color intensity (JS — 128 + 127 * Math.sin(…), three lines) from 1 to 255 on each channel 190 + 60 * Math.sin(…) gives a pastel plasma, easier to cover with text; 60 + 60 * Math.sin(…), a dark plasma.
Palette (JS — 2.094 and 4.188 offsets) 0, 120 and 240°: the whole spectrum Close offsets (0.6 and 1.2) narrow the palette to a few neighboring hues.
Computing detail (JS — y += 2, x += 2, w / 2, h / 2 and both * 2 in drawImage) one point computed per 2 × 2 CSS pixels Set these six 2s to 4 for 4 times less computation, useful on a wide banner: smoothing keeps gradients continuous, just slightly softer.
Height (CSS — height of .fx-0418-root) 300px The canvas follows the block's height. For a banner background, set the root to position: absolute; inset: 0.

FAQ

No. Despite its name, Deep Dream Pattern calls on no AI model and draws no fractal (no pattern repeats at a smaller scale). It is a plasma: three sine waves added together, with their sum turned into color. All the math fits in a single short function, with no dependency and no data loaded.
Fluid Gradient is pure CSS: four color blobs blurred at 40 px turn slowly over 15 s, in an indigo, violet and cyan range. Deep Dream Pattern computes every point in JavaScript and runs through the whole spectrum, with sharper bands and rings. Pick Fluid Gradient for a discreet background with no script; Deep Dream Pattern for a background that gets noticed, colorful and ever-changing.
The plasma is made of soft gradients: computing one point in four and then scaling up with smoothing gives the eye the same image, for four times less computation. On a Retina screen the scaling happens straight at the screen's density, so at no extra computing cost: 2.9 ms per frame in Chromium at 640 × 300, just like on a standard screen.