Implemented From<Color for Background

This commit is contained in:
Malte Veerman 2019-12-04 22:02:07 +01:00
parent ed045b45ba
commit 33ad332ce9
6 changed files with 26 additions and 20 deletions

View file

@ -7,3 +7,9 @@ pub enum Background {
Color(Color),
// TODO: Add gradient and image variants
}
impl From<Color> for Background {
fn from(color: Color) -> Self {
Background::Color(color)
}
}

View file

@ -37,6 +37,13 @@ impl Color {
}
}
/// Creates a [`Color`] from its RGB components.
///
/// [`Color`]: struct.Color.html
pub fn from_rgb(r: f32, g: f32, b: f32) -> Color {
Color { r, g, b, a: 1.0 }
}
/// Converts the [`Color`] into its linear values.
///
/// [`Color`]: struct.Color.html