diff options
author | 2022-11-03 18:57:09 +0100 | |
---|---|---|
committer | 2022-11-03 18:57:09 +0100 | |
commit | d222b5c8b0befab665c20ba0112b28199df0ae44 (patch) | |
tree | 0ac3a59f04e1c1ca89ff43800efbefd825b015ea /graphics/src/widget/canvas/fill.rs | |
parent | a8f510c39917b2ac42fcc854f0a7eff13aee9838 (diff) | |
parent | f31c8f2504ea7c004c5caed8913e5da28d2e50e2 (diff) | |
download | iced-d222b5c8b0befab665c20ba0112b28199df0ae44.tar.gz iced-d222b5c8b0befab665c20ba0112b28199df0ae44.tar.bz2 iced-d222b5c8b0befab665c20ba0112b28199df0ae44.zip |
Merge pull request #1448 from bungoboingo/fear/linear-gradients
Add linear gradient support to canvas widget
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. /// |