summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/color.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/src/color.rs b/core/src/color.rs
index 212c1214..e578eda4 100644
--- a/core/src/color.rs
+++ b/core/src/color.rs
@@ -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: