From ea7f2626b11af249510b27001fb6addd7f9210a9 Mon Sep 17 00:00:00 2001 From: Bingus Date: Mon, 29 May 2023 16:44:56 -0700 Subject: Optimized gradient data packing. --- core/src/color.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core') diff --git a/core/src/color.rs b/core/src/color.rs index 1392f28b..e3bbab73 100644 --- a/core/src/color.rs +++ b/core/src/color.rs @@ -145,6 +145,19 @@ impl From<[f32; 4]> for Color { } } +impl Into for Color { + fn into(self) -> u32 { + let [r, g, b, a] = self.into_rgba8(); + + let r = (r as u32) << 24; + let g = (g as u32) << 16; + let b = (b as u32) << 8; + let a = a as u32; + + r | g | b | a + } +} + /// Creates a [`Color`] with shorter and cleaner syntax. /// /// # Examples -- cgit