diff options
author | 2023-05-29 16:44:56 -0700 | |
---|---|---|
committer | 2023-06-06 16:46:20 -0700 | |
commit | ea7f2626b11af249510b27001fb6addd7f9210a9 (patch) | |
tree | b9a685c94c9cd536f74bdf4e20b25de8ac6b5bd8 /core | |
parent | c15f1b5f6575792cc89bb5fba2e613428397e46a (diff) | |
download | iced-ea7f2626b11af249510b27001fb6addd7f9210a9.tar.gz iced-ea7f2626b11af249510b27001fb6addd7f9210a9.tar.bz2 iced-ea7f2626b11af249510b27001fb6addd7f9210a9.zip |
Optimized gradient data packing.
Diffstat (limited to '')
-rw-r--r-- | core/src/color.rs | 13 |
1 files changed, 13 insertions, 0 deletions
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<u32> 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 |