Skip to content
animorio
IT
Back to the library

Light curve photo fix

Images, HoverGSAP, CanvasMediumCompressed weight: Demo 10 KBGSAP 28 KBFreeDownload the zip

The editor of a made-up photo app, Tonewell, in the style of today’s product interfaces: a real, dark photo of a harbour at dusk with its stone lighthouse and, on top of it, a glass panel with the light curve. Pull a point of the curve and the photo brightens and warms up live, the histogram slides along; hold Compare to see the original again, Reset puts everything back.

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>
<!--
  "Light curve photo fix" 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 photo that corrects as you pull the light curve</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" data-stage>
    <!-- the editor of a made-up photo app, Tonewell: an underexposed real photo of a harbour at dusk with its lighthouse
         (porto.webp, CC0) and, floating on it, a
         glass panel with the light curve. Pull a point of the curve and the photo brightens and warms up live, the
         histogram slides with it; hold Compare to see the original again, Reset to start over -->
    <article class="card" data-card aria-label="Tonewell photo editor">
      <header class="top">
        <div class="brand">
          <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M5.6 16.2c3.6.2 5.4-1.6 6.4-4.2s2.8-4.4 6.4-4.4"/></svg>
          <span class="brand__name" data-brand>Tonewell</span>
          <span class="brand__file" data-file>harbor-at-dusk.raw</span>
        </div>
        <span class="chip" data-chip>
          <svg class="chip__tick" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4l2.9 2.8 5.9-6.2"/></svg>
          <span class="chip__text" data-chiptext>Original</span>
        </span>
      </header>

      <figure class="photo" data-photo>
        <canvas class="photo__canvas" data-canvas aria-label="A harbour at dusk with a stone lighthouse on the pier and sailing boat masts behind it" role="img"></canvas>
        <span class="photo__sheen" data-sheen aria-hidden="true"></span>

        <div class="curve" data-curve>
          <svg class="curve__svg" data-svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-label="Light curve" role="group">
            <g class="curve__grid">
              <line x1="25" y1="0" x2="25" y2="100"/><line x1="50" y1="0" x2="50" y2="100"/><line x1="75" y1="0" x2="75" y2="100"/>
              <line x1="0" y1="25" x2="100" y2="25"/><line x1="0" y1="50" x2="100" y2="50"/><line x1="0" y1="75" x2="100" y2="75"/>
            </g>
            <path class="curve__hist" data-hist d=""/>
            <line class="curve__ref" x1="0" y1="100" x2="100" y2="0"/>
            <path class="curve__glow" data-glow d=""/>
            <path class="curve__line" data-line d=""/>
          </svg>
          <button class="handle" data-handle="0" type="button" aria-label="Shadows point"><span></span></button>
          <button class="handle" data-handle="1" type="button" aria-label="Midtones point"><span></span></button>
          <span class="curve__read" data-read>In 150 · Out 150</span>
        </div>
      </figure>

      <footer class="bar">
        <div class="bar__info">
          <span class="bar__label">Light curve</span>
          <span class="bar__hint" data-hint>Drag a point on the curve</span>
        </div>
        <div class="bar__tools">
          <button class="tool" data-compare type="button">
            <svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.2" y="3" width="11.6" height="10" rx="2"/><path d="M8 3v10"/><path class="fill" d="M8 3h3.8a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H8z"/></svg>
            <span>Hold to compare</span>
          </button>
          <button class="tool tool--round" data-reset type="button" aria-label="Reset">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.4 8a4.6 4.6 0 1 0 1.5-3.4"/><path d="M3.2 2.6v2.6h2.6"/></svg>
          </button>
        </div>
      </footer>
    </article>

    <!-- used only when the page can't read the photo's pixels (opened from a file): the same raw look and curve as tables -->
    <svg class="filtri" aria-hidden="true" focusable="false">
      <filter id="tono" color-interpolation-filters="sRGB">
        <feComponentTransfer>
          <feFuncR data-func type="table" tableValues="0 1"/>
          <feFuncG data-func type="table" tableValues="0 1"/>
          <feFuncB data-func type="table" tableValues="0 1"/>
        </feComponentTransfer>
      </filter>
    </svg>

    <svg class="cursor" data-cursor viewBox="0 0 24 24" aria-hidden="true"><path d="M5 2.8v16.4l4.2-4 2.8 6.2 2.9-1.3-2.8-6.1h5.9Z"/></svg>
  </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.

