egui_from_hex
EGUI from Hex is a simple, very lightweight and compatible crate to add to any of your projects.
It is made to work with older versions of EGUI, as well as improve the current from_hex() function.
Usage
The syntax is literally just how you use Color32 normally.
Version 0.1.2 added error handling instead of defaulting to black if there were any errors.
If this inconveniences you, you can use the unwrap() function, or switch back to the previous version.
Using the from_u32() function and its siblings:
// For u32
use HexColor;
let color = from_u32;
// For u32 premultiplied
use HexColor;
let color = from_u32_premultiplied;
Note: u32 functions do NOT need to be unwrapped.
Note: Some u32 functions might require bitshifting (as some people might use RRGGBB, AARRGGBB, etc.)
but everything regarding that is explained within the function docs.
If you have any questions, feel free to contact me (Issues | Discussions).
Examples
Using the from_hex() function:
use HexColor;
let color = from_hex.unwrap;
Using the from_hex() function with error handling:
- Using the
matchstatement
use HexColor;
match from_hex
- Using the
if letstatement
use HexColor;
if let Ok = from_hex else
However, it's overkill to use the match or if let statements, you can just use the unwrap() function.
Note: Thank you for using my crate.