Skip to main content

Module kitty

Module kitty 

Source
Expand description

Kitty terminal graphics renderer.

Renders a ChartSpec to an RGB bitmap via plotters, encodes it as PNG via the image crate, then wraps the PNG in kitty’s graphics Application Programming Command (APC) escape sequence so the result can be written directly to stdout inside a kitty-compatible terminal.

Protocol reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/. Key choices:

  • f=100 — the payload is PNG, not raw RGB. Lets the terminal decode via libpng without us having to specify pixel dimensions.
  • a=T — transmit and display immediately at the cursor.
  • m=1/m=0 — chunking. The protocol caps each APC chunk at 4096 base64 characters; any more gets silently dropped.

Structs§

KittyOpts
Dimensions, in pixels, and look of the rendered chart.

Functions§

encode_png_apc
Encode PNG bytes as one or more kitty APC graphics commands. The chunks share an implicit image ID; the final chunk sets m=0 to tell the terminal to display.
render_png
Render spec to an RGBA PNG byte vector: opaque over opts.background, or transparent when there is none. Returns None on any drawing or encoding failure; callers decide whether to substitute a text fallback.