diff --git a/Cargo.lock b/Cargo.lock index 8c24532..6f7743c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -730,7 +730,7 @@ dependencies = [ [[package]] name = "material-colors" -version = "0.1.6" +version = "0.2.1" dependencies = [ "ahash", "image", diff --git a/Cargo.toml b/Cargo.toml index 386d4df..975c613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "material-colors" -version = "0.1.6" +version = "0.2.1" edition = "2021" description = "Up-to-date material-color-utilities port" documentation = "https://docs.rs/material-colors" diff --git a/README.md b/README.md index 93adecb..00f9117 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,12 @@ There are also a relatively large number of unused variables and functions (45 w From HEX color: ```rust +use std::str::FromStr; use material_colors::theme_from_source_color; -use material_colors::argb_from_hex; +use material_colors::Argb; fn main() { - let theme = theme_from_source_color(argb_from_hex("#AAE5A4"), Default::default()); + let theme = theme_from_source_color(Argb::from_str("#AAE5A4"), Default::default()); // Do whatever you want... } diff --git a/src/utils/image.rs b/src/utils/image.rs index 4f3a2d3..3584dd6 100644 --- a/src/utils/image.rs +++ b/src/utils/image.rs @@ -39,7 +39,11 @@ impl AsPixels for Image { fn as_pixels(&self) -> Vec { self.image .pixels() - .map(|pixel| u32::from_be_bytes(pixel.0).rotate_right(8).to_be_bytes()) + .map(|pixel| { + let [a, r, g, b] = u32::from_be_bytes(pixel.0).rotate_right(8).to_be_bytes(); + + Argb::new(a, r, g, b) + }) .collect() } } diff --git a/tests/image.rs b/tests/image.rs index b1e471c..ec0f594 100644 --- a/tests/image.rs +++ b/tests/image.rs @@ -1,7 +1,6 @@ #[cfg(feature = "image")] #[tokio::test] async fn main() -> Result<(), reqwest::Error> { - use material_colors::hex_from_argb; use material_colors::theme_from_source_color; use material_colors::FilterType; use material_colors::ImageReader; @@ -18,7 +17,7 @@ async fn main() -> Result<(), reqwest::Error> { let color = ImageReader::extract_color(&data); - println!("{}", hex_from_argb(&color)); + println!("{}", color); _ = theme_from_source_color(color, Default::default()); diff --git a/tests/theme.rs b/tests/theme.rs index 8daa6b8..ac3aa5f 100644 --- a/tests/theme.rs +++ b/tests/theme.rs @@ -8,8 +8,7 @@ use material_colors::Scheme; #[test] fn test_theme() -> Result<(), ParseRgbError> { - let source = Argb::from_str("#AAE5A4")?; - let theme = theme_from_source_color(source, vec![]); + let theme = theme_from_source_color(Argb::from_str("#AAE5A4")?, vec![]); assert_eq!( theme.schemes.dark,