Skip to content

BrushTool

Color-picking surface of the brush, reached via PixelArtCanvas.tools.brush. Distinct from Brush; only exposes the pick-into-brush.primary behavior.

ts
export interface BrushTool {
  pickArmed: boolean;
  pick(x: number, y: number): RGBA | null;
}

Three independent paths sample a pixel color into brush.primary:

PathTriggerNotes
pickArmed = trueNext left-click in "paint" modeSingle-shot; auto-disarms. Switching mode disarms it.
pick(x, y)Called directly, anytimeReturns RGBA or null if out-of-bounds
Ctrl+right-clickMousedown in "paint" modeSingle-shot; never starts a secondary stroke

IMPORTANT

All paths dispatch a "colorpicked" CustomEvent (detail: { hex, opacity }, bubbling and composed) on canvas(). Use it to sync a UI color swatch.