Function freya_hooks::use_canvas

source ·
pub fn use_canvas<D: Dependency>(
    dependencies: D,
    renderer_cb: impl Fn(D::Out) -> Box<CanvasRunner> + 'static
) -> UseCanvas
where D::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
        }
    )
}