HTML DOM canvas Object for Rust WebAssembly

Create a canvas Object

You can create an <canvas> object using the document.create_element method.


    let canvas = document.create_element("canvas")
    .unwrap()
    .dyn_into::<web_sys::HtmlCanvasElement>()
    .unwrap();

Access a canvas Object

You can access an <canvas> object using the document.get_element_by_id method.


    let button = document.get_element_by_id("my-canvas")
    .unwrap()
    .dyn_into::<web_sys::HtmlCanvasElement>()
    .unwrap();

Properties

Functions

features/dependencies


        features = [
        'HtmlCanvasElement',
        ]

Source Code