summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/primitive.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-05-23 13:29:45 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-05-23 13:29:45 +0200
commitd8ba6b0673a33724a177f3a1ba59705527280142 (patch)
tree89482c8d1e3a03e00b3a8151abbb81e30ae5898c /tiny_skia/src/primitive.rs
parent72ed8bcc8def9956e25f3720a3095fc96bb2eef0 (diff)
parent468794d918eb06c1dbebb33c32b10017ad335f05 (diff)
downloadiced-d8ba6b0673a33724a177f3a1ba59705527280142.tar.gz
iced-d8ba6b0673a33724a177f3a1ba59705527280142.tar.bz2
iced-d8ba6b0673a33724a177f3a1ba59705527280142.zip
Merge branch 'master' into feat/text-macro
Diffstat (limited to 'tiny_skia/src/primitive.rs')
-rw-r--r--tiny_skia/src/primitive.rs30
1 files changed, 13 insertions, 17 deletions
diff --git a/tiny_skia/src/primitive.rs b/tiny_skia/src/primitive.rs
index 7718d542..5de51047 100644
--- a/tiny_skia/src/primitive.rs
+++ b/tiny_skia/src/primitive.rs
@@ -1,10 +1,7 @@
use crate::core::Rectangle;
-use crate::graphics::Damage;
-
-pub type Primitive = crate::graphics::Primitive<Custom>;
#[derive(Debug, Clone, PartialEq)]
-pub enum Custom {
+pub enum Primitive {
/// A path filled with some paint.
Fill {
/// The path to fill.
@@ -25,20 +22,19 @@ pub enum Custom {
},
}
-impl Damage for Custom {
- fn bounds(&self) -> Rectangle {
- match self {
- Self::Fill { path, .. } | Self::Stroke { path, .. } => {
- let bounds = path.bounds();
+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(),
- }
- .expand(1.0)
- }
+ Rectangle {
+ x: bounds.x(),
+ y: bounds.y(),
+ width: bounds.width(),
+ height: bounds.height(),
}
}
}