Skip to content

Tutorial : Random Colors

Maximilian Stadlmeier edited this page Jul 17, 2014 · 3 revisions

#Tutorial 04 - Colors

This tutorial will show you how to generate random colors with RUL.RulCol .
Note that some function and parameter names and types may differ depending on which framework or engine you are using. Keep in mind that RGB components in Unity have to be between 0 and 1.

###RulCol.RandColor() The easiest and most basic way to generate random colors. The colors produced by this function will be completely random, but always opaque.

for(int i = 0; i < 100; i++)
  Color myColor = RulCol.RandColor();

###RulCol.RandColor(int lightness) This function allows for a little more customization. You can specify the color's lightness .

for(int i = 0; i < 100; i++)
  Color myColor = RulCol.RandColor(lightness);

###RulCol.RandColor(Hues hue, LuminosityTypes luminosity) RUL makes it easy to get random colors of a specified hue and luminosity. There are 10 hues and 3 luminosity types available at the moment.

for(int i = 0; i < 100; i++)
{
   Color lightCyan = RulCol.RandColor(Hues.Red,LuminosityTypes.Light);
   Color mediumGreen = RulCol.RandColor(Hues.Green, LuminosityTypes.Medium);
   Color darkPurple = RulCol.RandColor(Hues.Purple, LuminosityTypes.Dark);
   Color mediumGray = RulCol.RandColor(Hues.Monochrome, LuminosityTypes.Medium);
   Color lightOrange = RulCol.RandColor(Hues.Orange, LuminosityTypes.Light);
}

For more ways to generate random colors check out the documentation

Clone this wiki locally