summaryrefslogtreecommitdiffstats
path: root/graphics/src/image.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/image.rs')
-rw-r--r--graphics/src/image.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/graphics/src/image.rs b/graphics/src/image.rs
index 47a7b30e..c6135e9e 100644
--- a/graphics/src/image.rs
+++ b/graphics/src/image.rs
@@ -7,7 +7,7 @@ use crate::core::svg;
use crate::core::{Color, Rectangle};
/// A raster or vector image.
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq)]
pub enum Image {
/// A raster image.
Raster {
@@ -33,6 +33,17 @@ pub enum Image {
},
}
+impl Image {
+ /// Returns the bounds of the [`Image`].
+ pub fn bounds(&self) -> Rectangle {
+ match self {
+ Image::Raster { bounds, .. } | Image::Vector { bounds, .. } => {
+ *bounds
+ }
+ }
+ }
+}
+
#[cfg(feature = "image")]
/// Tries to load an image by its [`Handle`].
///