mirror of
https://github.com/arabianq/colorgram-rust.git
synced 2026-04-28 06:31:22 +00:00
fix: incorrect docs
This commit is contained in:
Generated
+1
-1
@@ -237,7 +237,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colorgram"
|
name = "colorgram"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"clap",
|
"clap",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "colorgram"
|
name = "colorgram"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["arabian"]
|
authors = ["arabian"]
|
||||||
description = "Rust library that extracts colors from image. Port of colorgram.py"
|
description = "Rust library that extracts colors from image. Port of colorgram.py"
|
||||||
|
|||||||
@@ -25,14 +25,15 @@ colorgram = "0.1.0"
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
use colorgram::extract;
|
use colorgram::extract;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
fn main() {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let img_path = "test.png";
|
let buf = fs::read("image.jpg")?;
|
||||||
let colors_amount = 10;
|
let colors = extract(&buf, 5)?;
|
||||||
|
|
||||||
let colors = extract(img_path, colors_amount).unwrap();
|
|
||||||
for color in colors {
|
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(())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -131,7 +131,7 @@ fn rgb_to_hsl(rgb: &Rgb) -> Hsl {
|
|||||||
///
|
///
|
||||||
/// ### Example:
|
/// ### Example:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use colorgram::{extract, Color};
|
/// use colorgram::extract;
|
||||||
/// use std::fs;
|
/// use std::fs;
|
||||||
///
|
///
|
||||||
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user