From ef66e7a1b5031c4e7f131c5054562c43c1b016cd Mon Sep 17 00:00:00 2001 From: arabian Date: Tue, 6 Jan 2026 06:40:03 +0300 Subject: [PATCH] fix: incorrect docs --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 11 ++++++----- src/lib.rs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca432fd..6fbefb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -237,7 +237,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorgram" -version = "1.0.0" +version = "1.0.1" dependencies = [ "ansi_term", "clap", diff --git a/Cargo.toml b/Cargo.toml index a5e1d23..6e6db69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "colorgram" -version = "1.0.0" +version = "1.0.1" edition = "2024" authors = ["arabian"] description = "Rust library that extracts colors from image. Port of colorgram.py" diff --git a/README.md b/README.md index 321b87b..3677772 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,15 @@ colorgram = "0.1.0" ```rust use colorgram::extract; +use std::fs; -fn main() { - let img_path = "test.png"; - let colors_amount = 10; +fn main() -> Result<(), Box> { + let buf = fs::read("image.jpg")?; + let colors = extract(&buf, 5)?; - let colors = extract(img_path, colors_amount).unwrap(); for color in colors { - println!("RGB: {} {} {} HSL: {} {} {} Proportion: {:.2}", color.rgb.r, color.rgb.g, color.rgb.b, color.hsl.h, color.hsl.s, color.hsl.l, color.proportion); + println!("Color: {}, Weight: {:.2}%", color.rgb, color.proportion * 100.0); } + Ok(()) } ``` diff --git a/src/lib.rs b/src/lib.rs index 8585cdd..e044643 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,7 +131,7 @@ fn rgb_to_hsl(rgb: &Rgb) -> Hsl { /// /// ### Example: /// ```rust -/// use colorgram::{extract, Color}; +/// use colorgram::extract; /// use std::fs; /// /// fn main() -> Result<(), Box> {