Is there a macro which converts u32 hex value to 3 u8 bit values for colors?

I am using egui for a project of mine, I currently have a variable which is u32 which stores a hex value of a color.

I was wondering if there was a crate which using a macro or whatever it converts u32 to three tuples of u8 or arrays or whatever which can be used with egui's color picker?

You don't need a crate or a macro for this. It should be as easy as picking out 8 bits at a time from the u32 (assuming it follows the normal convention of packing the raw RGB(A) bytes into a single wider integer). You can either use explicit bit operations for this purpose, or use u32's built-in methods, such as to_le_bytes().

What does this return?

I've linked the relevant docs, you can click the link to find out.

1 Like

ok thanks

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.