Phaser AE

Drawing and gesture recognition

Pro packv3.0.0-32DArcade

A drawing pad that turns pointer movement into clean strokes, a recogniser that names a hand-drawn shape without any training, and playback that redraws a recording. Enough to cast a spell with a circle, sign a name or let a title write itself on screen.

This is a Pro pack. Upgrade to Phaser Pro to use it in your games.See Phaser Pro →

Released October 14, 2026 · updated October 20, 2026

Drawing and gesture recognition: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

What it does

The pad takes pointer samples and builds strokes. Samples nearer than a minimum distance to the last are dropped, so a shaky hand or a fast pointer does not flood the stroke with points a pixel apart. When a stroke ends it is simplified (dropping points that add nothing to its shape), then rounded off, and if its ends meet it becomes a closed shape. Each finished stroke keeps its raw samples and their times, its length, bounds and how long it took to draw. Undo and clear work on the list of strokes.

The recogniser follows the well-known single-stroke method. It resamples a stroke to a fixed number of evenly spaced points, so drawing speed stops mattering; rotates it so its first point sits at a known angle from its centre; scales it to a square and centres it; then compares it point by point with each template, searching a small range of rotations for the best fit. The result is a name and a score from 0 to 1, where above about 0.8 is a confident match. There is no model to train: nine starter gestures are built in (circle, triangle, square, line, vee, caret, zigzag, arrow and spiral), and a game can teach its own shapes at runtime, even several samples under one name.

Playback replays recorded strokes as the partial lines to draw each frame, at the pace they were made or at a constant drawing rate, with a pause between strokes and optional looping, and reports where the pen is now.

Features

  • A drawing pad — strokes from pointer samples, with a minimum sample distance, a minimum stroke length, undo and clear.
  • Clean strokes — simplification and corner-cutting smoothing on finish, and closed-shape detection that can snap the ends together.
  • Stroke maths — strokeLength, strokeBounds, centroid, isClosed, simplify, smooth, resample and signed area, usable on any polyline.
  • A gesture recogniser — single-stroke matching that ignores size, position and rotation, with a score and a ranked list for debugging.
  • Built-in and taught gestures — nine starter shapes in one call, and new templates learned or forgotten at runtime.
  • Playback — recorded strokes redrawn at their own timing, a speed multiple or a constant rate, with looping.

Good for

  • Spell-casting games, where drawing a shape on screen casts the spell it names.
  • Drawing and guessing games that check what the player drew against a set of shapes.
  • Signature and handwriting input, with strokes captured, cleaned and stored.
  • Gesture shortcuts in any game, such as a zigzag to undo or a circle to select.
  • Tutorials that show the player how to draw a gesture by replaying it.
  • Self-drawing titles and logos, laid down stroke by stroke at a steady rate.

Make it yours

The pad takes minDist (default 4), a simplify tolerance (default 2, or 0 to keep every sample), smooth iterations (default 1), closeDist for closed shapes (default 24, or 0 never to close), minLength (default 12) and snapClosed; reprocess reapplies new settings to strokes already drawn. The recogniser's angleRange sets how far it searches for a better rotation (default 45 degrees either way), and match takes a minimum score below which it returns nothing. Playback takes a speed, a constant rate, a gap between strokes and loop.

Two different uses: a spell game that teaches the recogniser only its own five rune shapes, ignores the built-ins and casts when a stroke matches above 0.8; and an attract screen that records a logo drawn once, then replays it on loop at a constant rate as the title writes itself.

Good to know

  • It is rotation-invariant by design, so it cannot tell a shape from the same shape turned upside down; compare the stroke's angle yourself where that matters.
  • It recognises single strokes only; a gesture drawn in several strokes needs a different method.
  • It draws nothing: your game draws the strokes and playback lines it returns.

More Arcade packs

Show all →