diff options
author | 2024-08-04 04:52:55 +0200 | |
---|---|---|
committer | 2024-08-04 04:52:55 +0200 | |
commit | d4b08462e5a25929ec4df32f242898986902af56 (patch) | |
tree | 4c6aaf8519b416ebf075fd780e533543416cc81e /wgpu/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 '')
-rw-r--r-- | wgpu/src/geometry.rs | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 6b1bb074..be65ba36 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -1,18 +1,17 @@ //! Build and draw geometry. -use crate::core::svg; use crate::core::text::LineHeight; use crate::core::{ - Color, Pixels, Point, Radians, Rectangle, Size, Transformation, Vector, + self, Pixels, Point, Radians, Rectangle, Size, Svg, Transformation, Vector, }; use crate::graphics::cache::{self, Cached}; use crate::graphics::color; use crate::graphics::geometry::fill::{self, Fill}; use crate::graphics::geometry::{ - self, Image, LineCap, LineDash, LineJoin, Path, Stroke, Style, + self, LineCap, LineDash, LineJoin, Path, Stroke, Style, }; use crate::graphics::gradient::{self, Gradient}; use crate::graphics::mesh::{self, Mesh}; -use crate::graphics::{self, Text}; +use crate::graphics::{Image, Text}; use crate::text; use crate::triangle; @@ -26,7 +25,7 @@ use std::sync::Arc; pub enum Geometry { Live { meshes: Vec<Mesh>, - images: Vec<graphics::Image>, + images: Vec<Image>, text: Vec<Text>, }, Cached(Cache), @@ -35,7 +34,7 @@ pub enum Geometry { #[derive(Debug, Clone)] pub struct Cache { pub meshes: Option<triangle::Cache>, - pub images: Option<Arc<[graphics::Image]>>, + pub images: Option<Arc<[Image]>>, pub text: Option<text::Cache>, } @@ -98,7 +97,7 @@ pub struct Frame { clip_bounds: Rectangle, buffers: BufferStack, meshes: Vec<Mesh>, - images: Vec<graphics::Image>, + images: Vec<Image>, text: Vec<Text>, transforms: Transforms, fill_tessellator: tessellation::FillTessellator, @@ -292,7 +291,7 @@ impl geometry::frame::Backend for Frame { height: f32::INFINITY, }; - self.text.push(graphics::Text::Cached { + self.text.push(Text::Cached { content: text.content, bounds, color: text.color, @@ -376,7 +375,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) = @@ -384,27 +383,18 @@ impl geometry::frame::Backend for Frame { image.rotation += external_rotation; - self.images.push(graphics::Image::Raster(image, bounds)); + self.images.push(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) = self.transforms.current.transform_rectangle(bounds); - self.images.push(graphics::Image::Vector { - handle: handle.clone(), - color, - bounds, - rotation: rotation + external_rotation, - opacity, - }); + svg.rotation += external_rotation; + + self.images.push(Image::Vector(svg, bounds)); } } |