summaryrefslogtreecommitdiffstats
path: root/core/src/background.rs
blob: 6af33c3edccdaceea27e0e2ee73c4006ee3198f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::{Color, Gradient};

/// The background of some element.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Background {
    /// A solid color.
    Color(Color),
    /// Linearly interpolate between several colors.
    Gradient(Gradient),
    // TODO: Add image variant
}

impl From<Color> for Background {
    fn from(color: Color) -> Self {
        Background::Color(color)
    }
}

impl From<Color> for Option<Background> {
    fn from(color: Color) -> Self {
        Some(Background::from(color))
    }
}

impl From<Gradient> for Option<Background> {
    fn from(gradient: Gradient) -> Self {
        Some(Background::Gradient(gradient))
    }
}