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.
This topic contains the following sections:
Make It Colorful is a collection of color types for use in your Unity scripts. Following the pattern provided by structs exposing their various color component fields, while also providing some useful methods and operators., these types are
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. 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)
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.
A subtractive color space mimicing cyan, magenta, and yellow inks.
A subtractive color space mimicing cyan, magenta, yellow, and black (key) inks.
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.