Skip to content
animorio
IT
Back to the library

Grainy gradient background

BackgroundsCanvas, GSAP, CSS onlyMediumCompressed weight: Demo 5.9 KBGSAP 28 KBFreeDownload the zip

The opening background of Halcyon, an invented notes app: on a near black ground three soft patches of colour, an ember orange and two close tones, drift slowly along their own paths and lean towards the pointer on a soft spring, under a fine grain that changes every frame like film stock. A click sends a small wave that swells the patches and lets them settle. The title and the pill stay sharp in the middle. 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>
<!--
  "Grainy gradient 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 grainy gradient background</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/instrument-sans@5.3.0/index.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the opening of Halcyon, an invented notes app: three soft patches of colour drift slowly on a near black
       ground under a fine moving grain, and lean towards the pointer on a soft spring; a click sends a small wave -->
  <main class="stage" data-stage>
    <canvas class="glow" data-glow aria-hidden="true"></canvas>
    <canvas class="grain" data-grain aria-hidden="true"></canvas>
    <span class="vignette" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="kicker" data-in>
        <svg class="kicker__mark" viewBox="0 0 16 16" aria-hidden="true"><path d="M2 10.5c2.2-4.6 4.6-4.6 6 0s3.8 4.6 6 0"></path></svg>
        <span>Halcyon, private beta</span>
      </p>
      <h1 class="title" id="hero-title">
        <span class="title__line" data-in>Think in</span>
        <span class="title__line title__line--soft" data-in>quiet colour.</span>
      </h1>
      <p class="line" data-in>Notes that settle on their own, so the idea stays and the noise goes.</p>
      <button class="pill" type="button" data-pill data-in>
        <span class="pill__fill" aria-hidden="true"></span>
        <span class="pill__label">Join the beta</span>
        <svg class="pill__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9M8.5 4.5 12 8l-3.5 3.5"></path></svg>
      </button>
    </section>

    <p class="hint" data-hint aria-hidden="true">Move, then click anywhere</p>
  </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.

22 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 “Grainy gradient 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

Across the screen a near black ground and three very soft patches of colour: an ember orange top left, a deeper pink bottom right and a light orange at the top. They move slowly, each along its own lazy figure of eight, and where they overlap the light adds up. Over everything, a fine grain that keeps changing. In the middle, sharp, «Halcyon, private beta» in small type, the title «Think in quiet colour.» on two lines, a sentence and the «Join the beta» pill. Moving the pointer the patches lean towards it on a spring, the nearest one most; a click sends a wave that swells them and lets them settle with a small bounce. Hovering the pill the white fills it from the left and the arrow steps forward. When nobody touches, an invisible pointer draws a figure of eight around the title and clicks now and then.

How it works

The patches, painted small

The three patches are radial gradients drawn on a hidden canvas one eighth of the screen, added up with 'lighter'. The visible canvas has the same small size and CSS stretches it to the full screen: the browser softens them for free and the work per frame is tiny.

The slow path

Each patch has a home and a sine and cosine with different phases and speeds, so the three never move together. DRIFT sets how far they wander, DRIFT_TIME how long one loop lasts.

The spring towards the pointer

The target of each patch moves towards the pointer by PULL, more for the nearest patch. The patch catches it on a hand-written spring in the GSAP ticker, on the real time between frames (at most 0.1 s), with SPRING and DAMPING.

The grain

Four 128 by 128 noise tiles are made once; at every change (GRAIN_FPS per second) one is picked and shifted at random. The grain canvas sits on top in 'overlay' at a low opacity, one and a half pixels per grain.

The click wave and the pill

A click takes a number from 0 to 1 in 0.32 s and back to 0 with elastic.out in 1.4 s: the patches' radius grows by WAVE. The pill fills with white from the left with scaleX, grows a hair with back.out and on press gives way and springs back.

Values to change

NameFileDefaultWhat it changes
DRIFT_TIMEscript.js14Seconds of one loop of each patch’s slow path.
DRIFTscript.js0.16How far the patches wander from home, as a fraction of the screen.
BLOB_SIZEscript.js0.46Radius of a patch, as a fraction of the shorter side.
PULLscript.js0.22How much the patches lean towards the pointer.
SPRINGscript.js3.2Stiffness of the spring towards the pointer.
DAMPINGscript.js0.82Damping of the spring: higher means less bounce.
WAVEscript.js0.28How much the patches swell with the click wave.
GRAIN_FPSscript.js24How many times per second the grain changes.
AUTO_PILOTscript.js2.2After how many seconds without a pointer the invisible pointer comes back (0 never).

Try them in the Playground

When to use it

Behind the opening headline of a digital product that wants to feel calm and warm: a notes or writing app, an AI tool, a newsletter, a dark portfolio. It adds depth without images and without pulling the eye from the title.

On phones

The same: the patches follow the finger as it drags and a tap sends the wave. The patches are sized on the shorter side, so they stay full even in the low, wide box; the title is sized on the height too and the sentence hides below 460 pixels of height.

With reduced motion

The patches stand still at home, the grain does not change and a click sends no wave; the type fades in.

Pitfalls

  • Painting the patches at full size and blurring them with filter costs too much: a canvas one eighth the size stretched by CSS is already very soft.
  • Rebuilding the grain pixel by pixel every frame chokes a phone: four ready tiles shifted at random are enough.
  • The grain canvas needs the real screen size (up to DPR 2), or once stretched it turns blocky; the patches canvas can stay small.
  • The title and pill sit in a full-screen container centred with flex: no centring transform, so GSAP can move and scale them without losing the centre.

Libraries

GSAP 3.15.0, Instrument Sans (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.

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

Testing

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