Function freya_hooks::use_canvas
source · pub fn use_canvas<D>(
cx: &ScopeState,
dependencies: D,
renderer_cb: impl Fn(D::Out) -> Box<CanvasRunner>
) -> 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
}
)
}