using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
public static void Main()
color.PackedValue = (uint)(flag ? -8131073 : -11079073);
Console.WriteLine(color);
Console.WriteLine("End!");
[DebuggerDisplay("{DebugDisplayString,nq}")]
public struct Color : IEquatable<Color>
#region Public Properties
return (byte) (this.packedValue >> 16);
this.packedValue = (this.packedValue & 0xff00ffff) | ((uint) value << 16);
return (byte) (this.packedValue >> 8);
this.packedValue = (this.packedValue & 0xffff00ff) | ((uint) value << 8);
return (byte) (this.packedValue);
this.packedValue = (this.packedValue & 0xffffff00) | value;
return (byte) (this.packedValue >> 24);
this.packedValue = (this.packedValue & 0x00ffffff) | ((uint) value << 24);
public UInt32 PackedValue
#region Public Static Color Properties
public static Color Transparent
public static Color AliceBlue
public static Color AntiqueWhite
public static Color Aquamarine
public static Color Azure
public static Color Beige
public static Color Bisque
public static Color Black
public static Color BlanchedAlmond
public static Color BlueViolet
public static Color Brown
public static Color BurlyWood
public static Color CadetBlue
public static Color Chartreuse
public static Color Chocolate
public static Color Coral
public static Color CornflowerBlue
public static Color Cornsilk
public static Color Crimson
public static Color DarkBlue
public static Color DarkCyan
public static Color DarkGoldenrod
public static Color DarkGray
public static Color DarkGreen
public static Color DarkKhaki
public static Color DarkMagenta
public static Color DarkOliveGreen
public static Color DarkOrange
public static Color DarkOrchid
public static Color DarkRed
public static Color DarkSalmon
public static Color DarkSeaGreen
public static Color DarkSlateBlue
public static Color DarkSlateGray
public static Color DarkTurquoise
public static Color DarkViolet
public static Color DeepPink
public static Color DeepSkyBlue
public static Color DimGray
public static Color DodgerBlue
public static Color Firebrick
public static Color FloralWhite
public static Color ForestGreen
public static Color Fuchsia
public static Color Gainsboro
public static Color GhostWhite
public static Color Goldenrod
public static Color Green
public static Color GreenYellow
public static Color Honeydew
public static Color HotPink
public static Color IndianRed
public static Color Indigo
public static Color Ivory
public static Color Khaki
public static Color Lavender
public static Color LavenderBlush
public static Color LawnGreen
public static Color LemonChiffon
public static Color LightBlue
public static Color LightCoral
public static Color LightCyan
public static Color LightGoldenrodYellow
public static Color LightGray
public static Color LightGreen
public static Color LightPink
public static Color LightSalmon
public static Color LightSeaGreen
public static Color LightSkyBlue
public static Color LightSlateGray
public static Color LightSteelBlue
public static Color LightYellow
public static Color LimeGreen
public static Color Linen
public static Color Magenta
public static Color Maroon
public static Color MediumAquamarine
public static Color MediumBlue
public static Color MediumOrchid
public static Color MediumPurple
public static Color MediumSeaGreen
public static Color MediumSlateBlue
public static Color MediumSpringGreen
public static Color MediumTurquoise
public static Color MediumVioletRed
public static Color MidnightBlue
public static Color MintCream
public static Color MistyRose
public static Color Moccasin
public static Color NavajoWhite
public static Color OldLace
public static Color Olive
public static Color OliveDrab
public static Color Orange
public static Color OrangeRed
public static Color Orchid
public static Color PaleGoldenrod
public static Color PaleGreen
public static Color PaleTurquoise
public static Color PaleVioletRed
public static Color PapayaWhip
public static Color PeachPuff
public static Color PowderBlue
public static Color Purple
public static Color RosyBrown
public static Color RoyalBlue
public static Color SaddleBrown
public static Color Salmon
public static Color SandyBrown
public static Color SeaGreen
public static Color SeaShell
public static Color Sienna
public static Color Silver
public static Color SkyBlue
public static Color SlateBlue
public static Color SlateGray
public static Color SpringGreen
public static Color SteelBlue
public static Color Thistle
public static Color Tomato
public static Color Turquoise
public static Color Violet
public static Color Wheat
public static Color White
public static Color WhiteSmoke
public static Color Yellow
public static Color YellowGreen
#region Internal Properties
internal string DebugDisplayString
#region Private Variables
private uint packedValue;
#region Private Static Constructors
Transparent = new Color(0);
AliceBlue = new Color(0xfffff8f0);
AntiqueWhite = new Color(0xffd7ebfa);
Aqua = new Color(0xffffff00);
Aquamarine = new Color(0xffd4ff7f);
Azure = new Color(0xfffffff0);
Beige = new Color(0xffdcf5f5);
Bisque = new Color(0xffc4e4ff);
Black = new Color(0xff000000);
BlanchedAlmond = new Color(0xffcdebff);
Blue = new Color(0xffff0000);
BlueViolet = new Color(0xffe22b8a);
Brown = new Color(0xff2a2aa5);
BurlyWood = new Color(0xff87b8de);
CadetBlue = new Color(0xffa09e5f);
Chartreuse = new Color(0xff00ff7f);
Chocolate = new Color(0xff1e69d2);
Coral = new Color(0xff507fff);
CornflowerBlue = new Color(0xffed9564);
Cornsilk = new Color(0xffdcf8ff);
Crimson = new Color(0xff3c14dc);
Cyan = new Color(0xffffff00);
DarkBlue = new Color(0xff8b0000);
DarkCyan = new Color(0xff8b8b00);
DarkGoldenrod = new Color(0xff0b86b8);
DarkGray = new Color(0xffa9a9a9);
DarkGreen = new Color(0xff006400);
DarkKhaki = new Color(0xff6bb7bd);
DarkMagenta = new Color(0xff8b008b);
DarkOliveGreen = new Color(0xff2f6b55);
DarkOrange = new Color(0xff008cff);
DarkOrchid = new Color(0xffcc3299);
DarkRed = new Color(0xff00008b);
DarkSalmon = new Color(0xff7a96e9);
DarkSeaGreen = new Color(0xff8bbc8f);
DarkSlateBlue = new Color(0xff8b3d48);
DarkSlateGray = new Color(0xff4f4f2f);
DarkTurquoise = new Color(0xffd1ce00);
DarkViolet = new Color(0xffd30094);
DeepPink = new Color(0xff9314ff);
DeepSkyBlue = new Color(0xffffbf00);
DimGray = new Color(0xff696969);
DodgerBlue = new Color(0xffff901e);
Firebrick = new Color(0xff2222b2);
FloralWhite = new Color(0xfff0faff);
ForestGreen = new Color(0xff228b22);
Fuchsia = new Color(0xffff00ff);
Gainsboro = new Color(0xffdcdcdc);
GhostWhite = new Color(0xfffff8f8);
Gold = new Color(0xff00d7ff);
Goldenrod = new Color(0xff20a5da);
Gray = new Color(0xff808080);
Green = new Color(0xff008000);
GreenYellow = new Color(0xff2fffad);
Honeydew = new Color(0xfff0fff0);
HotPink = new Color(0xffb469ff);
IndianRed = new Color(0xff5c5ccd);
Indigo = new Color(0xff82004b);
Ivory = new Color(0xfff0ffff);
Khaki = new Color(0xff8ce6f0);
Lavender = new Color(0xfffae6e6);
LavenderBlush = new Color(0xfff5f0ff);
LawnGreen = new Color(0xff00fc7c);
LemonChiffon = new Color(0xffcdfaff);
LightBlue = new Color(0xffe6d8ad);
LightCoral = new Color(0xff8080f0);
LightCyan = new Color(0xffffffe0);
LightGoldenrodYellow = new Color(0xffd2fafa);
LightGray = new Color(0xffd3d3d3);
LightGreen = new Color(0xff90ee90);
LightPink = new Color(0xffc1b6ff);
LightSalmon = new Color(0xff7aa0ff);
LightSeaGreen = new Color(0xffaab220);
LightSkyBlue = new Color(0xffface87);
LightSlateGray = new Color(0xff998877);
LightSteelBlue = new Color(0xffdec4b0);
LightYellow = new Color(0xffe0ffff);
Lime = new Color(0xff00ff00);
LimeGreen = new Color(0xff32cd32);
Linen = new Color(0xffe6f0fa);
Magenta = new Color(0xffff00ff);
Maroon = new Color(0xff000080);
MediumAquamarine = new Color(0xffaacd66);
MediumBlue = new Color(0xffcd0000);
MediumOrchid = new Color(0xffd355ba);
MediumPurple = new Color(0xffdb7093);
MediumSeaGreen = new Color(0xff71b33c);
MediumSlateBlue = new Color(0xffee687b);
MediumSpringGreen = new Color(0xff9afa00);
MediumTurquoise = new Color(0xffccd148);
MediumVioletRed = new Color(0xff8515c7);
MidnightBlue = new Color(0xff701919);
MintCream = new Color(0xfffafff5);
MistyRose = new Color(0xffe1e4ff);
Moccasin = new Color(0xffb5e4ff);
NavajoWhite = new Color(0xffaddeff);
Navy = new Color(0xff800000);
OldLace = new Color(0xffe6f5fd);
Olive = new Color(0xff008080);
OliveDrab = new Color(0xff238e6b);
Orange = new Color(0xff00a5ff);
OrangeRed = new Color(0xff0045ff);
Orchid = new Color(0xffd670da);
PaleGoldenrod = new Color(0xffaae8ee);
PaleGreen = new Color(0xff98fb98);
PaleTurquoise = new Color(0xffeeeeaf);
PaleVioletRed = new Color(0xff9370db);
PapayaWhip = new Color(0xffd5efff);
PeachPuff = new Color(0xffb9daff);
Peru = new Color(0xff3f85cd);
Pink = new Color(0xffcbc0ff);
Plum = new Color(0xffdda0dd);
PowderBlue = new Color(0xffe6e0b0);
Purple = new Color(0xff800080);
Red = new Color(0xff0000ff);
RosyBrown = new Color(0xff8f8fbc);
RoyalBlue = new Color(0xffe16941);
SaddleBrown = new Color(0xff13458b);
Salmon= new Color(0xff7280fa);
SandyBrown = new Color(0xff60a4f4);
SeaGreen = new Color(0xff578b2e);
SeaShell = new Color(0xffeef5ff);
Sienna = new Color(0xff2d52a0);
Silver = new Color(0xffc0c0c0);
SkyBlue = new Color(0xffebce87);
SlateBlue= new Color(0xffcd5a6a);
SlateGray= new Color(0xff908070);
Snow= new Color(0xfffafaff);
SpringGreen= new Color(0xff7fff00);
SteelBlue= new Color(0xffb48246);
Tan= new Color(0xff8cb4d2);
Teal= new Color(0xff808000);
Thistle= new Color(0xffd8bfd8);
Tomato= new Color(0xff4763ff);
Turquoise= new Color(0xffd0e040);
Violet= new Color(0xffee82ee);
Wheat= new Color(0xffb3def5);
White= new Color(uint.MaxValue);
WhiteSmoke= new Color(0xfff5f5f5);
Yellow = new Color(0xff00ffff);
YellowGreen = new Color(0xff32cd9a);
#region Public Constructors
public Color(float r, float g, float b)
R = (byte) MathHelper.Clamp(r * 255, Byte.MinValue, Byte.MaxValue);
G = (byte) MathHelper.Clamp(g * 255, Byte.MinValue, Byte.MaxValue);
B = (byte) MathHelper.Clamp(b * 255, Byte.MinValue, Byte.MaxValue);
public Color(int r, int g, int b)
R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
public Color(int r, int g, int b, int alpha)
R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
A = (byte) MathHelper.Clamp(alpha, Byte.MinValue, Byte.MaxValue);
public Color(float r, float g, float b, float alpha)
R = (byte) MathHelper.Clamp(r * 255, Byte.MinValue, Byte.MaxValue);
G = (byte) MathHelper.Clamp(g * 255, Byte.MinValue, Byte.MaxValue);
B = (byte) MathHelper.Clamp(b * 255, Byte.MinValue, Byte.MaxValue);
A = (byte) MathHelper.Clamp(alpha * 255, Byte.MinValue, Byte.MaxValue);
#region Private Constructors
private Color(uint packedValue)
this.packedValue = packedValue;
public bool Equals(Color other)
return this.PackedValue == other.PackedValue;
#region Public Static Methods
public static Color Lerp(Color value1, Color value2, float amount)
amount = MathHelper.Clamp(amount, 0.0f, 1.0f);
(int) MathHelper.Lerp(value1.R, value2.R, amount),
(int) MathHelper.Lerp(value1.G, value2.G, amount),
(int) MathHelper.Lerp(value1.B, value2.B, amount),
(int) MathHelper.Lerp(value1.A, value2.A, amount)
public static Color FromNonPremultiplied(int r, int g, int b, int a)
#region Public Static Operators and Override Methods
public static bool operator ==(Color a, Color b)
public static bool operator !=(Color a, Color b)
public override int GetHashCode()
return this.packedValue.GetHashCode();
public override bool Equals(object obj)
return ((obj is Color) && this.Equals((Color) obj));
public static Color Multiply(Color value, float scale)
public static Color operator *(Color value, float scale)
public override string ToString()
StringBuilder sb = new StringBuilder(25);
public static class MathHelper
public const float E = (float) Math.E;
public const float Log10E = 0.4342945f;
public const float Log2E = 1.442695f;
public const float Pi = (float) Math.PI;
public const float PiOver2 = (float) (Math.PI / 2.0);
public const float PiOver4 = (float) (Math.PI / 4.0);
public const float TwoPi = (float) (Math.PI * 2.0);
#region Internal Static Readonly Fields
internal static readonly float MachineEpsilonFloat = GetMachineEpsilonFloat();
#region Public Static Methods
public static float Barycentric(
return value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2;
public static float CatmullRom(
double amountSquared = amount * amount;
double amountCubed = amountSquared * amount;
((2.0 * value2 + (value3 - value1) * amount) +
((2.0 * value1 - 5.0 * value2 + 4.0 * value3 - value4) * amountSquared) +
(3.0 * value2 - value1 - 3.0 * value3 + value4) * amountCubed)
public static float Clamp(float value, float min, float max)
value = (value > max) ? max : value;
value = (value < min) ? min : value;
public static float Distance(float value1, float value2)
return Math.Abs(value1 - value2);
public static float Hermite(
double v1 = value1, v2 = value2, t1 = tangent1, t2 = tangent2, s = amount;
double sCubed = s * s * s;
if (WithinEpsilon(amount, 0f))
else if (WithinEpsilon(amount, 1f))
((2 * v1 - 2 * v2 + t2 + t1) * sCubed) +
((3 * v2 - 3 * v1 - 2 * t1 - t2) * sSquared) +
public static float Lerp(float value1, float value2, float amount)
return value1 + (value2 - value1) * amount;
public static float Max(float value1, float value2)
return value1 > value2 ? value1 : value2;
public static float Min(float value1, float value2)
return value1 < value2 ? value1 : value2;
public static float SmoothStep(float value1, float value2, float amount)
float result = MathHelper.Clamp(amount, 0f, 1f);
result = MathHelper.Hermite(value1, 0f, value2, 0f, result);
public static float ToDegrees(float radians)
return (float) (radians * 57.295779513082320876798154814105);
public static float ToRadians(float degrees)
return (float) (degrees * 0.017453292519943295769236907684886);
public static float WrapAngle(float angle)
if ((angle > -Pi) && (angle <= Pi))
#region Internal Static Methods
internal static int Clamp(int value, int min, int max)
value = (value > max) ? max : value;
value = (value < min) ? min : value;
internal static bool WithinEpsilon(float floatA, float floatB)
return Math.Abs(floatA - floatB) < MachineEpsilonFloat;
internal static int ClosestMSAAPower(int value)
#region Private Static Methods
private static float GetMachineEpsilonFloat()
float machineEpsilon = 1.0f;
comparison = 1.0f + machineEpsilon;
while (comparison > 1.0f);