Skip to content
animorio
IT
All components

Generate image button

Buttons, HoverGSAP, Canvas, CSS onlyAdvancedCompressed weight: Demo 10 KBGSAP 28 KBFreeDownload the zip

The Generate image button of an AI image app, in smoked glass on near black, like a Dribbble shot. On the left a small tile holds the preview: at rest a seed of coloured noise that stirs on hover. Pressed, the photo (an orchid at dusk, a koi pond, a sand dune under a low sun) comes out of the noise step by step like a real diffusion model, a thread of light closes around the tile, the picture’s colours spread into the glass and the steps and the percent count up; at the end the picture is sharp, a reflection crosses it, a check draws itself and the button throws its colours on the floor.

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>
<!--
  "Generate image button" 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 Generate image button with the preview that comes out of the noise</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 Generate image button of an AI image tool, dark smoked glass on a near black page. Inside, on the left, a
         small tile with the preview: at rest a dim seed of noise, on hover the noise stirs. Pressed, the image comes
         out of the noise step by step like a real diffusion model, a thin line of light closes around the tile, the
         colours of the picture bleed into the glass and the steps count up. At the end the picture is sharp, a
         reflection crosses it, a check draws itself and the button throws the picture's colours on the floor. -->
    <div class="gi" data-wrap>
      <span class="gi__glow" data-glow aria-hidden="true"></span>
      <button class="gi__btn" type="button" data-btn aria-label="Generate image: orchid at dusk">
        <span class="gi__body" data-body>
          <span class="gi__fill" aria-hidden="true"></span>
          <span class="gi__wash" aria-hidden="true"><span class="gi__wash-light" data-wash></span></span>
          <span class="gi__shine" data-shine aria-hidden="true"></span>
          <span class="gi__sweep" aria-hidden="true"><span class="gi__sweep-band" data-sweep></span></span>
          <span class="gi__edge" aria-hidden="true"></span>
          <span class="gi__row">
            <span class="gi__tile" data-tile aria-hidden="true">
              <span class="gi__tile-face" data-face>
                <canvas class="gi__canvas" data-canvas width="96" height="96"></canvas>
                <span class="gi__tile-gloss"></span>
                <span class="gi__tile-flash" aria-hidden="true"><span class="gi__tile-flash-band" data-flash></span></span>
              </span>
              <svg class="gi__ring" viewBox="0 0 52 52">
                <path class="gi__ring-track" d="M26 1H37A14 14 0 0 1 51 15V37A14 14 0 0 1 37 51H15A14 14 0 0 1 1 37V15A14 14 0 0 1 15 1Z"/>
                <path class="gi__ring-run" data-ring d="M26 1H37A14 14 0 0 1 51 15V37A14 14 0 0 1 37 51H15A14 14 0 0 1 1 37V15A14 14 0 0 1 15 1Z" pathLength="1"/>
              </svg>
            </span>
            <span class="gi__text" aria-hidden="true">
              <span class="gi__state" data-state>
                <span class="gi__title" data-t>Generate image</span>
                <span class="gi__sub" data-s>Orchid at dusk</span>
              </span>
              <span class="gi__state" data-state>
                <span class="gi__title gi__title--busy" data-t>Generating</span>
                <span class="gi__sub" data-s>Step <b class="gi__num" data-step>0</b> of <b class="gi__num" data-steps>30</b></span>
              </span>
              <span class="gi__state" data-state>
                <span class="gi__title" data-t>Image ready</span>
                <span class="gi__sub" data-s>1024 × 1024 · 2.4 s</span>
              </span>
              <span class="gi__state" data-state>
                <span class="gi__title" data-t>Stopped</span>
                <span class="gi__sub" data-s>No credits used</span>
              </span>
            </span>
            <span class="gi__end" aria-hidden="true">
              <span class="gi__end-face" data-end>
                <svg class="gi__spark" data-spark viewBox="0 0 24 24"><path d="M12 3.2c.5 4.6 2.9 7.3 8.8 8.8-5.9 1.5-8.3 4.2-8.8 8.8-.5-4.6-2.9-7.3-8.8-8.8 5.9-1.5 8.3-4.2 8.8-8.8z"/></svg>
                <span class="gi__cost" data-cost>4</span>
              </span>
              <span class="gi__end-face" data-end><span class="gi__pct" data-pct>0</span><span class="gi__pct-unit">%</span></span>
              <span class="gi__end-face" data-end>
                <svg class="gi__check" viewBox="0 0 24 24"><path data-check pathLength="1" d="M6.6 12.6l3.6 3.5 7.2-7.6"/></svg>
              </span>
            </span>
          </span>
        </span>
      </button>
    </div>
    <p class="sr" aria-live="polite" data-live></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.

31 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 “Generate image button” 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

