fn render_graphics(&mut self, raster: &mut Raster<SRgb8>) -> Result<()> {
        let mut rs = self.state.clone();
        for value in self.parser.clone() {
            let val = value?;
            match val {
                Value::ColorBackground(clr) => {
                    rs.color_ctx.set_background(clr, &val)?;
                }
                Value::ColorForeground(clr) => {
                    rs.color_ctx.set_foreground(clr, &val)?;
                }
                Value::ColorRectangle(rect, clr) => {
                    let mut ctx = rs.color_ctx.clone();
                    // only set foreground color in cloned context
                    ctx.set_foreground(Some(clr), &val)?;
                    let (r, g, b) = ctx.foreground_rgb();
                    let rgb = SRgb8::new(r, g, b);
                    render_rect(raster, rect, rgb, &val)?;
                }
                Value::Graphic(gn, None) => {
                    let g = self.graphic(gn, None)?;
                    g.render_graphic(raster, 1, 1, &rs.color_ctx)?;
                }
                Value::Graphic(gn, Some((x, y, gid))) => {
                    let g = self.graphic(gn, gid)?;
                    let x = x.into();
                    let y = y.into();
                    g.render_graphic(raster, x, y, &rs.color_ctx)?;
                }
                Value::NewPage() | Value::TextRectangle(_) => break,
                _ => (),
            }
        }
        Ok(())
    }
/// Render graphics and color rectangles.
Render graphics and color rectangles.
Render graphics and color rectangles .
fn render_graphics(&mut self, raster: &mut Raster<SRgb8>) -> Result<()> {
        let mut rs = self.state.clone();
        for value in self.parser.clone() {
            let val = value?;
            match val {
                Value::ColorBackground(clr) => {
                    rs.color_ctx.set_background(clr, &val)?;
                }
                Value::ColorForeground(clr) => {
                    rs.color_ctx.set_foreground(clr, &val)?;
                }
                Value::ColorRectangle(rect, clr) => {
                    let mut ctx = rs.color_ctx.clone();
                    // only set foreground color in cloned context
                    ctx.set_foreground(Some(clr), &val)?;
                    let (r, g, b) = ctx.foreground_rgb();
                    let rgb = SRgb8::new(r, g, b);
                    render_rect(raster, rect, rgb, &val)?;
                }
                Value::Graphic(gn, None) => {
                    let g = self.graphic(gn, None)?;
                    g.render_graphic(raster, 1, 1, &rs.color_ctx)?;
                }
                Value::Graphic(gn, Some((x, y, gid))) => {
                    let g = self.graphic(gn, gid)?;
                    let x = x.into();
                    let y = y.into();
                    g.render_graphic(raster, x, y, &rs.color_ctx)?;
                }
                Value::NewPage() | Value::TextRectangle(_) => break,
                _ => (),
            }
        }
        Ok(())
    }
fn render_graphics ( & mut self , raster : & mut Raster < SRgb8 > ) -> Result < ( ) > { let mut rs = self . state . clone ( ) ; for value in self . parser . clone ( ) { let val = value ? ; match val { Value :: ColorBackground ( clr ) => { rs . color_ctx . set_background ( clr , & val ) ? ; } Value :: ColorForeground ( clr ) => { rs . color_ctx . set_foreground ( clr , & val ) ? ; } Value :: ColorRectangle ( rect , clr ) => { let mut ctx = rs . color_ctx . clone ( ) ; // only set foreground color in cloned context ctx . set_foreground ( Some ( clr ) , & val ) ? ; let ( r , g , b ) = ctx . foreground_rgb ( ) ; let rgb = SRgb8 :: new ( r , g , b ) ; render_rect ( raster , rect , rgb , & val ) ? ; } Value :: Graphic ( gn , None ) => { let g = self . graphic ( gn , None ) ? ; g . render_graphic ( raster , 1 , 1 , & rs . color_ctx ) ? ; } Value :: Graphic ( gn , Some ( ( x , y , gid ) ) ) => { let g = self . graphic ( gn , gid ) ? ; let x = x . into ( ) ; let y = y . into ( ) ; g . render_graphic ( raster , x , y , & rs . color_ctx ) ? ; } Value :: NewPage ( ) | Value :: TextRectangle ( _ ) => break , _ => ( ) , } } Ok ( ( ) ) }
Render graphics and color rectangles.
Render graphics and color rectangles .
&mut self
raster
&mut Raster<SRgb8>