Gestures & WebcamPremium

Finger Frame Filter

Make a frame with the thumb and index finger of each hand: whatever it holds turns thermal, pop art, X-ray, neon or night vision. Without a camera, the frame follows the cursor over a photo.

WebcamMediaPipeHand trackingWebGL

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Gestures & Webcam has 11 effects, all premium. Explore the category →

3 usage examples

Try five looks on one area of the photo — editor of an online print lab — Finger Frame Filter example 1

① Try five looks on one area of the photo — editor of an online print lab

WhenBefore ordering a print, the customer moves the frame over the photo and clicks a look in the column: the framed area changes, the rest of the picture stays as it was shot. They compare, then apply.
WhyThe frame works as a before-and-after comparer: a look is judged on the part that matters, next to the original, without ever transforming the whole photo.
SettingsCamera-free use: the control bar is not in the HTML, the 372 × 326 px scene fills the left area. The list is made of real buttons; a click calls effect.next() until the wanted look is reached (the effect object is read from scene.cflBase), and the page reads effect.fb ten times a second to highlight the current one. Here the photo is the script's own: to use another, replace DEMO_IMAGE.
Reading the values of a night scene — lesson of an online drawing course — Finger Frame Filter example 2

② Reading the values of a night scene — lesson of an online drawing course

WhenThe student reads the lesson and moves the frame over the street. At each change of look, the caption on the left explains what to observe: where the light falls, the four tones, the shape of the bright areas. With the camera on, they frame their own still life with their fingers.
WhyFraming with your fingers is a draughtsman's gesture. Each filter isolates one reading of the picture (light, masses, outlines), and the caption follows without the student having to look for it.
Settings308 × 260 px block with its two buttons, privacy line moved below the caption. The page reads effect.fb (0 to 4) and shows the name, rank and explanation of the look; it controls nothing.
Framing with your fingers like in the movies — sign-up page of a film-making course for teenagers — Finger Frame Filter example 3

③ Framing with your fingers like in the movies — sign-up page of a film-making course for teenagers

WhenThe visitor reads the course description; on the right, two hands make a frame over a night street, close it, open it again, and the picture goes from thermal to pop art. The button under the picture invites them to try with their camera.
WhyThe finger frame is the first gesture taught in film-making: the demonstration shows the course's exercise instead of describing it, and makes you want to try it right away.
Settings336 × 324 px block to the right of the text, pointer-events: none on the scene (the demonstration runs by itself, both buttons stay active), camera button renamed in the HTML. For the capture, the scene script sets the demo cycle (effect.t0) just before a pinch. The shipped CSS also holds a .cfl-kiosk variant with headline and button laid over the picture.

How it works

The other effects in this family draw on top of the picture. This one transforms the picture itself, and only in one area: the quadrilateral whose four corners are the tips of the thumb and index finger of each hand. Inside, every pixel goes through a WebGL shader; outside, nothing changes. A light outline and four small rings mark the frame.

Five filters follow one another. Thermal turns brightness into five colours, from night blue to warm white. Pop art reduces the picture to four flat tones. X-ray is a bluish negative. Neon keeps only the outlines, in magenta on black. Night brightens everything in green with a light grain. These are graphic looks: the thermal filter reads light, not heat.

To change filter, close the frame by bringing thumbs and index fingers together until only a flat band is left, hold for 0.12 s, then open it again: the next filter fades in over 0.6 s. A click or a tap on the scene does the same, and so does the "Filter" button, which shows the name of the current filter. With a single hand, the L of the thumb and index finger gives a parallelogram.

While the camera is off, the effect works on a photo of a street at night, built into the script: the frame follows the cursor, and two drawn hands close it every 6 s. The captures on this page show this mode, with the code you buy. Once the camera is turned on from its button, the photo gives way to your mirrored picture, analysed in the browser by MediaPipe. That picture never leaves the device. MediaPipe does, however, report its usage to Google: a request of a few dozen bytes to odml.pa.googleapis.com one minute after it loads, then one per minute while the camera is filming, with counters and durations and not a single pixel. Worth citing in the privacy policy of the site that embeds the effect.

Accessibility

  • Keyboard: two tab stops, the camera button then the "Filter" button, which moves to the next filter on Enter or Space. Its accessible name repeats its visible text ("Filter: Thermal — change filter") and the button is an aria-live region: its new text is announced.
  • Reduced motion: the drawn hands no longer close the frame by themselves and the grain of the night filter is frozen: at rest, the filtered picture no longer changes. A click still changes filter, with the same fade.
  • Meaning of the filters: each has an accent colour, used by the outline and the dot on the button, but the name is always written out: colour alone carries no information.
  • Touch: a tap without dragging changes filter. The frame follows a sideways slide of the finger, while a vertical slide scrolls the page as usual. Change on tap verified in all three engines, on an emulated touch screen.
  • Light: no hard cut, everything goes through a fade, and the gesture can change filter only once every 0.8 s. The pop art and neon filters give highly saturated colours over a large area when the frame is big.

Browser compatibility

