Scene Primitives

ScenePrimitive

Every frame is a flat list of ScenePrimitive values. There are five variants:

#[non_exhaustive]
pub enum ScenePrimitive {
    Rect(RectPrimitive),
    Text(TextPrimitive),
    Line(LinePrimitive),
    Polygon(PolygonPrimitive),
    Image(ImagePrimitive),
}

Custom renderers must include a wildcard arm (_ => {}) when matching ScenePrimitive, since the enum is #[non_exhaustive].

RectPrimitive

Filled rectangle with optional stroke and rounded corners.

FieldTypeDescription
xf64Left edge (logical px)
yf64Top edge (logical px)
widthf64Width (logical px)
heightf64Height (logical px)
fillColorFill color
strokeOption<Color>Stroke color (None = no stroke)
stroke_widthf64Stroke width (logical px)
corner_radiusf64Corner radius (0 = sharp)

Used for: cell backgrounds, headers, selection rectangles, scrollbar elements.

TextPrimitive

Clipped text run with alignment.

FieldTypeDescription
xf64Left edge (logical px)
yf64Baseline y position (logical px)
textStringText content
colorColorText color
font_sizef64Font size (logical px)
boldboolFont weight 600
clipOption<[f64; 4]>Clipping rect [x, y, w, h]
alignTextAlignLeft, Center, or Right

Used for: cell values, headers, row numbers, search highlights.

LinePrimitive

Straight line segment.

FieldTypeDescription
x1, y1f64Start point
x2, y2f64End point
colorColorLine color
widthf64Line width (logical px)

Used for: grid lines, header borders, separator lines.

PolygonPrimitive

Filled convex polygon with optional rounded corners.

FieldTypeDescription
pointsVec<[f64; 2]>Vertices as [x, y] pairs
fillColorFill color
corner_radiusf64Corner radius (0 = sharp)

Used for: sort indicator arrows, scrollbar arrow buttons.

ImagePrimitive

Image loaded from a URL.

FieldTypeDescription
urlStringImage URL
x, yf64Position (logical px)
width, heightf64Available space
corner_radiusf64Rounded clipping
clipOption<[f64; 4]>Clipping rect

Used for: CellFormat::Image and CellFormat::ImageText cells.

Color

pub struct Color { pub r: u8, pub g: u8, pub b: u8, pub a: u8 }

Color::rgb(255, 255, 255)      // opaque white
Color::rgba(0, 0, 0, 128)      // 50% transparent black
color.to_css()                  // "rgba(255,255,255,1.0000)"