FrenchCurve.Backend.Sixel (FrenchCurve v0.1.3)

Copy Markdown View Source

Renders a raster as a sixel image, a palette-indexed DCS sequence.

Sixel encodes six vertical pixels per character, so the image is written as horizontal bands six pixels tall, one pass per colour used in the band, run-length compressed.

The format is indexed, not truecolour: the image is limited to 256 colours. Rasters with more are quantized by dropping low bits from each channel, as many as it takes to fit.

Sixel has no alpha. Pixels below the alpha threshold are left unwritten and show whatever the terminal already had there, unless :background names a colour to paint them instead.

IO.write(FrenchCurve.Backend.Sixel.render(raster, background: {0, 0, 0}))

Summary

Functions

Returns the DCS sequence that draws raster at the cursor.

Functions

render(raster, opts \\ [])

@spec render(
  FrenchCurve.Raster.t(),
  keyword()
) :: binary()

Returns the DCS sequence that draws raster at the cursor.

Options

  • :alpha_threshold — the smallest alpha treated as an opaque pixel, default 1. Pixels below it are transparent.
  • :background — an {r, g, b} tuple painted behind transparent pixels. Omitted by default, which leaves those pixels unwritten.