Experilous

Make It Colorful

$5 on the Unity Asset Store | Discuss

Documentation | Demos

Requires Unity 5.0.0 or higher.

Make It Colorful is a collection of color types for a variety of color spaces beyond just RGB. Benefits of using Make It Colorful include:

Make It Random provides full featured and interoperable color space types based on combinations of hue, saturation/chroma, and value/lightness/luma, plus ink-style subtractive components:

  • HSV
  • HCV
  • CMY
  • HSL
  • HCL
  • CMYK
  • HSY
  • HCY

Color operations include:

Constructing and manipulating colors, especially interpolating between colors for animations and gradients, can be unsatisfying with simple RGB, but can be greatly improved when working within a more appropriate color space. Let Make It Colorful assist!

Purchase Make It Colorful now from the Unity Asset Store

For even more fun with colors, check out Make It Random, which includes Make It Colorful, along with utilities to generate random colors and plenty more.


The Details


Hue

Saturation and Chroma

Value, Lightness, and Luma

Subtractive Color Spaces

Color Space Boundary Validation

Canonical and Equivalent Colors

Conversions


Samples


Hue

If you want to just pull vibrant colors directly from the one-dimensional color wheel, it's as simple as constructing an instance of ColorHSV with a hue in the range [0, 1) and a saturation and value both equal to 1.


Color c = new ColorHSV(0.37823f, 1, 1);

Inversely, if you just want to figure out the hue of a color and ignore everything else, simply convert to any of the hue-based color spaces and pull its hue field.


float hue = ((ColorHSV)color).h;

Luma

Like with hue, if you are most interested in the apparent luminance of a color, you can find out what it is by converting to one of the luma-based color spaces and pulling the luma field.


float luma = ((ColorHCY)color).l;

If you want to force one color to have a matching apparent luminance of another color, you can figure out the hue and chroma of the first color, the luma of the second color, and then construct a third color using those three values. The chroma may need to be adjusted for it to be convertible to a valid RGB color, so the color space bound functions can come in handy here.


var hcy = (ColorHCY)firstColor;
hcy.y = ((ColorHCY)secondColor).y;
hcy.c = Mathf.Min(hcy.c, ColorHCY.GetMaxChroma(hcy.h, hcy.y));
var rgb = (Color)hcy;

If you'd rather less then potential change in chroma in case of an out-of-range color, you can use GetNearestValid() instead. This will adjust both chroma and luma if necessary, compromising between the two.


var hcy = (ColorHCY)firstColor;
hcy.y = ((ColorHCY)secondColor).y;
var rgb = (Color)hcy.GetNearestValid();

K-Lock

Another useful method of forcing colors to match on a single component value is known as "K-lock", which is forcing the key component of the the CMYK color space to a constant value while the other components are free to change. This is as easy to implement as converting to CMYK, setting the key, and converting back.


var cmyk = (ColorCMYK)color;
cmyk.k = fixedKey;
color = cmyk;

Animated Color Blending

When blending from one color to another during an animation, you may want to use a different color space to do the blend, especially if you're encountering unwanted muddy greys in the middle of the blend, or noticing uneven changes in apparent luminance. You can achieve this by usig the following during each frame of animation (as an example, this is applied to a sprite renderer):


spriteRenderer.color = ColorHCY.Lerp(startColor, finalColor, animTime / animDuration);

Make It Colorful can be purchased from the Unity Asset Store.