On a near black page, with a soft light from above and a very fine grain, there is only a 60 pixel pill button in smoked glass: its edge is a one pixel thread of light, bright at the top and almost gone at the sides. On the left a 44 pixel tile with round corners and a glass gloss shows the preview, drawn on a canvas: at rest it is a seed of coloured noise where the picture’s colours barely show. In the middle Generate image and under it the prompt, Orchid at dusk; on the right a peach sparkle and the four credits it costs. A fake pointer arrives: the light follows it on the glass, the tile grows and turns three degrees on a spring, the noise stirs and the sparkle turns an eighth. Pressed, the glass sinks and springs back with a little bounce and the generation starts: in thirty steps the blocks of noise get smaller and fainter and a real photo comes out, a pink orchid on a branch with the warm blurred lights of dusk; meanwhile a peach thread of light closes around the tile starting from the top, the picture’s colours spread into the glass from the tile to the right, the label turns into Generating with a light running across it, the steps count up below and the percent on the right. At the last step the picture is sharp: a reflection crosses it diagonally, the tile gives a small hop, the thread widens and fades, the glass bounces again and a reflection crosses all of it, a pale green check draws itself, the label says Image ready with the size and the time, and under the button the floor takes the photo’s colours, pink and orange. Soon after the picture melts into a new seed, the next prompt arrives (three koi, one orange and two white, in the dark water of a pond, then a desert sand dune with a low sun in the haze, each with its own colours) and the loop starts again. Pressed while it works, it stops and goes back to noise.

How it works

The real photo is the target

Each prompt has its own real CC0 photo in the demo folder (an orchid at dusk, three koi, a dune under a low sun), loaded with new Image and decode(). drawImage crops it to a square around the subject (x, y and how tight, z) on a 96 pixel offscreen canvas, with a light vignette: it is the target of the diffusion. The photo’s two colours tint the glass and the floor.

One diffusion step

At every step p goes from 0 to 1: the blocks start at six pixels and go down to one with (1 − p)²; the photo is shrunk to one pixel per block on a small canvas without smoothing and blown up again, weighted by smoothstep(p); on top, in lighter mode, a brightness noise with a little colour per channel, weighted by (1 − smoothstep(p)), written with putImageData on its own canvas and blown up the same way. No pixel of the photo is ever read back.

Real steps, not a fade

GSAP takes p from 0 to 1 in DURATION seconds with power1.inOut, but the tile is redrawn only when the step changes (floor(p · STEPS)): the picture moves forward in jumps like a real generator, and the canvas works only thirty times. The noise uses a linear congruential generator with its own seed, so every recording is the same.

The thread of light and the glass that takes colour

The thread is a rounded rectangle SVG path starting at the top centre, with pathLength 1 and its stroke-dashoffset written by hand on every frame. Behind the words a radial light in the picture’s two colours (CSS variables changed for each prompt) grows with p, and at the end the coloured shadow under the button lights up too.

The states

Rest, hover (light under the pointer with gsap.quickTo, the tile growing, the noise stirring at twelve frames a second on GSAP’s ticker), press, generating, ready and stopped: the labels are stacked and swap with back.out; the autopilot is a timeline that starts from the load event and stops at the first real touch or key.

Values to change

NameFileDefaultWhat it changes
PROMPTSscript.jsOrchid at dusk|Koi pond in deep shade|Sand dune under a low sunThe prompts, one per round, split by |: each goes with its photo, in order.
STEPSscript.js30How many steps the picture takes to come out of the noise.
DURATIONscript.js2.4How many seconds the generation lasts.
NOISEscript.js0.5How bright the noise is: 0.2 faint, 1 strong.
BLOCKSscript.js6How big the noise blocks are at the first step, in canvas pixels.
COSTscript.js4The credits shown next to the sparkle.
SPRINGscript.js1How springy the moves are: 0.4 calm, 2 very bouncy.
HOLDscript.js1.8How many seconds Image ready stays before going back to rest.
AUTOscript.jstrueThe button goes round by itself until someone touches it.

Try them in the Playground

When to use it

For an app or a site that generates images with AI, for the editor of a portfolio or a shop that creates covers and product shots: the button that starts the generation and shows, while it works, what is coming out, the steps and how far along it is, and lets you stop it.

On phones

On the phone the button is at most 86% of the screen wide and a long prompt ends with an ellipsis; there is no hover, so the light under the finger turns on at the touch and the rest is the same.

With reduced motion

Nothing moves or bounces: the labels, the percent and the check swap with a fade, the picture clears in place step by step, the thread of light closes and the colours only grow in strength; the noise at rest does not stir.

Pitfalls

  • With gsap.set the thread’s stroke-dashoffset stayed at 1 all through the generation: GSAP writes it in rounded pixels, and with pathLength 1 the line jumps from empty to full; the thread and the check get their offset written by hand in the style on every frame.
  • The first thread was a rect with rx and started at the top left corner: a hand drawn path starts at the top centre, like a progress ring.
  • With eleven pixel blocks and lots of colour per channel the seed at rest looked like a mosaic of squares: six pixel blocks, less colour per channel and a dimmer noise make it look like grain.
  • Digits with tabular-nums took Mona Sans’s tabular shapes and looked like another typeface: plain digits are used.
  • Reading the photo with getImageData tainted the canvas as soon as the demo was opened from a file on the computer (the zip): «canvas tainted» and no more picture. The diffusion step uses only drawImage and the lighter blend, never reading the photo’s pixels back, and works from a server and from a file.
  • With round line caps the zero length thread left a dot at the top of the tile at the first step: the thread’s opacity grows with its length.
  • The photos arrive after the first frame: the seed at rest is drawn again once they are decoded, and the autopilot starts from load only after decode() of all three, so the first generation never comes out of a black canvas.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 5 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 components