Click or drag to resize
Introduction

Welcome to the Make It Colorful User's Manual. This document will assist in integrating this collection of color space types into your Unity project.

Note Note

An online version of this documentation is available here, and a downloadable archive for offline use can be acquired here.

What does Make It Colorful offer?

Make It Colorful is a collection of color types for use in your Unity scripts. Following the pattern provided by UnityEngineColor, these types are structs exposing their various color component fields, while also providing some useful methods and operators.

Each type represents colors within a particular color space, making it simple to work with colors within that color space. In addition, conversion functions exist to convert from any of the available color spaces to any other, including the RGB color space as represented by UnityEngineColor. For example, here is an easy way to get the RGB representation of a particular hue:

Color rgb = (Color)new ColorHSV(hue, 1f, 1f);

Linear interpolation between colors is included, which will often produce different and more desirable results in other color spaces than when interpolating within the RGB color space. The hue-based color spaces will avoid muddy gray middle sections, for example, and the HCY color space in particular provides good interpolation of apparent vibrance and brightness, whereas other color spaces will often produce apparent banding.

ColorHCY hcy = ColorHCY.Lerp(ColorHCY.FromRGB(1f, 0f, 0f), ColorHCY.FromRGB(0f, 0.2f, 0.3f), 0.354f);

Lastly, there are methods to manage the bounds of a color space and the uniqueness of individual colors. The non-HDR RGB color space has a range of [0, 1] for each color channel, and the other color spaces have corresponding ranges such that every color within these ranges will convert to an RGB color within these standard bounds. Methods exist to check if a color is within these bounds, and further to clamp to the nearest color within the bounds if not already in bounds. And in some color spaces, certain colors can be expressed in more than one way, so each color is defined to have a single canonical representation. Thus, methods exist to check if a color is canonical, and to convert to the canonical form if not.

ColorHCV hcv = new ColorHCV(0.5f, 0.6f, 0.2f, 1.1f);
Debug.Log(hcv.IsValid());         // false
Debug.Log(hcv.GetNearestValid()); // HCVA(0.500, 0.400, 0.400, 1.000)

ColorHSL hsl = new ColorHSL(0.2f, 0f, 0.3f);
Debug.Log(hsl.IsCanonical());     // false
Debug.Log(hsl.GetCanonical());    // HSLA(0.000, 0.000, 0.300, 1.000)
Note Note

Every color space type includes an alpha channel to indicate opacity, serving the same purpose as in UnityEngine.Color. When converting between color spaces, opacity plays no role, and is simply copied directly as is. For any constructors or similar functions that leave out opacity, it defaults to 1.

What color spaces are available?

ColorCMY

A subtractive color space mimicing cyan, magenta, and yellow inks.

ColorCMYK

A subtractive color space mimicing cyan, magenta, yellow, and black (key) inks.

ColorHSV

A hue-based color space using saturation to measure vividness and value to measure luminance.

ColorHCV

A hue-based color space using chroma to measure vividness and value to measure luminance.

ColorHSL

A hue-based color space using saturation to measure vividness and lightness to measure luminance.

ColorHCL

A hue-based color space using chroma to measure vividness and lightness to measure luminance.

ColorHSY

A hue-based color space using saturation to measure vividness and luma to measure luminance.

ColorHCY

A hue-based color space using chroma to measure vividness and luma to measure luminance.

Note Note

The Make It Colorful library is located within the Experilous.MakeItColorful namespace. Be sure to put the appropriate using directive at the top of your scripts, or explicitly qualify type names within your code.

See Also