diff options
author | 2023-05-19 04:37:58 +0200 | |
---|---|---|
committer | 2023-05-19 04:37:58 +0200 | |
commit | cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9 (patch) | |
tree | 349d98171b467b7738874a5ef99ce536512c10eb /core/src/background.rs | |
parent | 8e8b1e1eacc4e2c19c9878625f423c8e09e2d3b9 (diff) | |
parent | f7ed645eddd96f7964268367e24abcb5bb78a979 (diff) | |
download | iced-cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9.tar.gz iced-cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9.tar.bz2 iced-cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9.zip |
Merge pull request #1846 from bungoboingo/feat/background-gradients
[Feature] Gradients for Backgrounds
Diffstat (limited to 'core/src/background.rs')
-rw-r--r-- | core/src/background.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/src/background.rs b/core/src/background.rs index cfb95867..347c52c0 100644 --- a/core/src/background.rs +++ b/core/src/background.rs @@ -1,11 +1,14 @@ +use crate::gradient::{self, Gradient}; use crate::Color; /// The background of some element. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Background { - /// A solid color + /// A solid color. Color(Color), - // TODO: Add gradient and image variants + /// Linearly interpolate between several colors. + Gradient(Gradient), + // TODO: Add image variant } impl From<Color> for Background { @@ -14,8 +17,14 @@ impl From<Color> for Background { } } -impl From<Color> for Option<Background> { - fn from(color: Color) -> Self { - Some(Background::from(color)) +impl From<Gradient> for Background { + fn from(gradient: Gradient) -> Self { + Background::Gradient(gradient) + } +} + +impl From<gradient::Linear> for Background { + fn from(gradient: gradient::Linear) -> Self { + Background::Gradient(Gradient::Linear(gradient)) } } |