Use constants for colors in styling example

This commit is contained in:
Héctor Ramón Jiménez 2020-01-07 01:17:32 +01:00
parent b329003c8f
commit fce89d0ffe
2 changed files with 39 additions and 23 deletions

View file

@ -33,6 +33,13 @@ impl Color {
a: 0.0,
};
/// Creates a [`Color`] from its RGB components.
///
/// [`Color`]: struct.Color.html
pub const fn from_rgb(r: f32, g: f32, b: f32) -> Color {
Color { r, g, b, a: 1.0 }
}
/// Creates a [`Color`] from its RGB8 components.
///
/// [`Color`]: struct.Color.html
@ -45,13 +52,6 @@ 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