chroma-rust
A rust crate for working with colors and color spaces.
Installation
Add this to your Cargo.toml
:
[]
= "0.1"
and this to your crate root:
use chroma_rust;
Usage
Color
Generic color struct. Can be constructed from any color space. Current supported color spaces are:
- RGB
- RGBA
- HSL
- Lab
- Hex
- Named
You can generate a color from any of these color spaces with &str
by using the from
method.
For example:
let color = from;
let color = from;
let color = from;
let color = from;
let color = from;
alpha
Get the alpha value of a color.
let color = from;
let alpha = color.alpha; // 0.5
Set the alpha value of a color.
let color = from;
let color = color.alpha;
let alpha = color.alpha; // 0.2
name
Get the name of a color. If the color is not a named color, hex
code of the color is returned.
```rust
let color = from;
let name = color.name; // "yellow"
let color = from;
let name = color.name; // "#ff802c"
More api can be found in the documentation.
Enjoy it! 🎨