diff options
author | 2023-02-25 15:04:40 +0100 | |
---|---|---|
committer | 2023-02-25 15:04:40 +0100 | |
commit | 1475f5fa58273e45e67ebd94642ae9e1251fe5f9 (patch) | |
tree | 917b1bc1488e9277fbbdb383344f5019686a0f30 /graphics/src/image | |
parent | 573d27eb52bbfacf1b06983b4282f00eb5265bdc (diff) | |
download | iced-1475f5fa58273e45e67ebd94642ae9e1251fe5f9.tar.gz iced-1475f5fa58273e45e67ebd94642ae9e1251fe5f9.tar.bz2 iced-1475f5fa58273e45e67ebd94642ae9e1251fe5f9.zip |
Update `resvg` in `iced_graphics`
Diffstat (limited to 'graphics/src/image')
-rw-r--r-- | graphics/src/image/vector.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/graphics/src/image/vector.rs b/graphics/src/image/vector.rs index 82d77aff..c950ccd6 100644 --- a/graphics/src/image/vector.rs +++ b/graphics/src/image/vector.rs @@ -5,6 +5,8 @@ use crate::Color; use iced_native::svg; use iced_native::Size; +use resvg::tiny_skia; +use resvg::usvg; use std::collections::{HashMap, HashSet}; use std::fs; @@ -21,7 +23,7 @@ impl Svg { pub fn viewport_dimensions(&self) -> Size<u32> { match self { Svg::Loaded(tree) => { - let size = tree.svg_node().size; + let size = tree.size; Size::new(size.width() as u32, size.height() as u32) } @@ -51,20 +53,14 @@ impl<T: Storage> Cache<T> { let svg = match handle.data() { svg::Data::Path(path) => { let tree = fs::read_to_string(path).ok().and_then(|contents| { - usvg::Tree::from_str( - &contents, - &usvg::Options::default().to_ref(), - ) - .ok() + usvg::Tree::from_str(&contents, &usvg::Options::default()) + .ok() }); tree.map(Svg::Loaded).unwrap_or(Svg::NotFound) } svg::Data::Bytes(bytes) => { - match usvg::Tree::from_data( - bytes, - &usvg::Options::default().to_ref(), - ) { + match usvg::Tree::from_data(bytes, &usvg::Options::default()) { Ok(tree) => Svg::Loaded(tree), Err(_) => Svg::NotFound, } @@ -125,6 +121,7 @@ impl<T: Storage> Cache<T> { } else { usvg::FitTo::Height(height) }, + tiny_skia::Transform::default(), img.as_mut(), )?; |