diff --git a/src/core_traits.rs b/src/core_traits.rs index 31b887f..182e1e9 100644 --- a/src/core_traits.rs +++ b/src/core_traits.rs @@ -450,23 +450,23 @@ macro_rules! trait_impls_without_alpha { }; } -trait_impls_without_alpha!(Rgb, 3, [r, g, b], "rgb({}, {}, {})", "rgb(#{:0w$X}{:0w$X}{:0w$X})", "rgb(#{:0w$x}{:0w$x}{:0w$x})"); -trait_impls_without_alpha!(Bgr, 3, [b, g, r], "bgr({}, {}, {})", "bgr(#{:0w$X}{:0w$X}{:0w$X})", "bgr(#{:0w$x}{:0w$x}{:0w$x})"); -trait_impls_without_alpha!(Grb, 3, [g, r, b], "grb({}, {}, {})", "grb(#{:0w$X}{:0w$X}{:0w$X})", "grb(#{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_without_alpha!(Rgb, 3, [r, g, b], "rgb({},{},{})", "rgb(#{:0w$X}{:0w$X}{:0w$X})", "rgb(#{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_without_alpha!(Bgr, 3, [b, g, r], "bgr({},{},{})", "bgr(#{:0w$X}{:0w$X}{:0w$X})", "bgr(#{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_without_alpha!(Grb, 3, [g, r, b], "grb({},{},{})", "grb(#{:0w$X}{:0w$X}{:0w$X})", "grb(#{:0w$x}{:0w$x}{:0w$x})"); trait_impls_without_alpha!(Gray_v09, 1, [v], "gray({})", "gray(#{:0w$X})", "gray(#{:0w$x})"); -trait_impls_without_alpha!(Rgbw, 4, [r, g, b, w], "rgbw({}, {}, {}, {})", "rgbw(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "rgbw(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_without_alpha!(Rgbw, 4, [r, g, b, w], "rgbw({},{},{},{})", "rgbw(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "rgbw(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); use crate::formats::gray::Gray_v08; trait_impls_without_alpha!(Gray_v08, 1, [0], "gray_v0.8({})", "gray_v0.8(#{:0w$X})", "gray_v0.8(#{:0w$x})"); -trait_impls_with_alpha!(Rgba, 4, [r, g, b, a], "rgba({}, {}, {}, {})", "rgba(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "rgba(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); -trait_impls_with_alpha!(Argb, 4, [a, r, g, b], "argb({}, {}, {}, {})", "argb(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "argb(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); -trait_impls_with_alpha!(Bgra, 4, [b, g, r, a], "bgra({}, {}, {}, {})", "bgra(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "bgra(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); -trait_impls_with_alpha!(Abgr, 4, [a, b, g, r], "abgr({}, {}, {}, {})", "abgr(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "abgr(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); -trait_impls_with_alpha!(GrayA, 2, [v, a], "graya({}, {})", "graya(#{:0w$X}{:0w$X})", "graya(#{:0w$x}{:0w$x})"); +trait_impls_with_alpha!(Rgba, 4, [r, g, b, a], "rgba({},{},{},{})", "rgba(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "rgba(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_with_alpha!(Argb, 4, [a, r, g, b], "argb({},{},{},{})", "argb(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "argb(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_with_alpha!(Bgra, 4, [b, g, r, a], "bgra({},{},{},{})", "bgra(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "bgra(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_with_alpha!(Abgr, 4, [a, b, g, r], "abgr({},{},{},{})", "abgr(#{:0w$X}{:0w$X}{:0w$X}{:0w$X})", "abgr(#{:0w$x}{:0w$x}{:0w$x}{:0w$x})"); +trait_impls_with_alpha!(GrayA, 2, [v, a], "graya({},{})", "graya(#{:0w$X}{:0w$X})", "graya(#{:0w$x}{:0w$x})"); use crate::formats::gray_alpha::GrayAlpha_v08; -trait_impls_with_alpha!(GrayAlpha_v08, 2, [0, 1], "graya_v0.8({}, {})", "graya_v0.8(#{:0w$X}{:0w$X})", "graya_v0.8(#{:0w$x}{:0w$x})"); +trait_impls_with_alpha!(GrayAlpha_v08, 2, [0, 1], "graya_v0.8({},{})", "graya_v0.8(#{:0w$X}{:0w$X})", "graya_v0.8(#{:0w$x}{:0w$x})"); #[cfg(test)] #[test] diff --git a/src/legacy/internal/rgb.rs b/src/legacy/internal/rgb.rs index 71a33e2..94e4654 100644 --- a/src/legacy/internal/rgb.rs +++ b/src/legacy/internal/rgb.rs @@ -188,14 +188,14 @@ mod rgb_test { #[test] #[allow(deprecated)] fn test_fmt() { - let red_rgb = RGB::new(255u8, 0, 0); - let red_bgr = BGR::new(255u8, 0, 0); - assert_eq!("rgb(#FF0000)", &format!("{:X}", red_rgb)); - assert_eq!("bgr(#0000FF)", &format!("{:X}", red_bgr)); - assert_eq!("rgb(#ff0000)", &format!("{:x}", red_rgb)); - assert_eq!("bgr(#0000ff)", &format!("{:x}", red_bgr)); - - assert_eq!("rgb(255, 0, 0)", &format!("{}", red_rgb)); - assert_eq!("bgr(0, 0, 255)", &format!("{}", red_bgr)); + let red_rgb = RGB::new(255u8, 1, 0); + let red_bgr = BGR::new(255u8, 1, 0); + assert_eq!("rgb(#FF0100)", &format!("{:X}", red_rgb)); + assert_eq!("bgr(#0001FF)", &format!("{:X}", red_bgr)); + assert_eq!("rgb(#ff0100)", &format!("{:x}", red_rgb)); + assert_eq!("bgr(#0001ff)", &format!("{:x}", red_bgr)); + + assert_eq!("rgb(255,1,0)", &format!("{}", red_rgb)); + assert_eq!("bgr(0,1,255)", &format!("{}", red_bgr)); } } diff --git a/src/legacy/mod.rs b/src/legacy/mod.rs index 7f9dcbd..4d6f24a 100644 --- a/src/legacy/mod.rs +++ b/src/legacy/mod.rs @@ -51,7 +51,7 @@ fn rgb_works() { assert_eq!(0xFF, [rgb].as_bytes()[5]); } - assert_eq!("rgb(1, 2, 3)", format!("{}", RGB::new(1, 2, 3))); + assert_eq!("rgb(1,2,3)", format!("{}", RGB::new(1, 2, 3))); } #[test] @@ -79,7 +79,7 @@ fn rgba_works() { assert_eq!(rgba, rgba.iter().map(|ch| ch).collect()); - assert_eq!("rgba(1, 2, 3, 4)", format!("{}", RGBA::new(1, 2, 3, 4))); + assert_eq!("rgba(1,2,3,4)", format!("{}", RGBA::new(1, 2, 3, 4))); assert_eq!(rgba - rgba, RGBA::new(0, 0, 0, 0)); }