Drafter.Widget.Digits.Image (drafter v0.5.0)

Copy Markdown View Source

Draws Drafter.Widget.Digits text as a transmitted terminal image.

On a terminal supporting the kitty, iTerm2, or sixel protocol, the glyph bitmaps are scaled into a raster and sent as a picture, so strokes land on pixel rather than cell boundaries.

Every function returns nil when no protocol is available, and the widget renders cells instead.

Summary

Functions

Renders text as a Drafter.Render.Picture filling a cell box at the widget's top left.

The pixel protocol in use, or nil when the terminal has none.

Rasterises text at the largest whole scale that fits a cell box.

Functions

picture(text, arg, color, renderer)

@spec picture(String.t(), {pos_integer(), pos_integer()}, tuple(), atom() | nil) ::
  Drafter.Render.Picture.t() | nil

Renders text as a Drafter.Render.Picture filling a cell box at the widget's top left.

Returns nil when the text is empty, the box has no area, or the terminal cannot display an image.

protocol(renderer)

@spec protocol(atom() | nil) :: atom() | nil

The pixel protocol in use, or nil when the terminal has none.

raster(graphemes, arg, color)

@spec raster([String.t()], {pos_integer(), pos_integer()}, tuple()) ::
  FrenchCurve.Raster.t()

Rasterises text at the largest whole scale that fits a cell box.

Scale is never below one; a box too small for native size is handled by the encoder's fit, which scales the finished picture down.