Expand description
Conversion helpers for the rand_color workspace.
This crate currently supports RGB <-> HSL conversion only. Other color spaces in the workspace intentionally remain random-generation crates, not full conversion engines.
§Examples
use rand_color_convert::{rgb_to_hsl, ToRgb};
use rand_rgb::RandomColor;
let rgb = RandomColor {
red: 255,
green: 0,
blue: 0,
alpha: 1.0,
};
let hsl = rgb_to_hsl(rgb);
let round_trip = hsl.to_rgb();
assert_eq!(round_trip.red, 255);
assert_eq!(round_trip.alpha, 1.0);Traits§
- ToHsl
- Converts a color value into an HSL/HSLA representation.
- ToRgb
- Converts a color value into an RGB/RGBA representation.
Functions§
- hsl_
to_ rgb - Converts an HSL/HSLA color to RGB/RGBA.
- rgb_
to_ hsl - Converts an RGB/RGBA color to HSL/HSLA.