Skip to main content

Class: default

Defined in: src/lib/brushes/StrokePath/index.ts:145

Builds a stroke's line from its recorded points and places stamps along it, spacing pixels apart. Works incrementally while drawing: each new point returns the stamps that can now be placed.

Smoothing:

  • Linear (and None): straight lines between points.
  • BezierQuad: quadratic curves through the midpoints between points (no lag).
  • BezierCubic: cubic curves whose handles follow the direction of movement before and after each point (lags one point until the next arrives).

Example​

const path = new StrokePath(SmoothingType.Linear, 5);
path.add({ x: 0, y: 0 }); // [{ x: 0, y: 0 }]
path.add({ x: 10, y: 0 }); // [{ x: 5, y: 0 }, { x: 10, y: 0 }]
path.finish(); // []

Constructors​

Constructor​

new default(smoothing?, spacing?): StrokePath

Defined in: src/lib/brushes/StrokePath/index.ts:159

Parameters​

smoothing?​

SmoothingType = SmoothingType.Linear

spacing?​

number

Returns​

StrokePath

Properties​

step​

readonly step: number

Defined in: src/lib/brushes/StrokePath/index.ts:147

Pixels between stamps

Methods​

add()​

add(point): BrushStrokePoint[]

Defined in: src/lib/brushes/StrokePath/index.ts:170

Add a recorded point. Returns the stamps placed along the line this point completes (the first point always gets a stamp).

Parameters​

point​

BrushStrokePoint

Returns​

BrushStrokePoint[]


finish()​

finish(): BrushStrokePoint[]

Defined in: src/lib/brushes/StrokePath/index.ts:212

Finish the stroke: returns stamps for the last part of the line that was waiting for more points.

Returns​

BrushStrokePoint[]