summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-04 04:52:55 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-04 04:52:55 +0200
commitd4b08462e5a25929ec4df32f242898986902af56 (patch)
tree4c6aaf8519b416ebf075fd780e533543416cc81e /graphics
parent8708101c892540ffc966cf7ee9d66ca5cd2e8ca6 (diff)
downloadiced-d4b08462e5a25929ec4df32f242898986902af56.tar.gz
iced-d4b08462e5a25929ec4df32f242898986902af56.tar.bz2
iced-d4b08462e5a25929ec4df32f242898986902af56.zip
Introduce `Svg` struct in `core::svg`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/geometry.rs2
-rw-r--r--graphics/src/geometry/frame.rs28
-rw-r--r--graphics/src/image.rs25
3 files changed, 11 insertions, 44 deletions
diff --git a/graphics/src/geometry.rs b/graphics/src/geometry.rs
index c7515e46..2b4b45a6 100644
--- a/graphics/src/geometry.rs
+++ b/graphics/src/geometry.rs
@@ -16,7 +16,7 @@ pub use stroke::{LineCap, LineDash, LineJoin, Stroke};
pub use style::Style;
pub use text::Text;
-pub use crate::core::Image;
+pub use crate::core::{Image, Svg};
pub use crate::gradient::{self, Gradient};
use crate::cache::Cached;
diff --git a/graphics/src/geometry/frame.rs b/graphics/src/geometry/frame.rs
index 1a7af8e6..f3c0817c 100644
--- a/graphics/src/geometry/frame.rs
+++ b/graphics/src/geometry/frame.rs
@@ -1,7 +1,6 @@
//! Draw and generate geometry.
-use crate::core::svg;
-use crate::core::{Color, Point, Radians, Rectangle, Size, Vector};
-use crate::geometry::{self, Fill, Image, Path, Stroke, Text};
+use crate::core::{Point, Radians, Rectangle, Size, Vector};
+use crate::geometry::{self, Fill, Image, Path, Stroke, Svg, Text};
/// The region of a surface that can be used to draw geometry.
#[allow(missing_debug_implementations)]
@@ -206,15 +205,7 @@ pub trait Backend: Sized {
);
fn draw_image(&mut self, bounds: Rectangle, image: impl Into<Image>);
-
- 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>);
fn into_geometry(self) -> Self::Geometry;
}
@@ -262,17 +253,8 @@ impl Backend for () {
) {
}
- fn into_geometry(self) -> Self::Geometry {}
-
fn draw_image(&mut self, _bounds: Rectangle, _image: impl Into<Image>) {}
+ fn draw_svg(&mut self, _bounds: Rectangle, _svg: impl Into<Svg>) {}
- fn draw_svg(
- &mut self,
- _handle: &svg::Handle,
- _bounds: Rectangle,
- _color: Option<Color>,
- _rotation: Radians,
- _opacity: f32,
- ) {
- }
+ fn into_geometry(self) -> Self::Geometry {}
}
diff --git a/graphics/src/image.rs b/graphics/src/image.rs
index 2e4f4b5a..67a5e0cf 100644
--- a/graphics/src/image.rs
+++ b/graphics/src/image.rs
@@ -2,7 +2,9 @@
#[cfg(feature = "image")]
pub use ::image as image_rs;
-use crate::core::{image, svg, Color, Radians, Rectangle};
+use crate::core::image;
+use crate::core::svg;
+use crate::core::Rectangle;
/// A raster or vector image.
#[derive(Debug, Clone, PartialEq)]
@@ -11,22 +13,7 @@ pub enum Image {
Raster(image::Image, Rectangle),
/// A vector image.
- Vector {
- /// The handle of a vector image.
- handle: svg::Handle,
-
- /// The [`Color`] filter
- color: Option<Color>,
-
- /// The bounds of the image.
- bounds: Rectangle,
-
- /// The rotation of the image.
- rotation: Radians,
-
- /// The opacity of the image.
- opacity: f32,
- },
+ Vector(svg::Svg, Rectangle),
}
impl Image {
@@ -34,9 +21,7 @@ impl Image {
pub fn bounds(&self) -> Rectangle {
match self {
Image::Raster(image, bounds) => bounds.rotate(image.rotation),
- Image::Vector {
- bounds, rotation, ..
- } => bounds.rotate(*rotation),
+ Image::Vector(svg, bounds) => bounds.rotate(svg.rotation),
}
}
}