palette::cast

Function into_uint

source
pub fn into_uint<T>(color: T) -> T::Uint
where T: UintCast,
Expand description

Cast from a color type to an unsigned integer.

use palette::{cast, rgb::PackedArgb, Srgba};

let color: PackedArgb = Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into();
assert_eq!(cast::into_uint(color), 0xFF17C64C);

It’s also possible to use From and Into when casting built-in types:

use palette::Srgba;

let color = Srgba::new(23u8, 198, 76, 255);

// Integers implement `Into`:
let uint1: u32 = color.into();

// Integers implement `From`:
let uint2 = u32::from(color);