summaryrefslogtreecommitdiffstats
path: root/core/src/background.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-05-11 09:12:06 -0700
committerLibravatar Bingus <shankern@protonmail.com>2023-05-11 11:13:44 -0700
commit6551a0b2ab6c831dd1d3646ecf55180339275e22 (patch)
treede1e4a85b3176f94fd006fed190ef035d3202e49 /core/src/background.rs
parent669f7cc74b2e7918e86a8197916f503f2d3d9b93 (diff)
downloadiced-6551a0b2ab6c831dd1d3646ecf55180339275e22.tar.gz
iced-6551a0b2ab6c831dd1d3646ecf55180339275e22.tar.bz2
iced-6551a0b2ab6c831dd1d3646ecf55180339275e22.zip
Added support for gradients as background variants + other optimizations.
Diffstat (limited to 'core/src/background.rs')
-rw-r--r--core/src/background.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/src/background.rs b/core/src/background.rs
index cfb95867..6af33c3e 100644
--- a/core/src/background.rs
+++ b/core/src/background.rs
@@ -1,11 +1,13 @@
-use crate::Color;
+use crate::{Color, Gradient};
/// 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 {
@@ -19,3 +21,9 @@ impl From<Color> for Option<Background> {
Some(Background::from(color))
}
}
+
+impl From<Gradient> for Option<Background> {
+ fn from(gradient: Gradient) -> Self {
+ Some(Background::Gradient(gradient))
+ }
+}