Skip to content
animorio
IT
Back to the library

Velvet background

Backgrounds, HoverCanvas, GSAP, CSS onlyMediumCompressed weight: Demo 7.4 KBGSAP 28 KBFreeDownload the zip

The opening background of The Rosmere, a made-up hotel with a theatre bar: a deep bordeaux velvet with its real sheen, lighter where the pile leans toward the light and darker where it turns away. Where the pointer (or a finger) passes, the pile bends the way it moves and leaves a light or dark trail, like a hand on velvet, which stays and slowly stands up again. When nobody touches, an invisible hand draws a slow S.

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>
<!--
  "Velvet 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 velvet background that follows the hand</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/index.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/instrument-sans@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the hero of an invented hotel with a theatre bar, The Rosmere: behind the name a deep bordeaux velvet; where the
       hand passes the pile bends the way it moved and leaves a lighter or darker trail that slowly stands up again -->
  <main class="stage" data-stage>
    <canvas class="velvet" data-velvet aria-hidden="true"></canvas>
    <canvas class="grain" data-grain aria-hidden="true"></canvas>
    <span class="rake" aria-hidden="true"></span>
    <span class="vignette" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="kicker" data-in>
        <span class="kicker__rule" data-rule aria-hidden="true"></span>
        <span class="kicker__text">Hotel and theatre bar</span>
        <span class="kicker__rule" data-rule aria-hidden="true"></span>
      </p>
      <h1 class="title" id="hero-title" data-title>
        <span class="title__word" data-in>The</span>
        <span class="title__word title__word--name" data-in>Rosmere</span>
      </h1>
      <p class="line" data-in>Forty rooms behind the red curtain, open long after the last bow.</p>
    </section>

    <p class="hint" data-hint aria-hidden="true">
      <svg class="hint__mark" viewBox="0 0 24 12" aria-hidden="true"><path d="M1.5 9.5C5 2.5 8.5 2.5 12 6s7 3.5 10.5-3.5"></path></svg>
      <span>Brush the velvet</span>
    </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.

19 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 “Velvet 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 whole screen a bordeaux velvet, almost black in the folds, with a soft raking light from the top left and a fine grain of fibres. In the middle, in champagne, «Hotel and theatre bar» between two thin rules, the name «The Rosmere» in an elegant serif with «The» in italics, and a small line: «Forty rooms behind the red curtain, open long after the last bow». At the bottom «Brush the velvet» with a wavy mark. On opening the light slowly comes up on the cloth, the two rules stretch out and the words rise from a blur with one pixel too many. At rest the velvet is never even: it has the soft crushes of a cloth folded and laid out again. The pointer is a hand: where it passes the pile bends the way it moves, and the trail turns lighter if the pile now faces the lamp, darker if it turns away; brushing back the other way changes the tone of the trail. The faster you pass, the more the pile bends; holding down, the hand presses harder and wider. The trail stays and slowly stands up again, in ten seconds or so. The lamp drifts a little, so the trails change tone slowly even without touching, and the sheen on the name follows the hand. Without a pointer an invisible hand draws a slow S from top to bottom, then the same S upward, against the pile.

How it works

A map of the pile

The screen is split into 5 pixel cells. Each cell has a vector: which way the pile leans and how far (0 upright, 1 flat). At rest the vector comes from a few slow waves (sine and cosine of the position), so the velvet has the crushes of a real cloth and is never even.

Light on the pile

For each cell the direction toward the lamp is multiplied by the pile vector: positive, the pile faces the light and brightens; negative, it turns away and deepens. On top, the light falling off with distance and a fixed value per cell, the fibres, which break the trails into lighter and darker streaks.

From tones to colours

The tone goes through a 256 colour ramp built once from the four :root colours (near black, bordeaux, light bordeaux, pinkish sheen). The small map is softened with a 1-2-1 both ways, written into a tiny canvas and stretched across the screen with the browser's smoothing: a full screen costs as much as a small one.

The hand

Between two pointer positions the brush takes steps of one cell, and at each step the cells inside the radius turn toward the direction of motion, with a weight that falls off softly toward the edge of the hand and grows with speed. Pressing, the radius and the strength grow. Every frame each cell goes back toward its rest by 1 - exp(-dt times RECOVER): the trail slowly stands up.

The grain and the invisible hand

The grain is a second canvas, drawn once per size: a grey with a little memory along the row, which makes short fibres rather than snow, laid on top in overlay. After a few seconds without a pointer the invisible hand follows an S (the sine of the descent) with a soft ease, down and then up: at the ends it slows and bends less.

Values to change

NameFileDefaultWhat it changes
CELLscript.js5Side of one cell of the pile map, in pixels: smaller is finer and slower.
BRUSHscript.js0.34How far the hand bends the pile on each pass.
RADIUSscript.js64Radius of the hand, in pixels.
RECOVERscript.js0.09How fast the pile stands up again, per second (0: the trail stays forever).
SHEENscript.js1How glossy the velvet is: the difference between pile toward the light and against it.
CRUSHscript.js0.24How crushed the velvet is at rest (0 smooth).
HAND_TIMEscript.js6.5Seconds the invisible hand takes to draw one S.
AUTO_PILOTscript.js2.5After how many seconds without a pointer the invisible hand comes back (0 never).
--velvetstyle.css#4b0b1cThe velvet colour (with --velvet-deep, --velvet-lit and --velvet-sheen it makes the ramp of tones).
--champagnestyle.css#f2dfc4The colour of the name and the lines.

Try them in the Playground

When to use it

Behind the title of a brand that wants to feel warm and luxurious: a hotel, a theatre or its bar, a jeweller, an art house cinema, a tailor, a cocktail lounge. It invites touch without asking for anything: the trail is the first gesture of the visit.

On phones

The same: dragging a finger leaves the trail (the page inside the demo does not scroll), a long press pushes harder. The invisible hand's S is sized on the smaller of width and height, so it stays inside even in a low, wide box; the title is sized on width and height.

With reduced motion

The velvet stands still with a single static shade: the S already brushed once, and nothing else moving. The lines fade in.

Pitfalls

  • Drawing every pixel of the full screen every frame is too much: a map of one cell every 5 pixels is worked out and the browser stretches it. The 1-2-1 softening is done on the map, not with ctx.filter on the big canvas (costly, and missing in older Safari).
  • GSAP's filter (the entrance blur) wipes out the CSS drop-shadow on the words: the shadow sits on the title, the parent, and the blur on the words.
  • Gradient stops must be in order: a stop moved by a variable can end up before the previous one. The sheen on the name moves with background-position and the gradient stays fixed.
  • On resize the map changes size while you watch: the old one is read at the nearest cell, so the trail does not vanish.
  • The invisible hand must not draw a line from where the pointer left: it starts again on its S with its strength growing over 0.9 s.

Libraries

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

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

Testing

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