Random

Sometimes it is useful to generate a random color or set of colors. The Color Pro package includes a few functions in the static class Random for doing just that.


🔶 Single Color

Color color = Random.Color();

🌈 Multiple Colors

Color[] colors = Random.Colors(10); // 10 random colors
Random.ColorsNonAlloc(outputArray); // prevent heap allocations

🎨 Palettes

// Generate a given amount of random colors
Color[] tints = color.RandomTints(10);
Color[] shades = color.RandomShades(10);
Color[] tones = color.RandomTones(10);
Color[] lighter = color.RandomLighter(10);
Color[] darker = color.RandomDarker(10);
Color[] saturated = color.RandomSaturated(10);
Color[] desaturated = color.RandomDesaturated(10);
Color[] hues = color.RandomHues(10);

// Fill an existing array of colors to prevent heap allocations
color.RandomTintsNonAlloc(outputArray);
color.RandomShadesNonAlloc(outputArray);
color.RandomTonesNonAlloc(outputArray);
color.RandomLighterNonAlloc(outputArray);
color.RandomDarkerNonAlloc(outputArray);
color.RandomSaturatedNonAlloc(outputArray);
color.RandomDesaturatedNonAlloc(outputArray);
color.RandomHuesNonAlloc(outputArray);