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

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

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

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

Renders text as a transmitted image sized to a cell box.

Functions

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.

render(text, arg, color, renderer, id)

@spec render(
  String.t(),
  {pos_integer(), pos_integer()},
  tuple(),
  atom() | nil,
  term()
) ::
  {iodata(), iodata()} | nil

Renders text as a transmitted image sized to a cell box.

Returns {paint, clear} as Drafter.Widget's image/3 expects, or nil when the text is empty, the box has no area, or the terminal cannot display an image.