term.gfx.canvas

index · term.gfx

Overview

Pixel canvas — an ergonomic Lua wrapper over the C term.gfx_core surface.

The surface holds the raw RGBA bytes and does the per-pixel/blit/serialize work in C; this layer adds the friendly API the rest of the codebase already expects: {r,g,b,a} colour arrays, default fg/bg colours, the drawing primitives (line, circle, poly, quad_tex), blit with table options, and send/display helpers that hand the pixels to the Kitty protocol.

line/circle/poly route to the C span rasterizers when the runtime provides them (line_raw/circle_fill/poly_fill on the surface) and fall back to the Lua walks below on older binaries — the Lua paths double as the reference implementations the C rasterizers are pinned against, so routing changes no pixels. The input normalization and clipping preambles always run in Lua: they encode the NaN/inf/fractional-endpoint laws.

Use canvas:get(x, y) to read a pixel back.

Functions

NameSignature
new_canvasnew_canvas(config) -> canvas

new_canvas(config) -> canvas

Create a new pixel canvas for drawing and displaying images

Returns a canvas object with drawing and display methods.

Config fields:

The canvas is pre-filled with colors.bg on creation.