Skip to main content

brush

Function brush 

Source
pub fn brush(brush: Brush) -> Paint
Expand description

Registers a brush and returns the Paint that names it.

Call it wherever the brush is used, including in a component body that runs every render: the second call with the same brush returns the first call’s id and registers nothing, so a screen painted with the same gradient every frame registers it once and allocates nothing after that.

ⓘ
let sky = brush(Brush::vertical(vec![
    Stop::new(0.0, Color::rgb(0x4a90d9)),
    Stop::new(1.0, Color::rgb(0xffffff)),
]));
rsx! { Surface { background: sky, .. } }