Composable primitive color utilities for Rust.
use-color is the color-specific RustUse set for small, composable helpers
around RGB values and hex colors. It focuses on lightweight representation and
conversion without introducing full palette management or rendering engines.
- RGB color values
- hex color parsing and formatting
- grayscale checks
- relative luminance for sRGB colors
- named color constants for common base colors
| Crate | Purpose |
|---|---|
use-color |
Composable primitive color utilities for Rust. |
Crates.io:
[dependencies]
use-color = "0.1"Local workspace or path dependency:
[dependencies]
use-color = { path = "crates/use-color" }Parse and format a hex color:
use use_color::prelude::*;
let color = parse_hex_rgb("#3366CC").unwrap();
assert_eq!(color.to_hex_rgb(), "#3366CC");Check whether a color is grayscale:
use use_color::prelude::*;
assert!(Rgb::new(80, 80, 80).is_grayscale());
assert!(!Rgb::new(80, 81, 80).is_grayscale());Measure luminance:
use use_color::prelude::*;
assert!(WHITE.relative_luminance() > BLACK.relative_luminance());Early v0.1 API.