How the Random Color Generator Produces Each Color
AnyTool Random Color Generator creates every color in the browser using the Web Crypto API. Random values come from crypto.getRandomValues via rejection sampling — draws that would fall outside an even multiple of the range are discarded — so there is no modulo bias and the distribution is uniform; Math.random is never used. In the default “any” style each of the red, green and blue channels is an independent random value in 0–255. The style constraints instead sample in HSL: pastel uses high lightness with low–moderate saturation, vibrant uses high saturation at mid lightness, dark and light shift the lightness band, grayscale picks a single random brightness for all three channels, and “by hue” draws within a ±20° band around a chosen hue. Each generated color is converted client-side to HEX, RGB, HSL, HSB/HSV, HWB, CMYK and CIELAB, and labelled with the nearest CSS named color.
- Colors come from crypto.getRandomValues (CSPRNG), not Math.random
- Rejection sampling removes modulo bias — uniform random distribution
- “Any” mode randomizes R, G, B in 0–255; styles sample hue/saturation/lightness
- Converted to HEX, RGB, HSL, HSB, HWB, CMYK and CIELAB in the browser
- All generation and conversion run client-side — no server round-trip
