canvas

Function canvas 

Source
pub fn canvas(paint: impl Fn(&mut PaintCx<'_>, Size) + 'static) -> Canvas
Expand description

Creates a new Canvas view that can be used for custom painting

A Canvas provides a low-level interface for custom drawing operations. The supplied paint function will be called whenever the view needs to be rendered, and any signals accessed within the paint function will automatically trigger repaints when they change.

ยงExample

use floem::prelude::*;
use palette::css;
use peniko::kurbo::Rect;
canvas(move |cx, size| {
    cx.fill(
        &Rect::ZERO
            .with_size(size)
            .to_rounded_rect(8.),
        css::PURPLE,
        0.,
    );
})
.style(|s| s.size(100, 300));