Skip to content

Commit

Permalink
Fix macro hygiene of color!
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Dec 6, 2022
1 parent b205a66 commit c0ca180
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,26 @@ impl From<[f32; 4]> for Color {
#[macro_export]
macro_rules! color {
($r:expr, $g:expr, $b:expr) => {
Color::from_rgb8($r, $g, $b)
$crate::Color::from_rgb8($r, $g, $b)
};
($r:expr, $g:expr, $b:expr, $a:expr) => {
Color::from_rgba8($r, $g, $b, $a)
$crate::Color::from_rgba8($r, $g, $b, $a)
};
($hex:expr) => {{
let hex = $hex as u32;
let r = (hex & 0xff0000) >> 16;
let g = (hex & 0xff00) >> 8;
let b = (hex & 0xff);
Color::from_rgb8(r as u8, g as u8, b as u8)

$crate::Color::from_rgb8(r as u8, g as u8, b as u8)
}};
($hex:expr, $a:expr) => {{
let hex = $hex as u32;
let r = (hex & 0xff0000) >> 16;
let g = (hex & 0xff00) >> 8;
let b = (hex & 0xff);
Color::from_rgba8(r as u8, g as u8, b as u8, $a)

$crate::Color::from_rgba8(r as u8, g as u8, b as u8, $a)
}};
}

Expand Down

0 comments on commit c0ca180

Please sign in to comment.