2023-05-11 09:12:06 -07:00
|
|
|
use crate::{Color, Gradient};
|
2019-10-08 03:13:41 +02:00
|
|
|
|
2019-11-18 07:16:19 +01:00
|
|
|
/// The background of some element.
|
2019-10-08 03:13:41 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
|
pub enum Background {
|
2023-05-11 09:12:06 -07:00
|
|
|
/// A solid color.
|
2019-10-08 03:13:41 +02:00
|
|
|
Color(Color),
|
2023-05-11 09:12:06 -07:00
|
|
|
/// Linearly interpolate between several colors.
|
|
|
|
|
Gradient(Gradient),
|
|
|
|
|
// TODO: Add image variant
|
2019-10-08 03:13:41 +02:00
|
|
|
}
|
2019-12-04 22:02:07 +01:00
|
|
|
|
|
|
|
|
impl From<Color> for Background {
|
|
|
|
|
fn from(color: Color) -> Self {
|
|
|
|
|
Background::Color(color)
|
|
|
|
|
}
|
2020-01-01 17:27:14 +01:00
|
|
|
}
|
2020-08-19 01:30:22 +02:00
|
|
|
|
|
|
|
|
impl From<Color> for Option<Background> {
|
|
|
|
|
fn from(color: Color) -> Self {
|
|
|
|
|
Some(Background::from(color))
|
|
|
|
|
}
|
2020-08-19 01:30:46 +02:00
|
|
|
}
|
2023-05-11 09:12:06 -07:00
|
|
|
|
|
|
|
|
impl From<Gradient> for Option<Background> {
|
|
|
|
|
fn from(gradient: Gradient) -> Self {
|
|
|
|
|
Some(Background::Gradient(gradient))
|
|
|
|
|
}
|
|
|
|
|
}
|