diff options
author | 2024-08-04 04:52:55 +0200 | |
---|---|---|
committer | 2024-08-04 04:52:55 +0200 | |
commit | d4b08462e5a25929ec4df32f242898986902af56 (patch) | |
tree | 4c6aaf8519b416ebf075fd780e533543416cc81e /tiny_skia/src/geometry.rs | |
parent | 8708101c892540ffc966cf7ee9d66ca5cd2e8ca6 (diff) | |
download | iced-d4b08462e5a25929ec4df32f242898986902af56.tar.gz iced-d4b08462e5a25929ec4df32f242898986902af56.tar.bz2 iced-d4b08462e5a25929ec4df32f242898986902af56.zip |
Introduce `Svg` struct in `core::svg`
Diffstat (limited to 'tiny_skia/src/geometry.rs')
-rw-r--r-- | tiny_skia/src/geometry.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 7b0e68f4..659612d1 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -1,11 +1,10 @@ -use crate::core::svg; use crate::core::text::LineHeight; -use crate::core::{Color, Pixels, Point, Radians, Rectangle, Size, Vector}; +use crate::core::{self, Pixels, Point, Radians, Rectangle, Size, Svg, Vector}; use crate::graphics::cache::{self, Cached}; use crate::graphics::geometry::fill::{self, Fill}; use crate::graphics::geometry::stroke::{self, Stroke}; -use crate::graphics::geometry::{self, Image, Path, Style}; -use crate::graphics::{self, Gradient, Text}; +use crate::graphics::geometry::{self, Path, Style}; +use crate::graphics::{self, Gradient, Image, Text}; use crate::Primitive; use std::rc::Rc; @@ -282,7 +281,7 @@ impl geometry::frame::Backend for Frame { } } - fn draw_image(&mut self, bounds: Rectangle, image: impl Into<Image>) { + fn draw_image(&mut self, bounds: Rectangle, image: impl Into<core::Image>) { let mut image = image.into(); let (bounds, external_rotation) = @@ -293,24 +292,15 @@ impl geometry::frame::Backend for Frame { self.images.push(graphics::Image::Raster(image, bounds)); } - fn draw_svg( - &mut self, - handle: &svg::Handle, - bounds: Rectangle, - color: Option<Color>, - rotation: Radians, - opacity: f32, - ) { + fn draw_svg(&mut self, bounds: Rectangle, svg: impl Into<Svg>) { + let mut svg = svg.into(); + let (bounds, external_rotation) = transform_rectangle(bounds, self.transform); - self.images.push(graphics::Image::Vector { - handle: handle.clone(), - bounds, - color, - rotation: rotation + external_rotation, - opacity, - }); + svg.rotation += external_rotation; + + self.images.push(Image::Vector(svg, bounds)); } } |