fn render_node(&mut self, n: &usvg::Node, ctx: &mut PaintCtx) {
        match *n.borrow() {
            usvg::NodeKind::Path(ref p) => self.render_path(p, ctx),
            usvg::NodeKind::Defs => {
                // children are defs
                for def in n.children() {
                    match &*def.borrow() {
                        usvg::NodeKind::LinearGradient(linear_gradient) => {
                            self.linear_gradient_def(linear_gradient);
                        }
                        usvg::NodeKind::RadialGradient(gradient) => {
                            self.radial_gradient_def(gradient);
                        }
                        other => tracing::error!("unsupported element: {:?}", other),
                    }
                }
            }
            usvg::NodeKind::Group(_) => {
                // TODO I'm not sure if we need to apply the transform, or if usvg has already
                // done it for us? I'm guessing the latter for now, but that could easily be wrong.
                for child in n.children() {
                    self.render_node(&child, ctx);
                }
            }
            _ => {
                // TODO: handle more of the SVG spec.
                tracing::error!("{:?} is unimplemented", n.clone());
            }
        }
    }
/// Take a usvg node and render it to the given context.
Take a usvg node and render it to the given context.
Take a usvg node and render it to the given context .
fn render_node(&mut self, n: &usvg::Node, ctx: &mut PaintCtx) {
        match *n.borrow() {
            usvg::NodeKind::Path(ref p) => self.render_path(p, ctx),
            usvg::NodeKind::Defs => {
                // children are defs
                for def in n.children() {
                    match &*def.borrow() {
                        usvg::NodeKind::LinearGradient(linear_gradient) => {
                            self.linear_gradient_def(linear_gradient);
                        }
                        usvg::NodeKind::RadialGradient(gradient) => {
                            self.radial_gradient_def(gradient);
                        }
                        other => tracing::error!("unsupported element: {:?}", other),
                    }
                }
            }
            usvg::NodeKind::Group(_) => {
                // TODO I'm not sure if we need to apply the transform, or if usvg has already
                // done it for us? I'm guessing the latter for now, but that could easily be wrong.
                for child in n.children() {
                    self.render_node(&child, ctx);
                }
            }
            _ => {
                // TODO: handle more of the SVG spec.
                tracing::error!("{:?} is unimplemented", n.clone());
            }
        }
    }
fn render_node ( & mut self , n : & usvg :: Node , ctx : & mut PaintCtx ) { match * n . borrow ( ) { usvg :: NodeKind :: Path ( ref p ) => self . render_path ( p , ctx ) , usvg :: NodeKind :: Defs => { // children are defs for def in n . children ( ) { match & * def . borrow ( ) { usvg :: NodeKind :: LinearGradient ( linear_gradient ) => { self . linear_gradient_def ( linear_gradient ) ; } usvg :: NodeKind :: RadialGradient ( gradient ) => { self . radial_gradient_def ( gradient ) ; } other => tracing :: error ! ( " " other ) , } } } usvg :: NodeKind :: Group ( _ ) => { // TODO I'm not sure if we need to apply the transform, or if usvg has already // done it for us? I'm guessing the latter for now, but that could easily be wrong. for child in n . children ( ) { self . render_node ( & child , ctx ) ; } } _ => { // TODO: handle more of the SVG spec. tracing :: error ! ( " " n clone ( ) ) ; } } }
Take a usvg node and render it to the given context.
Take a usvg node and render it to the given context .
&mut self
n
&usvg::Node
ctx
&mut PaintCtx
&mut self
n
&usvg::Node
ctx
&mut PaintCtx