Gestures & WebcamPremium

Lightning Hands

A blue-white electric arc stretches between your index fingers and follows the gap between your hands, on your webcam — or with the cursor, no camera.

WebcamMediaPipeHand trackingCanvas 2D

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

Welcome screen of the “Lightning at your fingertips” station — electricity gallery of a science museum — Lightning Hands example 1

① Welcome screen of the “Lightning at your fingertips” station — electricity gallery of a science museum

WhenNobody at the station: two ghost hands trade an arc behind the heading and catch the eye across the room. A visitor taps “Start”, accepts the camera, and the arc now runs between their own index fingers.
WhyThere is nothing to learn: raising your hands is enough, which suits a passing crowd, children included. The idle screen and the experience are the same code, so the station has no demo video to maintain.
SettingsVariant built into the CSS you buy: .hlx-kiosk class on the scene, .hlx-scrim veil, text inside .hlx-kiosk-content, .hlx-cta button carrying data-hlx-start (it starts the camera; the small button only shows up to stop it). Scene stretched to the screen height by the page CSS.
“Light the five lamps” mini-game — booth activity for an energy supplier at a home show — Lightning Hands example 2

② “Light the five lamps” mini-game — booth activity for an energy supplier at a home show

WhenThe player runs an index finger over five lamps drawn in the play area; each one lights up as it is passed, the counter goes up, and the arc stays stretched towards the other hand for the whole round.
WhyThe effect places the index fingertip exactly on the pointer: the page only has to compare that position with the lamps. The game fits in about twenty lines; the show comes with the effect.
SettingsScene without its caption, stretched under a score bar. Lamps and counter belong to the page: its script listens to pointermove on .hlx-scene and lights a lamp within 30 px. With the camera, read point 8 of the tracked hand instead (scene.hlxBase.tracked).
Host's camera thumbnail on the waiting page of a live stream — popular-science channel — Lightning Hands example 3

③ Host's camera thumbnail on the waiting page of a live stream — popular-science channel

WhenBefore going live, the host opens the waiting page: inside the 184 × 144 px thumbnail, ghost hands are already crackling. The host turns the camera on and their own hands take over during the countdown.
WhyThe effect runs in the host's browser; their broadcast software, by capturing the window, is what shows it to viewers. No stream goes through a third-party service to add the lightning.
Settings184 × 144 px frame: aspect-ratio: auto and height: 100% on .hlx-scene, button shrunk to 10 px, privacy sentence hidden inside the thumbnail and repeated under the frame. In the capture the mouse never crosses the thumbnail: the hands move by themselves.

How it works

The script has two parts. The first one, the base, builds a list of hands on every frame, 21 points each. The second one only draws, on a transparent 2D canvas with additive blending: a faint skeleton, a red dot on each fingertip, a hexagonal ring around the index finger, then the arcs. The main arc links both index fingers and never switches off; two thinner arcs (thumbs, middle fingers) and four small arcs between neighbouring fingers of each hand light up for 0.5 to 1.4 s at a time.

Each arc has one node every 15 px (4 to 44 of them), moved by two slow waves and a fast zigzag: the path quivers without ever jumping between frames. Up to four branches appear and die out within 0.2 to 0.45 s, sparks fly from both ends (160 at most), and every stroke is painted four times, from an 18 px halo down to a 1.7 px white core. Brightness rises in short surges at least 0.45 s apart: no flash ever fills the screen.

By default no camera is opened: this is demo mode. The index fingertip of a ghost hand sits on the cursor (mouse, finger or pen) and a second hand faces it; after 2.5 s without movement both hands go back to swaying on their own. The three examples and the captures on this page run in that mode, with the code you buy.

Clicking “Turn camera on” asks the browser for permission and, at the same time, loads the MediaPipe hand detector (a module from cdn.jsdelivr.net, a model from storage.googleapis.com). Detection then runs inside the page: the webcam picture, mirrored under the lightning, goes nowhere. A single transmission still happens, decided by MediaPipe: after the first minute, then minute by minute during detection, the library sends Google (odml.pa.googleapis.com) a few counters — version number, kind of detector, processing times. No photo, no finger coordinates: still worth mentioning in your privacy policy. The camera stops on the second click, when the scene leaves the screen, when the tab is hidden or when another scene on the page starts its own.

Accessibility

  • Keyboard: the camera button is a real <button> with aria-pressed, reached on the first Tab (Option+Tab in Safari unless its default setting was changed), triggered by Enter or Space, with a 2 px focus ring. Demo mode has no keyboard control: without a pointer the ghost hands play by themselves, so keyboard users miss nothing.
  • Status messages: loading, camera on, “no hand detected”, refusals and failures are written into a role="status" pill announced by screen readers. Canvas and video are aria-hidden; the scene carries an aria-label you should adapt to your content.
  • Reduced motion: arcs frozen on a fixed path, three still branches, no sparks, no surges, ghost hands at rest. The hand still follows the cursor, since the visitor is the one moving it, then glides back to its place once the cursor stops.
  • Touch: dragging a finger sideways moves the hand; dragging up or down scrolls the page as usual (touch-action: pan-y). Once the finger lifts, the demo resumes on its own. Measured in Chromium with touch emulation, not on a real phone.
  • Light: no full-screen flash, at most 2.2 brightness changes per second, below the 3-per-second threshold of WCAG 2.3.1. The .hlx-solid class on the scene halves arc brightness and darkens the video.

