feat: Add Color::into_rgb8
This commit is contained in:
parent
28f0beee52
commit
0249640213
1 changed files with 13 additions and 0 deletions
|
|
@ -89,6 +89,19 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
/// Converts the [`Color`] into its RGBA8 equivalent.
|
||||
#[must_use]
|
||||
#[allow(clippy::cast_sign_loss)]
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
pub fn into_rgba8(self) -> [u8; 4] {
|
||||
[
|
||||
(self.r * 255.0).round() as u8,
|
||||
(self.g * 255.0).round() as u8,
|
||||
(self.b * 255.0).round() as u8,
|
||||
(self.a * 255.0).round() as u8,
|
||||
]
|
||||
}
|
||||
|
||||
/// Converts the [`Color`] into its linear values.
|
||||
pub fn into_linear(self) -> [f32; 4] {
|
||||
// As described in:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue