pub fn draw_canvas(&mut self, c: &Context, g: &mut G2d) {
        clear([0.0, 0.0, 0.0, 1.0], g);

        while let Some(d) = self.draw_queue.pop_front() {
            match d {
                DrawAction::Clear(color) => {
                    clear(color.into(), g)
                }
                DrawAction::Point(point, color) => {
                    let square = rectangle::square(point.0, point.1, 1.0);
                    Rectangle::new(color.into()).draw(
                        square,
                        &Default::default(),
                        c.transform,
                        g,
                    );
                }
                DrawAction::Image => {
                    // TODO
                }
                DrawAction::Circle { center, radius, line_width, line_color, fill_color } => {
                    let mut ellipse = Ellipse::new_border(
                        line_color.into(),
                        line_width.unwrap_or(1.0),
                    );
                    if let Some(fill_color) = fill_color {
                        ellipse = ellipse.color(fill_color.into());
                    }

                    let circle = ellipse::circle(center.0, center.1, radius);
                    ellipse.draw(
                        circle,
                        &Default::default(),
                        c.transform,
                        g,
                    );
                }
                DrawAction::Arc { center, radius, line_width, line_color, bounds } => {
                    let circle = ellipse::circle(center.0, center.1, radius);
                    CircleArc::new(
                        line_color.into(),
                        line_width.unwrap_or(1.0),
                        bounds.0,
                        bounds.1,
                    ).draw(
                        circle,
                        &Default::default(),
                        c.transform,
                        g,
                    );
                }
                DrawAction::Polygon { vertices, line_color, line_width, fill_color } => {
                    let slice = vertices.as_slice();
                    if let Some(fill) = fill_color {
                        // TODO: add support for concave polygons.
                        Polygon::new(fill.into()).draw(
                            slice,
                            &Default::default(),
                            c.transform,
                            g,
                        );
                    }

                    let l = Line::new(line_color.into(), line_width.unwrap_or(1.0));
                    for i in 0..slice.len() {
                        let p1: [Scalar; 2] = slice[i];
                        let p2: [Scalar; 2] = slice[(i + 1) % slice.len()];
                        let line: [Scalar; 4] = [p1[0], p1[1], p2[0], p2[1]];
                        l.draw(
                            line,
                            &Default::default(),
                            c.transform,
                            g,
                        );
                    }
                }
                _ => (),
            }
        }
    }
/// Draws the `draw_queue` to the graphics context.
Draws the `draw_queue` to the graphics context.
Draws the ` draw_queue ` to the graphics context .
pub fn draw_canvas(&mut self, c: &Context, g: &mut G2d) {
        clear([0.0, 0.0, 0.0, 1.0], g);
        while let Some(d) = self.draw_queue.pop_front() {
            match d {
                DrawAction::Clear(color) => {
                    clear(color.into(), g)
                }
                DrawAction::Point(point, color) => {
                    let square = rectangle::square(point.0, point.1, 1.0);
                    Rectangle::new(color.into()).draw(
                        square,
                        &Default::default(),
                        c.transform,
                        g,
                    );
                }
                DrawAction::Image => {
                    // TODO
                }
                DrawAction::Circle { center, radius, line_width, line_color, fill_color } => {
                    let mut ellipse = Ellipse::new_border(
                        line_color.into(),
                        line_width.unwrap_or(1.0),
                    );
                    if let Some(fill_color) = fill_color {
                        ellipse = ellipse.color(fill_color.into());
                    }
                    let circle = ellipse::circle(center.0, center.1, radius);
                    ellipse.draw(
                        circle,
                        &Default::default(),
                        c.transform,
                        g,
                    );
                }
                DrawAction::Arc { center, radius, line_width, line_color, bounds } => {
                    let circle = ellipse::circle(center.0, center.1, radius);
                    CircleArc::new(
                        line_color.into(),
                        line_width.unwrap_or(1.0),
                        bounds.0,
                        bounds.1,
                    ).draw(
                        circle,
                        &Default::default(),
                        c.transform,
                        g,
                    );
                }
                DrawAction::Polygon { vertices, line_color, line_width, fill_color } => {
                    let slice = vertices.as_slice();
                    if let Some(fill) = fill_color {
                        // TODO: add support for concave polygons.
                        Polygon::new(fill.into()).draw(
                            slice,
                            &Default::default(),
                            c.transform,
                            g,
                        );
                    }
                    let l = Line::new(line_color.into(), line_width.unwrap_or(1.0));
                    for i in 0..slice.len() {
                        let p1: [Scalar; 2] = slice[i];
                        let p2: [Scalar; 2] = slice[(i + 1) % slice.len()];
                        let line: [Scalar; 4] = [p1[0], p1[1], p2[0], p2[1]];
                        l.draw(
                            line,
                            &Default::default(),
                            c.transform,
                            g,
                        );
                    }
                }
                _ => (),
            }
        }
    }
pub fn draw_canvas ( & mut self , c : & Context , g : & mut G2d ) { clear ( [ 0.0 , 0.0 , 0.0 , 1.0 ] , g ) ; while let Some ( d ) = self . draw_queue . pop_front ( ) { match d { DrawAction :: Clear ( color ) => { clear ( color . into ( ) , g ) } DrawAction :: Point ( point , color ) => { let square = rectangle :: square ( point . 0 , point . 1 , 1.0 ) ; Rectangle :: new ( color . into ( ) ) . draw ( square , & Default :: default ( ) , c . transform , g , ) ; } DrawAction :: Image => { // TODO } DrawAction :: Circle { center , radius , line_width , line_color , fill_color } => { let mut ellipse = Ellipse :: new_border ( line_color . into ( ) , line_width . unwrap_or ( 1.0 ) , ) ; if let Some ( fill_color ) = fill_color { ellipse = ellipse . color ( fill_color . into ( ) ) ; } let circle = ellipse :: circle ( center . 0 , center . 1 , radius ) ; ellipse . draw ( circle , & Default :: default ( ) , c . transform , g , ) ; } DrawAction :: Arc { center , radius , line_width , line_color , bounds } => { let circle = ellipse :: circle ( center . 0 , center . 1 , radius ) ; CircleArc :: new ( line_color . into ( ) , line_width . unwrap_or ( 1.0 ) , bounds . 0 , bounds . 1 , ) . draw ( circle , & Default :: default ( ) , c . transform , g , ) ; } DrawAction :: Polygon { vertices , line_color , line_width , fill_color } => { let slice = vertices . as_slice ( ) ; if let Some ( fill ) = fill_color { // TODO: add support for concave polygons. Polygon :: new ( fill . into ( ) ) . draw ( slice , & Default :: default ( ) , c . transform , g , ) ; } let l = Line :: new ( line_color . into ( ) , line_width . unwrap_or ( 1.0 ) ) ; for i in 0 .. slice . len ( ) { let p1 : [ Scalar ; 2 ] = slice [ i ] ; let p2 : [ Scalar ; 2 ] = slice [ ( i + 1 ) % slice . len ( ) ] ; let line : [ Scalar ; 4 ] = [ p1 [ 0 ] , p1 [ 1 ] , p2 [ 0 ] , p2 [ 1 ] ] ; l . draw ( line , & Default :: default ( ) , c . transform , g , ) ; } } _ => ( ) , } } }
Draws the `draw_queue` to the graphics context.
Draws the ` draw_queue ` to the graphics context .
&mut self
c
&Context
g
&mut G2d