Crates.io | colori |
lib.rs | colori |
version | 0.1.1 |
source | src |
created_at | 2020-08-19 23:35:04.849283 |
updated_at | 2020-08-19 23:58:52.857353 |
description | A simple and basic color conversion and manipulation library |
homepage | |
repository | |
max_upload_size | |
id | 278459 |
size | 62,559 |
A rust crate for simple color conversion and manipulation.
Add the following to your [dependencies]
in Cargo.toml
colori = "0.1"
Data structures for different color spaces
use colori::{RgbColor, HslColor};
let rgb = RgbColor(255, 0, 80);
rgb.red() // 255
rgb.green() // 0
rgb.blue() // 80
let hsl = HslColor(0.5, 0.4, 1.0);
hsl.hue(); // 0.5
hsl.hue_deg() // 180
hsl.lightness() // 0.4
hsl.saturation() // 1.0
Convert different color spaces into each other
use colori::{RgbColor, HslColor};
let hsl: HslColor = RgbColor(255, 0, 0).into();
let rgb: RgbColor = HslColor(0.5, 0.4, 1.0).into();
Access a list of over 800 defined color constants
use colori::{Color};
let rgb = Color::UNITED_NATIONS_BLUE;
println!("R: {}, G: {}, B: {}", rgb.red(), rgb.green(), rgb.blue());