Skip to content
nodemode-ai edited this page Nov 8, 2026 · 1 revision

Tools

A tool is a self-registering module: it declares its key, icon, hint, cursor, pointer handlers, keyboard handler, overlay drawing and options. The options bar and the rail are built from these declarations, so adding a tool touches no shell code.

Source path What lives there
frontend/src/extensions/registry.ts Tool and OptionSpec types, registerTool, key lookup, the dashed outline helper
frontend/src/extensions/tools/index.ts registerBuiltinTools, the one place tools are listed
frontend/src/extensions/tools/move.ts Move, eight resize handles, rotation outside the corners, nudge, digit opacity, the Warp grid's control points (Edit > Warp, through engine/mesh-warp.ts, ported from NodeMode's formvis studio), Puppet Warp pins (engine/puppet.ts, rigid moving least squares); with several layers or a folder selected, the handles surround them all and transform them together; with an unlinked mask targeted, the handles move, resize or rotate the mask alone; Cmd-drag a corner handle to free distort (pending until Enter, Escape cancels; groups and folders too), its handles at the corners and the middles of the sides dragging as Edit > Transform's Distort, Skew or Perspective say (distortDragged in engine/distort.ts); Edit > Transform's Scale and Rotate make the handles only scale, or turn, until Enter or Escape; snap guides, editable X, Y, W, H, Scale and Angle fields with Sampling and Snap; dragging inside a selection moves its pixels (Alt duplicates); Enter and Escape apply or cancel a floating selection
frontend/src/extensions/tools/marquee.ts, lasso.ts, wand.ts, select-common.ts Selection tools and the shared modifier-to-mode rule
frontend/src/extensions/tools/brush.ts Brush and Eraser, size and hardness keys, right-drag to resize (Shift: hardness) with the circle pinned at the press, the brush cursor, presets and pen pressure on size and flow (engine/brush-dynamics.ts, ported from NodeMode's formvis studio)
frontend/src/extensions/tools/eyedropper.ts, hand.ts, zoom.ts Sampling (with the sample ring during drags and its Sample Ring option) and navigation
frontend/src/extensions/tools/crop.ts, gradient.ts, shape.ts Crop frame with ratios and snapping to the canvas and visible layers' edges, Straighten with a Level line, Content-Aware edges and Perspective corners, pending gradient with movable ends (Linear, Radial, Angle, Reflected, Diamond, colour-stop presets from engine/gradients.ts, and the Gradient Editor with noise gradients through its Edit button), shape layers (Rectangle, Ellipse, Polygon, Star, Line, Arrow, Heart; the path shapes from engine/shape-paths.ts, ported from NodeMode's formvis studio)
frontend/src/extensions/tools/heal.ts, remove.ts, clone.ts, smear.ts, brush-common.ts Spot Healing, Remove (content-aware fill of the stroke, and Remove Wires and Cables through engine/distractions.ts), Clone Stamp (with the preview inside the brush circle of what a click would stamp), Smear (Liquify, Blur, Sharpen, Smudge; Blur also softens a targeted layer mask), and the brush cursor, keys and options they share
frontend/src/extensions/tools/pen.ts, freeform-pen.ts, curvature-pen.ts, path-select.ts, direct-select.ts The Pen (P), Freeform Pen and Curvature Pen (both through engine/curve-fit.ts), Path Selection and Direct Selection (A): drawing paths, choosing whole subpaths with their path operation, and editing points. Paths fill through fillVector in engine/paths.ts, which applies the operations

Contract

  • Register through registerBuiltinTools; ids are unique, and tools may share a key (the healing tools share J, the pens P, the selection arrows A). Tools that share a key form one slot on the rail (ui/tool-groups.ts), in the order of their order; the first is the slot's default.
  • Change documents only through Engine methods; never touch the DOM.
  • Draw overlays in CSS pixels on the CanvasRenderingContext2D you are given, using colors from ctx.paint().
  • Options are declarative OptionSpec entries; the options bar owns their DOM. It builds each tool's bar once, so a row that applies only sometimes (a shape kind's own settings) is listed always with a when condition, and is shown or hidden in place.
  • cancel must leave no partial edit behind.

Clone this wiki locally