Move core::Image::clip_bounds to graphics::Image

This commit is contained in:
Héctor Ramón Jiménez 2025-10-28 19:44:46 +01:00
parent 3cc5bd5dbc
commit 7c11ccb046
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
16 changed files with 189 additions and 88 deletions

View file

@ -7,21 +7,32 @@ use crate::core::image;
use crate::core::svg;
/// A raster or vector image.
#[allow(missing_docs)]
#[derive(Debug, Clone, PartialEq)]
pub enum Image {
/// A raster image.
Raster(image::Image, Rectangle),
Raster {
image: image::Image,
bounds: Rectangle,
clip_bounds: Rectangle,
},
/// A vector image.
Vector(svg::Svg, Rectangle),
Vector {
svg: svg::Svg,
bounds: Rectangle,
clip_bounds: Rectangle,
},
}
impl Image {
/// Returns the bounds of the [`Image`].
pub fn bounds(&self) -> Rectangle {
match self {
Image::Raster(image, bounds) => bounds.rotate(image.rotation),
Image::Vector(svg, bounds) => bounds.rotate(svg.rotation),
Image::Raster { image, bounds, .. } => {
bounds.rotate(image.rotation)
}
Image::Vector { svg, bounds, .. } => bounds.rotate(svg.rotation),
}
}
}