Skip to content

Commit

Permalink
chore(README): update
Browse files Browse the repository at this point in the history
chore(Cargo.toml): bump version
chore(utils/image): i forgor update image utils
chore(tests/image): update test
chore(tests/theme): remove source variable
  • Loading branch information
Aiving committed Mar 14, 2024
1 parent 35e58a0 commit a26699c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...
}
Expand Down
6 changes: 5 additions & 1 deletion src/utils/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ impl AsPixels for Image {
fn as_pixels(&self) -> Vec<Argb> {
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()
}
}
Expand Down
3 changes: 1 addition & 2 deletions tests/image.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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());

Expand Down
3 changes: 1 addition & 2 deletions tests/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a26699c

Please sign in to comment.