Skip to content
pixi-silk
GitHub repository
Class

PenTool

import { PenTool } from 'pixi-silk/ui/pathgizmo';

The pen tool’s state machine, without pointer events or drawing: feed it presses, moves and releases in path coordinates and read the path back. A click adds a corner. A drag pulls out mirrored handles, and Alt moves only the outgoing one. A click on the first anchor closes the path, and a click on the last one drops its outgoing handle. PathGizmo drives one.

Constructors#

Constructor#

new PenTool(path?: BezierPath, options?: PenToolOptions): PenTool;

Parameters#

ParameterType
pathBezierPath
optionsPenToolOptions

Returns#

PenTool

Properties#

PropertyTypeDescriptionDefined in
slopnumberHow far a press must move, in path units, before it pulls out handles.ui/pathgizmo.ts:72

Accessors#

cursor#

Get Signature#

get cursor(): Vec | null;

The last pointer position, for the rubber band.

Returns

Vec | null


path#

Get Signature#

get path(): BezierPath;

The path as drawn so far.

Returns

BezierPath


phase#

Get Signature#

get phase(): PenPhase;

Where the tool is.

Returns

PenPhase


preview#

Get Signature#

get preview(): Cubic | null;

The segment the next click would add, from the last anchor to the cursor, or null.

Returns

Cubic | null

Methods#

down()#

down(p: Vec, input?: PenInput): string | null;

A press at p. Returns the label of what it changed, or null when it changed nothing.

Parameters#

ParameterType
pVec
inputPenInput

Returns#

string | null


finish()#

finish(): boolean;

Stops drawing and leaves the path open. Returns false when it was not drawing.

Returns#

boolean


load()#

load(path: BezierPath): void;

Starts from path (a closed one leaves nothing to draw) and stops drawing.

Parameters#

ParameterType
pathBezierPath

Returns#

void


move()#

move(p: Vec, input?: PenInput): boolean;

A move to p. Returns true when it changed the path.

Parameters#

ParameterType
pVec
inputPenInput

Returns#

boolean


up()#

up(): void;

The release. Ends a handle drag. The tool keeps drawing until PenTool.finish or a close.

Returns#

void