pub enum Node {
Group(Box<Group>),
Path(Box<Path>),
Image(Box<Image>),
Text(Box<Text>),
}
Expand description
Node’s kind.
Variants§
Implementations§
source§impl Node
impl Node
sourcepub fn abs_transform(&self) -> Transform
pub fn abs_transform(&self) -> Transform
Returns node’s absolute transform.
This method is cheap since absolute transforms are already resolved.
sourcepub fn bounding_box(&self) -> Rect
pub fn bounding_box(&self) -> Rect
Returns node’s bounding box in object coordinates, if any.
sourcepub fn abs_bounding_box(&self) -> Rect
pub fn abs_bounding_box(&self) -> Rect
Returns node’s bounding box in canvas coordinates, if any.
sourcepub fn stroke_bounding_box(&self) -> Rect
pub fn stroke_bounding_box(&self) -> Rect
Returns node’s bounding box, including stroke, in object coordinates, if any.
sourcepub fn abs_stroke_bounding_box(&self) -> Rect
pub fn abs_stroke_bounding_box(&self) -> Rect
Returns node’s bounding box, including stroke, in canvas coordinates, if any.
sourcepub fn abs_layer_bounding_box(&self) -> Option<NonZeroRect>
pub fn abs_layer_bounding_box(&self) -> Option<NonZeroRect>
Element’s “layer” bounding box in canvas units, if any.
For most nodes this is just abs_bounding_box
,
but for groups this is abs_layer_bounding_box
.
See Group::layer_bounding_box
for details.
sourcepub fn subroots<F: FnMut(&Group)>(&self, f: F)
pub fn subroots<F: FnMut(&Group)>(&self, f: F)
Calls a closure for each subroot this Node
has.
The Tree::root
field contain only render-able SVG elements.
But some elements, specifically clip paths, masks, patterns and feImage
can store their own SVG subtrees.
And while one can access them manually, it’s pretty verbose.
This methods allows looping over all SVG elements present in the Tree
.
§Example
fn all_nodes(parent: &usvg::Group) {
for node in parent.children() {
// do stuff...
if let usvg::Node::Group(ref g) = node {
all_nodes(g);
}
// handle subroots as well
node.subroots(|subroot| all_nodes(subroot));
}
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl !RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl !UnwindSafe for Node
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)