Gestures & WebcamPremium

Air Drawing

A neon pen at the tip of your index finger: draw in the air in front of the webcam, raise two fingers to stop, grab a stroke with a pinch, wipe everything with a held fist, then download the drawing. Without a camera, the mouse or a finger draws while pressed.

WebcamMediaPipeHand trackingCanvas 2DNeon

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

A neon "Hello" writes itself next to the headline — home page of a neighbourhood laundromat café — Air Drawing example 1

① A neon "Hello" writes itself next to the headline — home page of a neighbourhood laundromat café

WhenAs the page opens, a hand to the right of the headline writes the word, underlines it, switches to pink and adds a small heart, like the neon sign in the shop window. The visitor has nothing to do or allow.
WhyA sign that writes itself by hand sets the tone of a neighbourhood spot at once. With no camera bar and no action buttons, the effect becomes pure living decoration, and the text keeps the left half.
SettingsA 268 × 290 px scene, recoloured background, data-adw-box="0.06,0.2,0.94,0.84" to place the word, only three swatches, no camera bar or action buttons in the HTML, pointer-events: none. For the capture, the script restarts the shipped code's demo from its beginning on the first pointer move.
Draw the runs on the pitch — tactics board of a futsal club — Air Drawing example 2

② Draw the runs on the pitch — tactics board of a futsal club

WhenDuring the team talk, the coach traces number 8's run on the tablet with a finger, picks orange for the opponents' press, green for the pass. Standing at the screen in the hall, he can do the same with his index finger, camera on.
WhyThe pitch is a plain CSS background; the effect brings the line, one colour per team and Undo when the sketch goes wrong. A held fist wipes the board for the next situation.
SettingsA 374 × 330 px scene over a CSS-drawn pitch, three named swatches (data-adw-rgb), Undo and Clear as icons. The "Hello" is removed with the shipped code's own methods (removeAuto(), userDrew = true). For the capture, the script sends the scene pointerdown, pointermove and pointerup along three paths and clicks the real swatches: the shipped code does the drawing.
Sign a colleague's leaving card — shared online card — Air Drawing example 3

③ Sign a colleague's leaving card — shared online card

WhenEveryone visits the card page, signs under the message with a finger or the mouse, underlines in orange, then downloads the card to print or send.
WhyA hand-drawn signature feels warmer than a typed name. The stroke stays, can be undone if it goes wrong, and the Download button provides the image to share.
SettingsA 340 × 224 px scene inside the card, HTML message above the canvas, pink, orange and cyan palette, Undo and Download as icons. Demo removed as in the previous example; for the capture, a looped signature and an underline are sent to the scene as pointer events. The downloaded PNG holds only the strokes, on the code's midnight-blue background: neither the card's violet gradient nor the HTML message. A complete card would need the page to compose the image itself.

How it works

It is the only effect in the family whose gesture leaves a mark that stays. With the index raised alone, the fingertip draws. The line is not a string of dots: a Catmull-Rom curve runs through the sampled positions (at least 2.5 px apart), thinning when the finger moves fast and thickening when it slows, like a real nib. It is painted twice, an additive glow underneath and an opaque core on top, which gives it its neon tube look.

The rest of the hand works as tools. Index and middle finger raised, or an open hand: the pen lifts and the ring follows the finger without drawing. A thumb-and-index pinch with the other fingers open grabs the nearest stroke (or else the last one) and moves it with the hand. A fist held for 0.6 s clears everything: strokes burst into particles that live 0.9 s and fade out. Pointing at a swatch for 0.5 s fills a ring around it and changes colour. Each gesture has to hold for 0.1 s before it counts, so a hesitating hand does not scrawl over the page.

