Skip to main content

gradient_quad

Function gradient_quad 

Source
pub fn gradient_quad(
    rect: (f32, f32, f32, f32),
    radius: f32,
    from: [u8; 4],
    to: [u8; 4],
    vertical: bool,
) -> ((f32, f32, f32, f32), Vec<u8>)
Expand description

FillGradientGRADIENT quad. Two stops, from at the rect’s top/left edge to to at the bottom/right (pad spread), masked by the rounded rect. params: (corner_radius, vertical ? 1 : 0, 0, 0).

Colors are passed as sRGB (NOT pre-linearized like every other pipeline): tiny-skia interpolates gradient stops in sRGB space, so the shader must mix in sRGB and linearize AFTER — verified by A/B midpoint sampling (linear-space mixing measured +16/255 red at the midpoint of the violet→blue reference gradient vs the CPU path).