Browser compatibility

Demo mode: 2D canvas and pointer events, 36 KB of unminified JavaScript, no dependency. In WebKit 26.5, as in Chromium 149 and Firefox 151, two independent scenes run on one page, with no network request and the loop stopped off screen. Camera mode measured with the fake camera of Chromium 149 and Firefox 151: four downloads (about 20 MB, two domains), then MediaPipe's usage record every minute, stream closed on stop; not verified in Safari, whose test engine has no fake camera. The page must be served over https (or localhost).

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

Camera refused, missing, busy or blocked by the page: a message says so for 10 s and the cursor demo never stopped running. Detection module unreachable (offline, CSP): same fallback, and a new click tries again. Without aspect-ratio (before Chrome 88, Firefox 89, Safari 15) the scene is 300 px tall. Without JavaScript, a dark frame remains with the button and the privacy sentence.

The code

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

index.html — structure
<div class="fx-0844-root">
  <div class="hlx-scene" data-hlx-lang="en" role="region" aria-label="Lightning Hands — electric arcs between your fingertips. Cursor demo, camera on request (processed on your device only)">
    <video class="hlx-video" playsinline muted autoplay aria-hidden="true" tabindex="-1"></video>
    <canvas class="hlx-canvas" aria-hidden="true"></canvas>
    <div class="hlx-bar">
      <button class="hlx-btn hlx-cam-btn" type="button" aria-pressed="false">
        <span class="hlx-btn-ico" aria-hidden="true"></span><span class="hlx-btn-txt">Turn camera on</span>
      </button>
      <p class="hlx-privacy">No image ever leaves your device.</p>
    </div>
    <p class="hlx-status" role="status" aria-live="polite"></p>
    <div class="hlx-label" aria-hidden="true">
      <span>Lightning Hands</span>
      <span class="hlx-hint">move the cursor · or turn the camera on</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
Scene size (CSS — .hlx-scene) 100% wide, aspect-ratio: 16 / 10, 240 px minimum To fill a block, give the parent a height, then aspect-ratio: auto; height: 100%. Ghost hands measure 19% of the short side and never go below 34 px: in a frame under 180 px they stop shrinking and end up overlapping.
Kiosk variant (HTML — .hlx-kiosk, data-hlx-start) not in the delivered HTML Adds text on the left over a dark veil and a main button that starts the camera. Any element inside the scene carrying data-hlx-start plays that part.
Texts (JS — TEXT, TEXT_EN) 17 messages, French and English All dynamic messages sit at the top of the script. data-hlx-lang="en" on the scene switches to TEXT_EN; fixed labels (button, privacy) are edited in the HTML.
Number of hands (JS — MAX_HANDS) 2 At 1 there is no arc between hands any more: only the small arcs between fingers remain, 25% larger. Detection gets cheaper.
Brightness and surges (JS — inten = 0.84, + 0.16) 0.84 at rest, 1 during a 0.28 s surge Lower the base for quieter arcs behind text. Do not shorten the 0.45 s gap between two surges: it is what keeps the effect under 3 changes per second.
Colours (JS — strokeArc, SPR_TIP) arcs from blue rgba(40,120,255) to white, red fingertips The four colours in strokeArc go from halo to core. Additive blending needs a dark background: on a light one the arcs vanish.
Smoothing (JS — SMOOTH, HOLD_MS) 0.5 and 220 ms A lower SMOOTH gives steadier hands that lag behind the gesture. HOLD_MS keeps a hand for 220 ms after it disappears, fading, so it does not flicker.
Canvas sharpness (JS — DPR_MAX) 1.5 Pixel-density cap. At 2 the arcs look finer on a Retina screen, for a third more pixels to fill on every frame.
MediaPipe version (JS — MP_VERSION) '1.0.1', pinned The module and the wasm folder must come from the same version. To depend on no CDN, host those files and the model yourself and change the four MP_… addresses.

FAQ

The same effect, driven by the cursor. A refusal shows “Camera not allowed here. The demo keeps running with the cursor.” for 10 s, the button goes back to “Turn camera on” and nothing else changes. Measured in Chromium: after the refusal, the scene keeps animating.
Serve the page over https, otherwise the browser will not open the camera and the effect says so. If you have a CSP, allow cdn.jsdelivr.net and storage.googleapis.com in script-src and connect-src. If a Permissions-Policy header blocks the camera, write camera=(self). Inside an iframe, add allow="camera". These four points are listed at the top of the script. A CSP that leaves odml.pa.googleapis.com out of connect-src blocks MediaPipe's usage record, and detection carries on.
Yes. Each .hlx-scene gets its own instance, demo and button; the detector is downloaded once for all of them. Only one camera stays open at a time: starting the second scene stops the first, measured with two copies of the code in Chromium and Firefox.