make color! macro expand hex as Color directly

This commit is contained in:
Var Bhat 2023-12-22 02:08:36 +05:30 committed by Héctor Ramón Jiménez
parent 6756594fc6
commit 6492d9d927
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -190,7 +190,12 @@ macro_rules! color {
let g = (hex & 0xff00) >> 8;
let b = (hex & 0xff);
$crate::Color::from_rgb8(r as u8, g as u8, b as u8)
$crate::Color {
r: r as f32 / 255.0,
g: g as f32 / 255.0,
b: b as f32 / 255.0,
a: 1.0,
}
}};
($hex:expr, $a:expr) => {{
let hex = $hex as u32;