Implemented From<Color for Background
This commit is contained in:
parent
ed045b45ba
commit
33ad332ce9
6 changed files with 26 additions and 20 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue