diff options
author | 2024-04-10 15:21:42 +0200 | |
---|---|---|
committer | 2024-04-10 15:21:42 +0200 | |
commit | 1e802e776cb591f3860d1bfbaa1423d356fc8456 (patch) | |
tree | 6d18b7ed93daac1f56346f1a18b16da9e378419d /tiny_skia/src/primitive.rs | |
parent | 14b9708f723f9fc730634e7ded3dec7dc912ce34 (diff) | |
download | iced-1e802e776cb591f3860d1bfbaa1423d356fc8456.tar.gz iced-1e802e776cb591f3860d1bfbaa1423d356fc8456.tar.bz2 iced-1e802e776cb591f3860d1bfbaa1423d356fc8456.zip |
Reintroduce damage tracking for `iced_tiny_skia`
Diffstat (limited to 'tiny_skia/src/primitive.rs')
-rw-r--r-- | tiny_skia/src/primitive.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tiny_skia/src/primitive.rs b/tiny_skia/src/primitive.rs index 5305788d..5de51047 100644 --- a/tiny_skia/src/primitive.rs +++ b/tiny_skia/src/primitive.rs @@ -1,3 +1,5 @@ +use crate::core::Rectangle; + #[derive(Debug, Clone, PartialEq)] pub enum Primitive { /// A path filled with some paint. @@ -19,3 +21,20 @@ pub enum Primitive { stroke: tiny_skia::Stroke, }, } + +impl Primitive { + /// Returns the visible bounds of the [`Primitive`]. + pub fn visible_bounds(&self) -> Rectangle { + let bounds = match self { + Primitive::Fill { path, .. } => path.bounds(), + Primitive::Stroke { path, .. } => path.bounds(), + }; + + Rectangle { + x: bounds.x(), + y: bounds.y(), + width: bounds.width(), + height: bounds.height(), + } + } +} |