Skip to content

Function: densify()

densify(samples, cusps, config): PenSample[]

Defined in: spline.ts:120

Turn the sample list into a dense polyline that follows the centripetal Catmull-Rom curve through it, splitting into independent runs at every cusp so a corner stays a corner.

The runs share their cusp point — it is the last point of one run and the first of the next — so the path stays continuous (C⁰) while its tangent does not (no C¹). That is precisely what a pen does when it reverses.

Each run gets reflected phantom control points at its ends (2·p₀ − p₁), which makes the curve leave and enter the run along the run's own direction. The naive alternative — duplicating the endpoint — flattens the curve into the endpoint and produces a visible little straightening at the start of every stroke.

Parameters

samples

readonly PenSample[]

cusps

readonly boolean[]

config

DensifyConfig

Returns

PenSample[]