Function freya::hooks::use_canvas

source ·
pub fn use_canvas<D>(
    dependencies: D,
    renderer_cb: impl Fn(<D as Dependency>::Out) -> Box<dyn Fn(&Canvas, &RCHandle<skia_textlayout_FontCollection>, Rect<f32, Measure>) + Send + Sync> + 'static
) -> UseCanvaswhere
    D: Dependency,
    <D as Dependency>::Out: 'static,
Expand description

Register a rendering hook to gain access to the Canvas.

Usage

fn app() -> Element {
    let canvas = use_canvas((), |_| {
        Box::new(|canvas, font_collection, area| {
            // Draw using the canvas !
        })
    });

    rsx!(
        Canvas {
            canvas
        }
    )
}