Function freya::prelude::use_canvas

pub fn use_canvas<D>(
    cx: &ScopeState,
    dependencies: D,
    renderer_cb: impl Fn(<D as UseFutureDep>::Out) -> Box<dyn Fn(&mut Canvas, &RCHandle<skia_textlayout_FontCollection>, Rect<f32, Measure>) + Sync + Send, Global>
) -> UseCanvaswhere
    D: UseFutureDep,
Expand description

Register a rendering hook to gain access to the Canvas.

Usage

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

    render!(
        Canvas {
            canvas: canvas
        }
    )
}