Skip to content

Documentation / @ripl/terminal / dashPixels

Function: dashPixels() ​

dashPixels(pattern, offset, plot): PixelCallback

Defined in: terminal/src/algorithms.ts:511

Wraps a plot callback so pixels landing in a dash gap are dropped.

Arc length is approximated by counting plotted pixels, which is exact for axis-aligned runs and up to √2 short on a diagonal — indistinguishable at braille resolution, and far cheaper than re-parameterizing every command by true arc length. A pattern with an odd number of entries is repeated to an even length, as canvas specifies.

Parameters ​

ParameterTypeDescription
patternnumber[]The dash pattern, alternating dash and gap lengths in pixels.
offsetnumberDistance into the pattern at which the first dash starts.
plotPixelCallbackThe callback to gate.

Returns ​

PixelCallback

A callback that forwards only the pixels falling within a dash, or plot itself when the pattern describes a solid line.