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#
| Parameter | Type |
|---|---|
path | BezierPath |
options | PenToolOptions |
Returns#
PenTool
Properties#
| Property | Type | Description | Defined in |
|---|---|---|---|
slop | number | How 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
phase#
Get Signature#
get phase(): PenPhase;
Where the tool is.
Returns
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#
| Parameter | Type |
|---|---|
p | Vec |
input | PenInput |
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#
| Parameter | Type |
|---|---|
path | BezierPath |
Returns#
void
move()#
move(p: Vec, input?: PenInput): boolean;
A move to p. Returns true when it changed the path.
Parameters#
| Parameter | Type |
|---|---|
p | Vec |
input | PenInput |
Returns#
boolean
up()#
up(): void;
The release. Ends a handle drag. The tool keeps drawing until PenTool.finish or a close.
Returns#
void