Skip to content
D
Documentation

SetStrokePointsCommand

reference
1 min readUpdated

Import it from @grafloria/engine.

Also has every member of Command, listed on its own entry.

Replace an ink stroke's point list, undoable. The stroke-edit tool's commit: a drag that translates a stroke ends in exactly ONE of these at pointer-up.

Mirrors {@link SetLinkPointsCommand }, minus the hasManualWaypoints bookkeeping — a stroke's points are ALWAYS authored content (nothing re-routes them), so there is no derived/manual flag to keep in step.

COLLAB: execute()/undo() each call setPoints exactly ONCE, and points on a stroke is a per-property register, so stroke geometry reaches peers. One gesture therefore puts ONE op on the wire — never per-pointermove spam, never a class instance.

The FROM snapshot is taken from the model on first execute() when the caller did not supply one — but the stroke-edit tool DOES supply it (the gesture-start geometry), because by commit time a live-feedback path may already have the model sitting at TO, and a FROM read then would make undo a no-op.

ts
class SetStrokePointsCommand extends Command

Methods

  • constructor( private strokeId: string, newPoints: readonly StrokePoint[], oldPoints?: readonly StrokePoint[] )
  • override execute(context: CommandContext): void — Execute the command
  • override undo(context: CommandContext): void — Undo the command
  • override canExecute(context: CommandContext): boolean — Check if command can be executed
  • override canUndo(context: CommandContext): boolean — Check if command can be undone
  • override canMergeWith(): boolean — One edit gesture = one undo step; never merge two of them.
  • override serialize(): SerializedCommand — Serialize command
  • override getDescription(): string — Get description for UI

Was this page helpful?