fn update(&mut self, vdom: VirtualNode) -> Result<(), JsValue> {
        self.dom_updater.update(vdom);

        let psd = &self.store.borrow();
        let psd = &psd.psd;
        let psd = psd.as_ref().unwrap();

        // Flatten the PSD into only the pixels from the layers that are currently
        // toggled on.
        let mut psd_pixels = psd
            .flatten_layers_rgba(&|(idx, layer)| {
                let layer_visible = *self
                    .store
                    .borrow()
                    .layer_visibility
                    .get(layer.name())
                    .unwrap();

                layer_visible
            })
            .unwrap();

        let psd_pixels = Clamped(&mut psd_pixels[..]);
        let psd_pixels =
            ImageData::new_with_u8_clamped_array_and_sh(psd_pixels, psd.width(), psd.height())?;

        let canvas: HtmlCanvasElement = document()
            .get_element_by_id("psd-visual")
            .unwrap()
            .dyn_into()?;
        let context = canvas
            .get_context("2d")?
            .unwrap()
            .dyn_into::<web_sys::CanvasRenderingContext2d>()?;

        canvas.set_width(psd.width());
        canvas.set_height(psd.height());

        context.put_image_data(&psd_pixels, 0., 0.)?;

        Ok(())
    }
/// Patch the DOM with a new virtual dom and update our Canvas' pixels
Patch the DOM with a new virtual dom and update our Canvas' pixels
Patch the DOM with a new virtual dom and update our Canvas ' pixels
fn update(&mut self, vdom: VirtualNode) -> Result<(), JsValue> {
        self.dom_updater.update(vdom);
        let psd = &self.store.borrow();
        let psd = &psd.psd;
        let psd = psd.as_ref().unwrap();
        // Flatten the PSD into only the pixels from the layers that are currently
        // toggled on.
        let mut psd_pixels = psd
            .flatten_layers_rgba(&|(idx, layer)| {
                let layer_visible = *self
                    .store
                    .borrow()
                    .layer_visibility
                    .get(layer.name())
                    .unwrap();
                layer_visible
            })
            .unwrap();
        let psd_pixels = Clamped(&mut psd_pixels[..]);
        let psd_pixels =
            ImageData::new_with_u8_clamped_array_and_sh(psd_pixels, psd.width(), psd.height())?;
        let canvas: HtmlCanvasElement = document()
            .get_element_by_id("psd-visual")
            .unwrap()
            .dyn_into()?;
        let context = canvas
            .get_context("2d")?
            .unwrap()
            .dyn_into::<web_sys::CanvasRenderingContext2d>()?;
        canvas.set_width(psd.width());
        canvas.set_height(psd.height());
        context.put_image_data(&psd_pixels, 0., 0.)?;
        Ok(())
    }
fn update ( & mut self , vdom : VirtualNode ) -> Result < ( ) , JsValue > { self . dom_updater . update ( vdom ) ; let psd = & self . store . borrow ( ) ; let psd = & psd . psd ; let psd = psd . as_ref ( ) . unwrap ( ) ; // Flatten the PSD into only the pixels from the layers that are currently // toggled on. let mut psd_pixels = psd . flatten_layers_rgba ( & | ( idx , layer ) | { let layer_visible = * self . store . borrow ( ) . layer_visibility . get ( layer . name ( ) ) . unwrap ( ) ; layer_visible } ) . unwrap ( ) ; let psd_pixels = Clamped ( & mut psd_pixels [ .. ] ) ; let psd_pixels = ImageData :: new_with_u8_clamped_array_and_sh ( psd_pixels , psd . width ( ) , psd . height ( ) ) ? ; let canvas : HtmlCanvasElement = document ( ) . get_element_by_id ( " " ) . unwrap ( ) . dyn_into ( ) ? ; let context = canvas . get_context ( " " ) ? . unwrap ( ) . dyn_into :: < web_sys :: CanvasRenderingContext2d > ( ) ? ; canvas . set_width ( psd . width ( ) ) ; canvas . set_height ( psd . height ( ) ) ; context . put_image_data ( & psd_pixels , 0. , 0. ) ? ; Ok ( ( ) ) }
Patch the DOM with a new virtual dom and update our Canvas' pixels
Patch the DOM with a new virtual dom and update our Canvas ' pixels
&mut self
vdom
VirtualNode
&mut self
vdom
VirtualNode