Skip to main content

Crate rand_rgb

Crate rand_rgb 

Source
Expand description

Generate random RGB/RGBA color values with configurable channel bounds.

The crate samples each channel independently from the configured numeric ranges. It does not attempt palette design, gamut mapping, contrast checking, or perceptual-uniform sampling.

§Examples

use rand_rgb::random_color;

let color = random_color();

assert!((0.0..=1.0).contains(&color.alpha));
assert!(color.to_rgba_string().starts_with("rgba("));

Structs§

ColorRange
User-provided channel bounds for random generation.
RandomColor
Represents a randomly generated rgba() color value.

Enums§

ColorError
Error returned when color bounds are invalid.

Functions§

random_color
Generates a random color using default bounds.
random_color_in
Generates a random color using custom bounds.
random_color_in_with_rng
Generates a random color using custom bounds and a caller-provided RNG.
random_color_with_rng
Generates a random color using default bounds and a caller-provided RNG.