Skip to main content

encode_brush

Function encode_brush 

Source
pub fn encode_brush(
    brush: &Brush,
    transform: Affine,
    encoded_paints: &mut Vec<EncodedPaint>,
) -> BrushEncoding
Expand description

Encode brush into paint’s renderer-facing form, appending to encoded_paints.

transform is the paint transform in effect for the draw; a gradient’s encoded form folds its inverse in, so the same gradient under two transforms yields two encoded entries but still shares one colour ramp.

A gradient that is degenerate or malformed — fewer than two stops, unsorted or out-of-range offsets, a zero-length line, coincident circles, a non-increasing sweep — is not an error: vello_common substitutes a solid fallback, which arrives here as a plain Paint::Solid with no side-table entry and therefore no LutRequest.

Frust’s scene layer only ever constructs Extend::Pad gradients; other extend modes are carried through to the encoded entry untouched for the renderer to honour.