diff options
Diffstat (limited to 'graphics/src/widget/canvas/fill.rs')
-rw-r--r-- | graphics/src/widget/canvas/fill.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/graphics/src/widget/canvas/fill.rs b/graphics/src/widget/canvas/fill.rs index 56495435..c69fc0d7 100644 --- a/graphics/src/widget/canvas/fill.rs +++ b/graphics/src/widget/canvas/fill.rs @@ -1,12 +1,15 @@ -use iced_native::Color; +//! Fill [crate::widget::canvas::Geometry] with a certain style. +use crate::{Color, Gradient}; + +pub use crate::triangle::Style; /// The style used to fill geometry. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] pub struct Fill { - /// The color used to fill geometry. + /// The color or gradient of the fill. /// - /// By default, it is set to `BLACK`. - pub color: Color, + /// By default, it is set to [`FillStyle::Solid`] `BLACK`. + pub style: Style, /// The fill rule defines how to determine what is inside and what is /// outside of a shape. @@ -20,9 +23,9 @@ pub struct Fill { } impl Default for Fill { - fn default() -> Fill { - Fill { - color: Color::BLACK, + fn default() -> Self { + Self { + style: Style::Solid(Color::BLACK), rule: FillRule::NonZero, } } @@ -31,12 +34,21 @@ impl Default for Fill { impl From<Color> for Fill { fn from(color: Color) -> Fill { Fill { - color, + 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. /// |