summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/primitive.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-22 00:38:36 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 07:18:20 +0200
commit0ae1baa37bd7b6607f79b33b8a6d8c5daafde0b2 (patch)
tree7f3d09dca8ea9fae96457d3f9266e014d1d25d80 /tiny_skia/src/primitive.rs
parent8d65e40a1174ecb8225ce9973575bced36e7aeb5 (diff)
downloadiced-0ae1baa37bd7b6607f79b33b8a6d8c5daafde0b2.tar.gz
iced-0ae1baa37bd7b6607f79b33b8a6d8c5daafde0b2.tar.bz2
iced-0ae1baa37bd7b6607f79b33b8a6d8c5daafde0b2.zip
Introduce custom backend-specific primitives
Diffstat (limited to 'tiny_skia/src/primitive.rs')
-rw-r--r--tiny_skia/src/primitive.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/tiny_skia/src/primitive.rs b/tiny_skia/src/primitive.rs
new file mode 100644
index 00000000..0ed24969
--- /dev/null
+++ b/tiny_skia/src/primitive.rs
@@ -0,0 +1,48 @@
+use crate::core::Rectangle;
+use crate::graphics::Damage;
+
+pub type Primitive = crate::graphics::Primitive<Custom>;
+
+#[derive(Debug, Clone, PartialEq)]
+pub enum Custom {
+ /// A path filled with some paint.
+ Fill {
+ /// The path to fill.
+ path: tiny_skia::Path,
+ /// The paint to use.
+ paint: tiny_skia::Paint<'static>,
+ /// The fill rule to follow.
+ rule: tiny_skia::FillRule,
+ /// The transform to apply to the path.
+ transform: tiny_skia::Transform,
+ },
+ /// A path stroked with some paint.
+ Stroke {
+ /// The path to stroke.
+ path: tiny_skia::Path,
+ /// The paint to use.
+ paint: tiny_skia::Paint<'static>,
+ /// The stroke settings.
+ stroke: tiny_skia::Stroke,
+ /// The transform to apply to the path.
+ transform: tiny_skia::Transform,
+ },
+}
+
+impl Damage for Custom {
+ fn bounds(&self) -> Rectangle {
+ match self {
+ Self::Fill { path, .. } | Self::Stroke { path, .. } => {
+ let bounds = path.bounds();
+
+ Rectangle {
+ x: bounds.x(),
+ y: bounds.y(),
+ width: bounds.width(),
+ height: bounds.height(),
+ }
+ .expand(1.0)
+ }
+ }
+ }
+}