pub fn new(canvas: HtmlCanvasElement) -> Self {
        // **get_context()** returns a untyped **JsValue**. **dyn_into::<T>()** performs an
        // upcast into the real type. (Can error when the type does not match)
        // --------------------------------------------------------------------------------
        let ctx = canvas.get_context("2d").unwrap();
        let ctx = ctx.unwrap().dyn_into::<CanvasRenderingContext2d>().unwrap();

        Self {
            canvas_ctx: ctx,
            width: canvas.width(),
            height: canvas.height(),
        }
    }
/// Create a new PXS by creating a drawing cotext atop the **HtmlCanvasElement**.
Create a new PXS by creating a drawing cotext atop the **HtmlCanvasElement**.
Create a new PXS by creating a drawing cotext atop the ** HtmlCanvasElement ** .
pub fn new(canvas: HtmlCanvasElement) -> Self {
        // **get_context()** returns a untyped **JsValue**. **dyn_into::<T>()** performs an
        // upcast into the real type. (Can error when the type does not match)
        // --------------------------------------------------------------------------------
        let ctx = canvas.get_context("2d").unwrap();
        let ctx = ctx.unwrap().dyn_into::<CanvasRenderingContext2d>().unwrap();
        Self {
            canvas_ctx: ctx,
            width: canvas.width(),
            height: canvas.height(),
        }
    }
pub fn new ( canvas : HtmlCanvasElement ) -> Self { // **get_context()** returns a untyped **JsValue**. **dyn_into::<T>()** performs an // upcast into the real type. (Can error when the type does not match) // -------------------------------------------------------------------------------- let ctx = canvas . get_context ( " " ) . unwrap ( ) ; let ctx = ctx . unwrap ( ) . dyn_into :: < CanvasRenderingContext2d > ( ) . unwrap ( ) ; Self { canvas_ctx : ctx , width : canvas . width ( ) , height : canvas . height ( ) , } }
Create a new PXS by creating a drawing cotext atop the **HtmlCanvasElement**.
Create a new PXS by creating a drawing cotext atop the ** HtmlCanvasElement ** .
canvas
HtmlCanvasElement
canvas
HtmlCanvasElement