diff options
author | 2022-12-13 09:31:57 +0100 | |
---|---|---|
committer | 2022-12-13 09:31:57 +0100 | |
commit | 2e6d90f141217bad83eacd392562c13d7485881f (patch) | |
tree | baa2c507076073aed4fd24abc9c7a7949d85c039 /graphics/src/widget/canvas/fill.rs | |
parent | ba95042fff378213f5029b2b164d79e768482a47 (diff) | |
parent | 02182eea45537c9eb5b2bddfdff822bb8a3d143d (diff) | |
download | iced-2e6d90f141217bad83eacd392562c13d7485881f.tar.gz iced-2e6d90f141217bad83eacd392562c13d7485881f.tar.bz2 iced-2e6d90f141217bad83eacd392562c13d7485881f.zip |
Merge branch 'master' into feat/slider-orientation
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..e954ebb5 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::widget::canvas::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 [`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. @@ -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. /// |