23 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 “Light curve photo fix” 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 warm white background, with a faint orange light behind it, there is a white card with the editor of Tonewell, a made-up photo app: at the top its mark with the name, the file harbor-at-dusk.raw and a grey pill that says Original. In the middle a real photo of a harbour at dusk: on the left the stone lighthouse with its red gallery, at the end of the pier above the rocks, behind it the masts of the sailing boats, the coloured houses on the shore and the dark hill, in front the still water catching the light of the sky. As it comes out of the camera it is dark, flat and a little cold, with its grain. At the bottom right, over the photo, floats a frosted glass panel with the grid, the grey histogram, the dashed diagonal and the black curve with two white points, the shadows and the midtones. The drawn pointer takes the midtones point and pulls it up: the point swells with an orange halo, the curve turns orange with a trail of light, In and Out are written at the top, and the photo brightens and warms up live while the histogram slides to the right. Let go, the point settles with an elastic bounce, a warm sheen crosses the photo and the pill turns orange, Edited, with its tick drawing itself. Then it lowers the shadows a little for contrast, holds Hold to compare, which turns black, and the photo fades back to the dark original while the panel dims; let go, the corrected photo returns. Finally it presses Reset: the arrow spins and the two points go back onto the diagonal. It also really works: the points can be dragged with the mouse or a finger and moved with the arrow keys.

How it works

The photo read once

The real photo, porto.webp, is drawn on a canvas cut like a background-size: cover, as big as the card at the screen’s pixel density (1100 pixels at most). Right after, the pixels are read with getImageData and turned into the raw shot: a power curve that darkens and flattens them, a touch more blue and a random grain with a fixed seed. Those pixels stay in memory: every correction starts again from there. Opened from a file, where the browser won’t let the page read the pixels, the same sum is done by an SVG feComponentTransfer filter with tables computed from the curve.

The curve

The two movable points and the two fixed ends go through a monotone cubic (Fritsch and Carlson), which makes no waves and never leaves the square. From it, a table of 256 values: every channel of every pixel reads it, and the same function draws the SVG path of the curve and its glow.

The colours warming up

How much the curve lifts the middle grey also decides the warmth: red rises a little and blue drops, so as the light grows the sunset gets warmer. The comparison with the original is a number, mix, that GSAP takes from 1 to 0: every pixel is the original plus the correction multiplied by mix.

The histogram and one drawing per frame

Every change marks the photo as dirty, and a single gsap.ticker redraws it at most once per frame. While recolouring, it counts the brightness of one pixel in eight into 48 columns; the histogram chases the new values halfway for a few frames, so it slides instead of jumping.

The point that follows the finger

The point doesn’t jump to where you touch: GSAP takes it there in a little over two tenths of a second with power3.out, kept between its neighbours so the curve never turns back. On release the point settles with an elastic bounce, the pill takes its colour with the tick drawing itself and a soft-light sheen crosses the photo.

Values to change

NameFileDefaultWhat it changes
BRANDscript.js'Tonewell'The name of the made-up photo app, written at the top left.
MID_LIFTscript.js50How far the drawn pointer lifts the midtones point, out of 255.
SHADOWSscript.js16How far the drawn pointer lowers the shadows point, out of 255.
WARMTHscript.js1How much the colours warm up as the light rises: 0 none, 2 a lot.
FOLLOWscript.js0.22The seconds the curve point takes to reach the finger.
COMPAREscript.js1.3The seconds the drawn pointer holds Compare down.
PAUSEscript.js1.2The seconds of pause before the loop starts again.

Try them in the Playground

When to use it

For the page of a photo editing app, a creative tool or a service that fixes photos: it shows in a single gesture what the product does, and the comparison with the original proves it. It also suits the portfolio of a photographer or a retoucher.

On phones

The same animation with adapted sizes: the card is sized on the width and the height of the screen, the curve panel stays a third of the photo, the file name disappears and the buttons keep only their icons under 420 pixels. The points can be dragged with a finger.

With reduced motion

No pointer and nothing moving by itself: the photo arrives already corrected, the comparison with the original is a fade and Reset puts the points back without travelling.

Pitfalls

  • Recolouring the photo on every pointer event redrew it up to three times per frame: every change now only marks the photo as dirty, and a single gsap.ticker does the drawing.
  • Opened from the zip with a double click (file://) the photo makes the canvas “tainted” and getImageData stops with an error: the photo now shows anyway and the curve moves to an SVG feComponentTransfer filter with color-interpolation-filters sRGB (without it the filter works in linear light and the tones come out different), and the histogram starts from the shot’s, measured once.
  • After the comparison the line below said to drag a point even with the photo corrected, because it read the state set to Original during the comparison: now it looks at the points.

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 6 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