WebGL 1 for the filter, Canvas 2D for the markers. The JavaScript weighs 223 KB unminified, 173 KB of which is the demo photo (a 130 KB WebP encoded in base64): in demo, no network request. Pasted twice into a page, the code gives two independent frames: in Chromium 149, Firefox 151 and WebKit 26.5, clicking the second changes only its filter. Camera mode was run in Chromium and Firefox on a simulated webcam: the detector is a 10.7 MB download, then MediaPipe sends its log to Google once a minute. The gesture was verified in Chromium by simulating the hand landmarks: frame closed then reopened, one filter further; frame kept closed for 4 s, a single change on reopening. A trial video also triggered a change. Safari: camera mode not checked.

Chrome 88+✓ Full (measured)
Firefox 89+✓ Full (measured)
Safari 15+✓ Demo measured · camera not verified
Edge 88+✓ Not verified
iOS Safari 15+✓ Not verified
Android Chrome 88+✓ Not verified

Without WebGL, the frame is cut out in Canvas 2D and the five looks are approximated with canvas CSS filters (ctx.filter); this fallback was not measured, and Safari only knows ctx.filter from version 18. WebGL context lost: the rendering is rebuilt as soon as the browser gives it back. Camera refused: the demo photo stays in place.

The code

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

index.html — structure
<div class="fx-0851-root">
  <div class="cfl-scene" data-cfl-lang="en" role="region" aria-label="Filter Frame — the frame you shape with your fingers filters the picture: thermal, pop art, X-ray, neon, night vision. Cursor demo, camera on request (processed on your device only)">
    <video class="cfl-video" playsinline muted autoplay aria-hidden="true" tabindex="-1"></video>
    <canvas class="cfl-canvas" aria-hidden="true"></canvas>
    <div class="cfl-bar">
      <button class="cfl-btn cfl-cam-btn" type="button" aria-pressed="false">
        <span class="cfl-btn-ico" aria-hidden="true"></span><span class="cfl-btn-txt">Turn camera on</span>
      </button>
      <button class="cfl-btn cfl-filter-btn" type="button" aria-live="polite">
        <span class="cfl-btn-ico" aria-hidden="true"></span><span class="cfl-btn-pre">Filter:</span><span class="cfl-btn-txt">Thermal</span>
      </button>
      <p class="cfl-privacy">No image ever leaves your device.</p>
    </div>
    <p class="cfl-status" role="status" aria-live="polite"></p>
    <canvas class="cfl-gl" aria-hidden="true"></canvas>
    <div class="cfl-label" aria-hidden="true">
      <span>Filter Frame</span>
      <span class="cfl-hint">move the cursor · click to change filter</span>
    </div>
  </div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Your own demo photo (JS — DEMO_IMAGE) night street, 1120 × 700 px An image from your own domain or a data URI, cropped like the video to fill the scene. For an image from another domain, you also need to set crossOrigin on the image in the script and have its server allow it, otherwise WebGL rejects it.
Fade length (JS — FADE_S) 0.6 s Time to go from one filter to the next. Do not go below 0.35 s: a hard change of large saturated areas bothers photosensitive people.
Gesture thresholds (JS — CLOSE_T, OPEN_T) 0.06 and 0.16 Area of the frame divided by the square of its longest diagonal: below the first threshold the frame is "closed", above the second it is "reopened". Bring them closer if the gesture feels too wide.
Hold time and delay (JS — ARM_S, COOL_S) 0.12 s and 0.8 s How long the frame must stay closed, then the minimum delay between two gesture-triggered changes.
Demo pace (JS — DEMO_CYCLE) 6 s Interval between two automatic pinches of the drawn hands. The pinch timings are written in squeezeCurve.
Accent colours (JS — FILTERS) orange, magenta, ice blue, bright magenta, green Colour of the outline and of the button dot for each filter. The colours of the looks themselves are in the FS shader, one function per filter.
Filter names (JS — FX_TEXT.filters) Thermal, Pop art, X-ray, Neon, Night Button texts; the French defaults sit in FX_TEXT, the English ones in FX_TEXT_EN.
Hero variant (HTML — .cfl-kiosk, data-cfl-start) to add to the HTML Already styled in the shipped CSS: a dark veil covers the left of the photo, holding a headline, a paragraph and a button that turns the camera on.

FAQ

No. A webcam cannot see thermal infrared: the filter colours each pixel by its brightness, from night blue for dark to warm white for bright. It is a false-colour look, to be presented as a graphic effect. The same goes for "X-ray", which is a negative, and for "night", which brightens the picture.
Not through an option: the shader only filters the inside of the quadrilateral. You can, however, supply the four corners yourself. In render, the quad variable receives four points in scene pixels; give it the four corners of the scene and the whole picture is filtered.
Read scene.cflBase.effect.fb, a rank from 0 to 4 in the order thermal, pop art, X-ray, neon, night. effect.next() moves to the next one. There is no event and no method to pick a given filter: read the rank again every 100 ms or so and call next() until you reach the one you want, as in the first example.