DrawState
Everything the draw tool knows. Shapes, the selection and the history live in one value, so undo covers every edit, including deleting a shape.
This is an interface exported by @mapcairn/core, checked against version 0.2.0.
Signature
import type { DrawState } from "@mapcairn/core";
interface DrawState
Properties
coalesce
readonly coalesce: string | null;
The key of the last coalescing edit. An edit with the same key joins the undo step of the one before, so a drag, or a run of arrow key presses, is one step.
future
readonly future: readonly DrawHistoryEntry[];
The steps undone, which redo reapplies, most recently undone last.
lastEvent
readonly lastEvent: DrawEvent | null;
What the last action did, for announcements. Null before any action.
mode
readonly mode: DrawKind;
The kind of shape the next tap starts.
nextId
readonly nextId: number;
The number the next shape's id gets. Never goes back, so ids stay unique after an undo.
past
readonly past: readonly DrawHistoryEntry[];
The undo steps, oldest first.
selection
readonly selection: DrawSelection | null;
The selected shape and vertex, or null.
serials
readonly serials: Readonly<Record<DrawKind, number>>;
How many shapes of each kind have been named, for labels such as "Polygon 2".
shapes
readonly shapes: readonly DrawShape[];
Every shape in the order drawn. At most one, the last, is unfinished.