summaryrefslogtreecommitdiffstats
path: root/graphics/src/geometry/fill.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-03-09 19:05:38 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-09 19:05:38 +0100
commitcaf2836b1b15bff6e8a2ea72441d67f297eb8707 (patch)
tree0ffa0d1d604780999892b88de85ee93e3ed7d539 /graphics/src/geometry/fill.rs
parent11b2c3bbe31a43e73a61b9bd9f022233f302ae27 (diff)
parent424ac8177309440bbd8efe0dd9f7622cb10807ce (diff)
downloadiced-caf2836b1b15bff6e8a2ea72441d67f297eb8707.tar.gz
iced-caf2836b1b15bff6e8a2ea72441d67f297eb8707.tar.bz2
iced-caf2836b1b15bff6e8a2ea72441d67f297eb8707.zip
Merge pull request #1748 from iced-rs/feature/software-renderer
Software renderer, runtime renderer fallback, and core consolidation
Diffstat (limited to 'graphics/src/geometry/fill.rs')
-rw-r--r--graphics/src/geometry/fill.rs63
1 files changed, 63 insertions, 0 deletions
diff --git a/graphics/src/geometry/fill.rs b/graphics/src/geometry/fill.rs
new file mode 100644
index 00000000..2e8c1669
--- /dev/null
+++ b/graphics/src/geometry/fill.rs
@@ -0,0 +1,63 @@
+//! Fill [crate::widget::canvas::Geometry] with a certain style.
+use iced_core::{Color, Gradient};
+
+pub use crate::geometry::Style;
+
+/// The style used to fill geometry.
+#[derive(Debug, Clone)]
+pub struct Fill {
+ /// The color or gradient of the fill.
+ ///
+ /// By default, it is set to [`Style::Solid`] with [`Color::BLACK`].
+ pub style: Style,
+
+ /// The fill rule defines how to determine what is inside and what is
+ /// outside of a shape.
+ ///
+ /// See the [SVG specification][1] for more details.
+ ///
+ /// By default, it is set to `NonZero`.
+ ///
+ /// [1]: https://www.w3.org/TR/SVG/painting.html#FillRuleProperty
+ pub rule: Rule,
+}
+
+impl Default for Fill {
+ fn default() -> Self {
+ Self {
+ style: Style::Solid(Color::BLACK),
+ rule: Rule::NonZero,
+ }
+ }
+}
+
+impl From<Color> for Fill {
+ fn from(color: Color) -> Fill {
+ Fill {
+ style: Style::Solid(color),
+ ..Fill::default()
+ }
+ }
+}
+
+impl From<Gradient> for Fill {
+ fn from(gradient: Gradient) -> Self {
+ Fill {
+ style: Style::Gradient(gradient),
+ ..Default::default()
+ }
+ }
+}
+
+/// The fill rule defines how to determine what is inside and what is outside of
+/// a shape.
+///
+/// See the [SVG specification][1].
+///
+/// [1]: https://www.w3.org/TR/SVG/painting.html#FillRuleProperty
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[allow(missing_docs)]
+pub enum Rule {
+ NonZero,
+ EvenOdd,
+}