1using System.Globalization;
8 public static readonly
Color steelBlue =
new Color32(70, 130, 180,
byte.MaxValue);
12 public static readonly
Color white32 =
new Color32(
byte.MaxValue,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue);
14 public static readonly
Color black =
new Color32(0, 0, 0,
byte.MaxValue);
64 public static readonly
Color white =
new Color32(
byte.MaxValue,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue);
66 public static readonly
Color red =
new Color32(
byte.MaxValue, 0, 0,
byte.MaxValue);
68 public static readonly
Color brown =
new Color32(165, 42, 42,
byte.MaxValue);
70 public static readonly
Color gray =
new Color32(190, 190, 190,
byte.MaxValue);
72 public static readonly
Color pink =
new Color32(
byte.MaxValue, 192, 203,
byte.MaxValue);
74 public static readonly
Color green =
new Color32(0,
byte.MaxValue, 0,
byte.MaxValue);
76 public static readonly
Color tan =
new Color32(210, 180, 140,
byte.MaxValue);
78 public static readonly
Color yellow =
new Color32(
byte.MaxValue,
byte.MaxValue, 0,
byte.MaxValue);
80 public static readonly
Color maroon =
new Color32(128, 0, 0,
byte.MaxValue);
82 public static readonly
Color navyBlue =
new Color32(0, 0, 128,
byte.MaxValue);
84 public static readonly
Color magenta =
new Color32(
byte.MaxValue, 0,
byte.MaxValue,
byte.MaxValue);
86 public static readonly
Color blue =
new Color32(0, 0,
byte.MaxValue,
byte.MaxValue);
88 public static readonly
Color aqua =
new Color32(0,
byte.MaxValue,
byte.MaxValue,
byte.MaxValue);
90 public static readonly
Color orange =
new Color32(
byte.MaxValue, 165, 0,
byte.MaxValue);
94 return new Color(c.r + value, c.g + value, c.b + value);
99 return new Color(c.r - value, c.g - value, c.b - value);
104 return new Color(1f - color.r, 1f - color.g, 1f - color.b, color.a);
112 public static Color HSVtoRGB(
float hue,
float saturation,
float value,
float alpha = 1f)
114 int num = (int)(hue / 60f) % 6;
115 float num2 = hue / 60f - (float)(
int)(hue / 60f);
116 float num3 = value * (1f - saturation);
117 float num4 = value * (1f - num2 * saturation);
118 float num5 = value * (1f - (1f - num2) * saturation);
121 0 =>
new Color(value, num5, num3, alpha),
122 1 =>
new Color(num4, value, num3, alpha),
123 2 =>
new Color(num3, value, num5, alpha),
124 3 =>
new Color(num3, num4, value, alpha),
125 4 =>
new Color(num5, num3, value, alpha),
126 _ =>
new Color(value, num3, num4, alpha),
132 if (color.r == color.g && color.g == color.b)
136 return RGBtoHSV(color.r, color.g, color.b, color.a);
142 float num = Mathf.Max(r, g, b);
143 float num2 = Mathf.Min(r, g, b);
144 float num3 = num - num2;
146 if (num == 0f || num2 == 1f || num3 == 0f)
154 result.h = (g - b) / num3;
158 result.h = (b - r) / num3 + 2f;
162 result.h = (r - g) / num3 + 4f;
170 result.s = num3 / num;
177 float num = Mathf.Max(r, g, b);
178 float num2 = Mathf.Min(r, g, b);
179 float num3 = num - num2;
181 if (num == 0f || num2 == 1f || num3 == 0f)
189 result.h = (g - b) / num3;
193 result.h = (b - r) / num3 + 2f;
197 result.h = (r - g) / num3 + 4f;
204 result.l = (num + num2) / 2f;
205 result.s = num3 / (1f - Mathf.Abs(2f * result.
l - 1f));
211 return RGBtoHSL(color.r, color.g, color.b, color.a);
218 result.l = hsv.v * (2f - hsv.
s) / 2f;
219 result.s = hsv.v * hsv.s / (1f - Mathf.Abs(result.
l - 1f));
227 result.v = (2f * hsl.l + hsl.s * (1f - Mathf.Abs(2f * hsl.
l - 1f))) / 2f;
228 result.s = 2f * (result.v - hsl.
l) / result.
v;
234 return color.r.ToString(
"X2") + color.g.ToString(
"X2") + color.b.ToString(
"X2") + color.a.ToString(
"X2");
239 byte r =
byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
240 byte g =
byte.Parse(hex.Substring(2, 2), NumberStyles.HexNumber);
241 byte b =
byte.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
242 byte a =
byte.MaxValue;
245 a =
byte.Parse(hex.Substring(6, 2), NumberStyles.HexNumber);
247 return new Color32(r, g, b, a);
252 return color.SetAlpha(0.75f);
static readonly Color black
static readonly Color red
static Color SlightlyTransparent(Color color)
static Color HexToColor(string hex)
static readonly Color magenta50
static readonly Color green
static readonly Color red75
static readonly Color pink
static readonly Color magenta
static readonly Color red10
static readonly Color brown
static Color HSVtoRGB(HSVColor hsv)
static readonly Color aqua
static readonly Color green25
static readonly Color nearlyBlack
static HSLColor RGBtoHSL(float r, float g, float b, float a=1f)
static readonly Color lightSteelBlue
static HSLColor RGBtoHSL(Color color)
static Color Lighten(this Color c, float value=0.2f)
static readonly Color yellow25
static Color Darken(this Color c, float value=0.2f)
static readonly Color blue50
static Color HSVtoRGB(float hue, float saturation, float value, float alpha=1f)
static readonly Color steelBlue
static readonly Color red50
static string ColorToHex(Color32 color)
static readonly Color white
static readonly Color orange
static readonly Color cyan25
static readonly Color transparentBlack
static readonly Color transparentWhite
static readonly Color green10
static readonly Color blue
static HSVColor RGBtoHSV(Color color)
static HSLColor HSVtoHSL(HSVColor hsv)
static readonly Color red25
static HSVColor HSLtoHSV(HSLColor hsl)
static readonly Color tan
static HSVColor RGBtoHSV(float r, float g, float b, float a=1f)
static readonly Color white32
static readonly Color magenta75
static readonly Color cyan75
static readonly Color blue25
static readonly Color yellow50
static readonly Color navyBlue
static readonly Color gray
static readonly Color green50
static readonly Color blue10
static readonly Color magenta25
static readonly Color green75
static Color Inverse(this Color color)
static Color SetAlpha(this Color color, float alpha=0.5f)
static readonly Color blue75
static readonly Color maroon
static readonly Color cyan50
static readonly Color yellow75
static readonly Color yellow