Class ColorUtils
Namespace: Xareus.Unity.Utils
Assembly: Xareus.Unity.Utils.dll
Syntax
public static class ColorUtils
Methods
ChangeColorBrightness(Color, float)
Creates color with corrected brightness.
Declaration
public static Color ChangeColorBrightness(Color color, float correctionFactor)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Color to correct. |
float | correctionFactor | The brightness correction factor. Must be between -1 and 1. Negative values produce darker colors. |
Returns
Type | Description |
---|---|
Color | Corrected Color structure. |
GetColorFromString(string)
Get the color from an hexadecimal
Declaration
public static Color GetColorFromString(string hexString)
Parameters
Type | Name | Description |
---|---|---|
string | hexString | string of an hexadecimal |
Returns
Type | Description |
---|---|
Color | color converted from hexadecimal |
GetContrastColor(Color)
When fed a color, get the best contrast color (white or black)
Declaration
public static Color GetContrastColor(this Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color |
Returns
Type | Description |
---|---|
Color |
GetLuminance(Color)
Calculate the luminance of a color
Declaration
public static float GetLuminance(this Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color |
Returns
Type | Description |
---|---|
float |
GetStringFromColor(Color, bool)
Get the hexadecimal from a Color
Declaration
public static string GetStringFromColor(Color color, bool useAlpha = false)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Unity Color Format RGBA |
bool | useAlpha |
Returns
Type | Description |
---|---|
string | string hexadecial converted from RGBA color |