2 public struct Color : IEquatable<Color> {
104 public Color(
byte r,
byte g,
byte b) =>
PackedValue = (uint)(-16777216 | (b << 16) | (g << 8) | r);
106 public Color(
byte r,
byte g,
byte b,
byte a) =>
PackedValue = (uint)((a << 24) | (b << 16) | (g << 8) | r);
108 public Color(
int r,
int g,
int b,
int a) =>
this =
new Color(
109 (
byte)Math.Clamp(r, 0, 255),
110 (
byte)Math.Clamp(g, 0, 255),
111 (
byte)Math.Clamp(b, 0, 255),
112 (
byte)Math.Clamp(a, 0, 255)
115 public Color(
int r,
int g,
int b) =>
this =
new Color(r, g, b, 255);
117 public Color(
float r,
float g,
float b,
float a) =>
this =
new Color(
144 public static implicit
operator Color((
byte R,
byte G,
byte B) v) =>
new(v.R, v.G, v.B);
146 public static implicit
operator Color((
byte R,
byte G,
byte B,
byte A) v) =>
new(v.R, v.G, v.B, v.A);
148 public static implicit
operator Color((
int R,
int G,
int B) v) =>
new(v.R, v.G, v.B);
150 public static implicit
operator Color((
int R,
int G,
int B,
int A) v) =>
new(v.R, v.G, v.B, v.A);
152 public static implicit
operator Color((
float R,
float G,
float B,
float A) v) =>
new(v.R, v.G, v.B, v.A);
158 public override string ToString() => $
"{R},{G},{B},{A}";
185 (byte)Math.Clamp(c.
R * s, 0f, 255f),
186 (
byte)Math.Clamp(c.
G * s, 0f, 255f),
187 (
byte)Math.Clamp(c.
B * s, 0f, 255f),
208 float num3 = num2 - num;
213 num4 = num3 == 0f ? 0f :
214 rgb.X == num2 ? (rgb.Y - rgb.
Z) / num3 :
215 rgb.Y != num2 ? 4f + (rgb.X - rgb.
Y) / num3 : 2f + (rgb.Z - rgb.
X) / num3;
220 return new Vector3(num4, y, z);
224 return new Vector3(num4, y, z);
232 int num = (int)MathF.
Floor(hsv.
X);
233 float num2 = hsv.X - num;
234 float num3 = hsv.Z * (1f - hsv.
Y);
235 float num4 = hsv.Z * (1f - hsv.Y * num2);
236 float num5 = hsv.Z * (1f - hsv.Y * (1f - num2));
280 (byte)Math.Clamp(c.
R * s, 0f, 255f),
281 (
byte)Math.Clamp(c.
G * s, 0f, 255f),
282 (
byte)Math.Clamp(c.
B * s, 0f, 255f),
283 (
byte)Math.Clamp(c.
A * s, 0f, 255f)
287 (byte)Math.Clamp(c.
R * s, 0f, 255f),
288 (
byte)Math.Clamp(c.
G * s, 0f, 255f),
289 (
byte)Math.Clamp(c.
B * s, 0f, 255f),
290 (
byte)Math.Clamp(c.
A * s, 0f, 255f)
296 (
byte)Math.Clamp(c.
R * num, 0f, 255f),
297 (
byte)Math.Clamp(c.
G * num, 0f, 255f),
298 (
byte)Math.Clamp(c.
B * num, 0f, 255f),
299 (
byte)Math.Clamp(c.
A * num, 0f, 255f)
304 (byte)Math.Clamp(c.
R * s.
X, 0f, 255f),
305 (
byte)Math.Clamp(c.
G * s.
Y, 0f, 255f),
306 (
byte)Math.Clamp(c.
B * s.
Z, 0f, 255f),
307 (
byte)Math.Clamp(c.
A * s.
W, 0f, 255f)
311 (byte)Math.Clamp(c.
R * s.
X, 0f, 255f),
312 (
byte)Math.Clamp(c.
G * s.
Y, 0f, 255f),
313 (
byte)Math.Clamp(c.
B * s.
Z, 0f, 255f),
314 (
byte)Math.Clamp(c.
A * s.
W, 0f, 255f)
318 (byte)Math.Min(c1.
R + c2.
R, 255),
319 (
byte)Math.Min(c1.
G + c2.
G, 255),
320 (
byte)Math.Min(c1.
B + c2.
B, 255),
321 (
byte)Math.Min(c1.
A + c2.
A, 255)
325 (byte)Math.Max(c1.
R - c2.
R, 0),
326 (
byte)Math.Max(c1.
G - c2.
G, 0),
327 (
byte)Math.Max(c1.
B - c2.
B, 0),
328 (
byte)Math.Max(c1.
A - c2.
A, 0)
332 (byte)(c1.R * c2.R / 255),
333 (byte)(c1.G * c2.G / 255),
334 (byte)(c1.B * c2.B / 255),
335 (byte)(c1.A * c2.A / 255)
static int Min(int x1, int x2)
static float Saturate(float x)
static int Max(int x1, int x2)
static float Lerp(float x1, float x2, float f)
static Color MultiplyAlphaOnly(Color c, float s)
static Color MultiplyAlphaOnlyNotSaturated(Color c, float s)
static Color operator/(Color c, float s)
Color(int r, int g, int b)
static Color operator-(Color c1, Color c2)
static Color Lerp(Color c1, Color c2, float f)
static bool operator==(Color c1, Color c2)
static Vector4 PremultiplyAlpha(Vector4 c)
static Vector3 RgbToHsv(Vector3 rgb)
Color(float r, float g, float b, float a)
static Color LightMagenta
static Color MultiplyColorOnlyNotSaturated(Color c, Vector3 s)
Color(byte r, byte g, byte b, byte a)
static bool operator!=(Color c1, Color c2)
static Vector3 HsvToRgb(Vector3 hsv)
static Color MultiplyNotSaturated(Color c, float s)
Color(byte r, byte g, byte b)
override int GetHashCode()
static Color MultiplyColorOnlyNotSaturated(Color c, float s)
static Color MultiplyColorOnly(Color c, float s)
override string ToString()
static Color operator+(Color c1, Color c2)
static Color PremultiplyAlpha(Color c)
Color(Color rgb, float a)
Color(float r, float g, float b)
static Color MultiplyNotSaturated(Color c, Vector4 s)
override bool Equals(object obj)
static Color LerpNotSaturated(Color c1, Color c2, float f)
Color(int r, int g, int b, int a)
static Color operator*(Color c, float s)
static Vector3 Floor(Vector3 v)