Skip to main content

Crate rand_color

Crate rand_color 

Source
Expand description

Unified random color generation across supported color spaces.

This umbrella crate re-exports the focused color-space crates from stable modules. Use a focused crate such as rand_rgb when you only need one color space, or use rand_color when you want one dependency for several spaces.

Random values are sampled from numeric component ranges. They are not gamut-checked, contrast-checked, or perceptually uniform.

§Examples

let rgb = rand_color::rgb::random_color();
let hsl = rand_color::hsl::random_hsl();
let hsv = rand_color::hsv::random_hsv();

assert!(rgb.to_rgba_string().starts_with("rgba("));
assert!(hsl.to_hsla_string().starts_with("hsla("));
assert!(hsv.to_hsva_string().starts_with("hsva("));

Modules§

convert
RGB <-> HSL conversion helpers and traits from rand_color_convert.
hsl
HSL/HSLA random color generation from rand_hsl.
hsv
HSV/HSVA random color generation from rand_hsv.
hwb
HWB/HWBA random color generation from rand_hwb.
lab
CIELAB random color generation from rand_lab.
lch
CIELCH random color generation from rand_lch.
oklab
Oklab random color generation from rand_oklab.
oklch
Oklch random color generation from rand_oklch.
rgb
RGB/RGBA random color generation from rand_rgb.