INNER CODE UNIT · Rust
new_from_image
silvia-odwyer/photon · crate/src/lib.rs:135
pub fn new_from_image(image: HtmlImageElement) -> PhotonImage {
set_panic_hook();
let document = web_sys::window().unwrap().document().unwrap();
let canvas = document
.create_element("canvas")
.unwrap()
.dyn_into::<web_sys::HtmlCanvasElement>()
.unwrap();
canvas.set_width(image.width());
canvas.set_height(image.height());
let context = canvas
.get_context("2d")
.unwrap()
.unwrap()