summaryrefslogtreecommitdiffstats
path: root/graphics/src/geometry/fill.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--graphics/src/geometry/fill.rs (renamed from graphics/src/widget/canvas/fill.rs)29
1 files changed, 15 insertions, 14 deletions
diff --git a/graphics/src/widget/canvas/fill.rs b/graphics/src/geometry/fill.rs
index e954ebb5..b773c99b 100644
--- a/graphics/src/widget/canvas/fill.rs
+++ b/graphics/src/geometry/fill.rs
@@ -1,7 +1,8 @@
//! Fill [crate::widget::canvas::Geometry] with a certain style.
-use crate::{Color, Gradient};
+pub use crate::geometry::Style;
-pub use crate::widget::canvas::Style;
+use crate::core::Color;
+use crate::gradient::{self, Gradient};
/// The style used to fill geometry.
#[derive(Debug, Clone)]
@@ -19,14 +20,14 @@ pub struct Fill {
/// By default, it is set to `NonZero`.
///
/// [1]: https://www.w3.org/TR/SVG/painting.html#FillRuleProperty
- pub rule: FillRule,
+ pub rule: Rule,
}
impl Default for Fill {
fn default() -> Self {
Self {
style: Style::Solid(Color::BLACK),
- rule: FillRule::NonZero,
+ rule: Rule::NonZero,
}
}
}
@@ -49,6 +50,15 @@ impl From<Gradient> for Fill {
}
}
+impl From<gradient::Linear> for Fill {
+ fn from(gradient: gradient::Linear) -> Self {
+ Fill {
+ style: Style::Gradient(Gradient::Linear(gradient)),
+ ..Default::default()
+ }
+ }
+}
+
/// The fill rule defines how to determine what is inside and what is outside of
/// a shape.
///
@@ -57,16 +67,7 @@ impl From<Gradient> for Fill {
/// [1]: https://www.w3.org/TR/SVG/painting.html#FillRuleProperty
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(missing_docs)]
-pub enum FillRule {
+pub enum Rule {
NonZero,
EvenOdd,
}
-
-impl From<FillRule> for lyon::tessellation::FillRule {
- fn from(rule: FillRule) -> lyon::tessellation::FillRule {
- match rule {
- FillRule::NonZero => lyon::tessellation::FillRule::NonZero,
- FillRule::EvenOdd => lyon::tessellation::FillRule::EvenOdd,
- }
- }
-}