Skip to content

Documentation / @ripl/terminal / thickenPixels

Function: thickenPixels() ​

thickenPixels(width, plot): PixelCallback

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

Widens a rasterization pass by stamping a round brush at every pixel it plots, so a stroke can be more than one dot thick. Thickness is geometry, not color depth: a braille cell is 2×4 dots, so a width is perfectly expressible even though each dot is only lit or unlit.

The brush centres on a dot, so thickness quantises to an odd number of dots — widths of 1, 2, 3, 4 and 5 produce strokes 1, 3, 3, 5 and 5 dots across. Because the brush is round, caps and joins are always round; lineCap, lineJoin and miterLimit have no effect.

Compose this inside dashPixels, never outside it: dash measures arc length by counting the pixels it receives, so thickening first would advance the pattern once per stamped dot rather than once per centreline dot.

Parameters ​

ParameterTypeDescription
widthnumberStroke width in raster pixels.
plotPixelCallbackThe callback to widen.

Returns ​

PixelCallback

A callback that stamps a brush per pixel, or plot itself for a hairline stroke.