Three buttons complete the hand: Undo (also Ctrl+Z, or Cmd+Z on a Mac), Clear, Download. The last one builds a PNG in the browser, the strokes over a midnight-blue background painted by the code (not your scene's CSS background), and saves it under a dated name; nothing is uploaded. Finished strokes are kept in two off-screen layers: only the line in progress is redrawn each frame, and everything follows the scene when it resizes.

With the camera off, you draw with the mouse or a finger by holding it down. If nobody draws, a drawn hand has already written "Hello" in cursive; it underlines it, picks pink, adds a heart, waits, wipes it with a fist and starts again. As soon as the visitor draws their first stroke, it steps away for good. The captures on this page show that mode, with the shipped code.

Accessibility

  • What works from the keyboard: camera button, colour swatches (buttons with aria-pressed, colour name spelled out), Undo, Clear and Download, in that order, with Enter or Space. Ctrl+Z undoes in the last scene used, except when focus is in a text field. Drawing itself needs a pointer or a hand: there is no keyboard drawing.
  • Messages: saving the image ("Image saved on your device") or having nothing to save ("Nothing to save yet") is announced in the role="status" pill, like the camera messages. The canvas is hidden from assistive technology: a hand drawing has no text equivalent, so provide one if the content matters.
  • Reduced motion: the demo word, underline and heart are placed at once, the drawn hand stays still, the glow does not pulse, and Clear empties the scene in one go, with no particles or fade.
  • Touch: inside the scene the finger draws, top to bottom included, so the page does not scroll when dragged there. Leave enough margin around the scene on mobile so people can scroll elsewhere. Checked with touch emulation.
  • Light: no flash. Clearing is the liveliest moment: a few hundred coloured particles for under a second, then a fade.

Browser compatibility

Canvas 2D, with two off-screen layers for finished strokes; 66 KB of JavaScript and 11 KB of CSS unminified. Tested with Chromium 149, WebKit 26.5 and Firefox 151: two copies on a page stay independent, nothing is downloaded in the demo, animation stops off screen; Undo, Ctrl+Z, Clear and Download tried in Chromium and Firefox. Simulated camera (Chromium, Firefox): four files on first activation, and the demo "Hello" goes away when the camera starts. A test video let the detector find the hands; drawing, pen up, the pinch that moves a stroke, colour picking and fist clearing were confirmed by injecting hand positions. While detection runs, Google's library sends a short usage report to odml.pa.googleapis.com every minute: version number, processing times, never an image or a stroke. You can mention it in your privacy policy. Safari: camera not verified.

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

Minimum versions set by aspect-ratio. Without toBlob, the image goes through toDataURL. Camera refused, missing or busy, module unreachable: a message, and mouse or finger drawing carries on, existing strokes included. A scene without colour swatches draws in the default colour. Camera access goes through the browser's permission prompt and needs an https page; it stops if the scene scrolls out of view or the tab is hidden, and the strokes stay.

The code

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

index.html — structure
<div class="fx-0854-root">
  <div class="adw-scene" data-adw-lang="en" role="region" aria-label="Air Drawing — your index fingertip draws a neon line. Mouse demo (hold to draw), camera on request (processed on your device only)">
    <video class="adw-video" playsinline muted autoplay aria-hidden="true" tabindex="-1"></video>
    <canvas class="adw-canvas" aria-hidden="true"></canvas>
    <div class="adw-bar">
      <button class="adw-btn adw-cam-btn" type="button" aria-pressed="false">
        <span class="adw-btn-ico" aria-hidden="true"></span><span class="adw-btn-txt">Turn camera on</span>
      </button>
      <p class="adw-privacy">No image ever leaves your device.</p>
    </div>
    <p class="adw-status" role="status" aria-live="polite"></p>
    <div class="adw-label" aria-hidden="true">
      <span>Air Drawing</span>
      <span class="adw-hint">hold the mouse button to draw · or turn the camera on and raise your index finger</span>
    </div>
    <div class="adw-tools">
      <div class="adw-palette" role="group" aria-label="Line colour">
        <button class="adw-swatch" type="button" data-adw-rgb="79,233,255" data-adw-name="cyan" style="--adw-c:#4fe9ff" aria-label="Cyan" title="Cyan" aria-pressed="true"></button>
        <button class="adw-swatch" type="button" data-adw-rgb="255,92,214" data-adw-name="pink" style="--adw-c:#ff5cd6" aria-label="Pink" title="Pink" aria-pressed="false"></button>
        <button class="adw-swatch" type="button" data-adw-rgb="176,255,84" data-adw-name="green" style="--adw-c:#b0ff54" aria-label="Green" title="Green" aria-pressed="false"></button>
        <button class="adw-swatch" type="button" data-adw-rgb="255,176,64" data-adw-name="orange" style="--adw-c:#ffb040" aria-label="Orange" title="Orange" aria-pressed="false"></button>
        <button class="adw-swatch" type="button" data-adw-rgb="184,150,255" data-adw-name="violet" style="--adw-c:#b896ff" aria-label="Violet" title="Violet" aria-pressed="false"></button>
      </div>
      <div class="adw-actions">
        <button class="adw-btn adw-tool adw-undo" type="button" aria-label="Undo the last stroke (Ctrl+Z)" title="Undo the last stroke (Ctrl+Z)">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 2.5 7 6 10.5M2.5 7h7a4 4 0 0 1 0 8H8"/></svg><span class="adw-btn-txt">Undo</span>
        </button>
        <button class="adw-btn adw-tool adw-clear" type="button" aria-label="Clear everything" title="Clear everything">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.7 9h6.6l.7-9"/></svg><span class="adw-btn-txt">Clear</span>
        </button>
        <button class="adw-btn adw-tool adw-save" type="button" aria-label="Download the drawing (PNG image, saved on your device)" title="Download the drawing (PNG)">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2.5v8m0 0L4.8 7.3M8 10.5l3.2-3.2M2.5 12.5v1h11v-1"/></svg><span class="adw-btn-txt">Download</span>
        </button>
      </div>
    </div>
  </div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Colours (HTML — data-adw-rgb, data-adw-name on each swatch) cyan, pink, green, orange, violet Add, remove or rename swatches; the first one is the starting colour. With no swatch at all, the line uses the default colour.
Where the demo word goes (HTML — data-adw-box, data-adw-box-portrait) 0.06,0.16,0.78,0.84 Rectangle in scene fractions (left, top, right, bottom) where "Hello" is written, with a variant for scenes taller than wide.
Buttons that start the camera (HTML — data-adw-start) none Any button in the scene with this attribute switches the camera on, in addition to the bar button.
Gesture holding times (JS — GEST_HOLD, FIST_HOLD, DWELL) 0.1 s, 0.6 s, 0.5 s Time before a gesture is adopted, length of the clearing fist, and time spent pointing at a swatch. Lengthen FIST_HOLD if drawings get wiped by accident.
Line resolution (JS — PT_MIN) 2.5 px Minimum gap between two recorded points. Larger gives a smoother, lighter line; smaller keeps the detail.
Clearing (JS — FADE_T, PART_T, MAX_PARTS) 0.45 s, 0.9 s, 420 Fade duration, particle life and maximum particle count.
Download file name and messages (JS — TEXT_FX, TEXT_FX_EN) dessin-dans-l-air, air-drawing Start of the PNG name (today's date is appended) and the texts shown after saving.

FAQ

The strokes live in scene.adwBase.effect.strokes: an array of objects with their points (pts, in scene pixels) and colour (rgb). You can store them as JSON to redraw later, or read the canvas as an image. The code sends them nowhere: that is up to your page, if you want it.
No: raising the index is enough to draw, and the buttons do the rest (colour, Undo, Clear). The other gestures let people stay away from the screen. The help line shown when the camera starts recalls the three main ones.
Because the scene keeps dragging for drawing (touch-action: none): otherwise every vertical stroke would scroll the page instead of drawing. On mobile, keep the scene smaller than the screen and leave margin around it for scrolling.