diff --git a/src/Graphics/Color.cs b/src/Graphics/Color.cs index de66d26..1b8d32d 100644 --- a/src/Graphics/Color.cs +++ b/src/Graphics/Color.cs @@ -14,942 +14,1208 @@ using System.Runtime.CompilerServices; using System.Text; using System.Numerics; +using System.Globalization; -namespace MoonWorks.Graphics +namespace MoonWorks.Graphics; + +/// +/// Describes a 32-bit packed color. +/// +public record struct Color(byte R, byte G, byte B, byte A = 255) { + public Color(int r, int g, int b, int a = 255) : this( + (byte) int.Clamp(r, 0, 255), + (byte) int.Clamp(g, 0, 255), + (byte) int.Clamp(b, 0, 255), + (byte) int.Clamp(a, 0, 255) + ) { } + + /// + /// Constructs an RGBA color from scalars which represent red, green, blue and alpha values. + /// + /// Red component value from 0.0f to 1.0f. + /// Green component value from 0.0f to 1.0f. + /// Blue component value from 0.0f to 1.0f. + /// Alpha component value from 0.0f to 1.0f. + public Color(float r, float g, float b, float a) : this( + (byte) (System.Math.Clamp(r, 0, 1) * byte.MaxValue), + (byte) (System.Math.Clamp(g, 0, 1) * byte.MaxValue), + (byte) (System.Math.Clamp(b, 0, 1) * byte.MaxValue), + (byte) (System.Math.Clamp(a, 0, 1) * byte.MaxValue) + ) { } + + /// + /// Constructs an RGBA color from scalars which represent red, green, blue values. Alpha is assumed to be 1. + /// + /// Red component value from 0.0f to 1.0f. + /// Green component value from 0.0f to 1.0f. + /// Blue component value from 0.0f to 1.0f. + public Color(float r, float g, float b) : this( + (byte) (System.Math.Clamp(r, 0, 1) * byte.MaxValue), + (byte) (System.Math.Clamp(g, 0, 1) * byte.MaxValue), + (byte) (System.Math.Clamp(b, 0, 1) * byte.MaxValue), + (byte) 255 + ) { } + + public Color(Vector4 vector) : this(vector.X, vector.Y, vector.Z, vector.W) { } + + // Private, to enforce using explicit FromBigEndianRGB(A) functions. + private Color(uint bigEndian_RGBA) : this( + // Casting to byte triggers overflow behavior, meaning we retain the 8 least significant bits. + (byte)(bigEndian_RGBA >> 24), // R + (byte)(bigEndian_RGBA >> 16), // G + (byte)(bigEndian_RGBA >> 8), // B + (byte)bigEndian_RGBA // A + ) { } + + private Color(int bigEndian_RGB, byte alpha = 255) : this( + (byte)(bigEndian_RGB >> 16), // R + (byte)(bigEndian_RGB >> 8), // G + (byte)bigEndian_RGB, // B + alpha + ) { } + /// - /// Describes a 32-bit packed color. + /// Returns the in a Big-Endian UInt32 packed value format. + /// Thus, the value is in RGBA bit-order. /// - public record struct Color(byte R, byte G, byte B, byte A = 255) + public readonly uint BigEndianPackedValue() { - public Color(int r, int g, int b, int a = 255) : this( - (byte) int.Clamp(r, 0, 255), - (byte) int.Clamp(g, 0, 255), - (byte) int.Clamp(b, 0, 255), - (byte) int.Clamp(a, 0, 255) - ) { } - - /// - /// Constructs an RGBA color from scalars which represent red, green, blue and alpha values. - /// - /// Red component value from 0.0f to 1.0f. - /// Green component value from 0.0f to 1.0f. - /// Blue component value from 0.0f to 1.0f. - /// Alpha component value from 0.0f to 1.0f. - public Color(float r, float g, float b, float a) : this( - (byte) (System.Math.Clamp(r, 0, 1) * byte.MaxValue), - (byte) (System.Math.Clamp(g, 0, 1) * byte.MaxValue), - (byte) (System.Math.Clamp(b, 0, 1) * byte.MaxValue), - (byte) (System.Math.Clamp(a, 0, 1) * byte.MaxValue) - ) { } - - /// - /// Constructs an RGBA color from scalars which represent red, green, blue values. Alpha is assumed to be 1. - /// - /// Red component value from 0.0f to 1.0f. - /// Green component value from 0.0f to 1.0f. - /// Blue component value from 0.0f to 1.0f. - public Color(float r, float g, float b) : this( - (byte) (System.Math.Clamp(r, 0, 1) * byte.MaxValue), - (byte) (System.Math.Clamp(g, 0, 1) * byte.MaxValue), - (byte) (System.Math.Clamp(b, 0, 1) * byte.MaxValue), - (byte) 255 - ) { } - - public Color(Vector4 vector) : this(vector.X, vector.Y, vector.Z, vector.W) { } - - /// - /// Gets packed value of this . - /// - public readonly uint PackedValue() => Unsafe.BitCast(this); - - /// - /// Transparent color (R:0,G:0,B:0,A:0). - /// - public static Color Transparent => new(0, 0, 0, 0); - - /// - /// AliceBlue color (R:240,G:248,B:255,A:255). - /// - public static Color AliceBlue => new(240, 248, 255); - - /// - /// AntiqueWhite color (R:250,G:235,B:215,A:255). - /// - public static Color AntiqueWhite => new(250, 235, 215); - - /// - /// Aqua color (R:0,G:255,B:255,A:255). - /// - public static Color Aqua => new(0, 255, 255); - - /// - /// Aquamarine color (R:127,G:255,B:212,A:255). - /// - public static Color Aquamarine => new(127, 255, 212); - - /// - /// Azure color (R:240,G:255,B:255,A:255). - /// - public static Color Azure => new(240, 255, 255); - - /// - /// Beige color (R:245,G:245,B:220,A:255). - /// - public static Color Beige => new(245, 245, 220); - - /// - /// Bisque color (R:255,G:228,B:196,A:255). - /// - public static Color Bisque => new(255, 228, 196); - - /// - /// Black color (R:0,G:0,B:0,A:255). - /// - public static Color Black => new(0, 0, 0); - - /// - /// BlanchedAlmond color (R:255,G:235,B:205,A:255). - /// - public static Color BlanchedAlmond => new(255, 235, 205); - - /// - /// Blue color (R:0,G:0,B:255,A:255). - /// - public static Color Blue => new(0, 0, 255); - - /// - /// BlueViolet color (R:138,G:43,B:226,A:255). - /// - public static Color BlueViolet => new(138, 43, 226); - - /// - /// Brown color (R:165,G:42,B:42,A:255). - /// - public static Color Brown => new(165, 42, 42); - - /// - /// BurlyWood color (R:222,G:184,B:135,A:255). - /// - public static Color BurlyWood => new(222, 184, 135); - - /// - /// CadetBlue color (R:95,G:158,B:160,A:255). - /// - public static Color CadetBlue => new(95, 158, 160); - - /// - /// Chartreuse color (R:127,G:255,B:0,A:255). - /// - public static Color Chartreuse => new(127, 255, 0); - - /// - /// Chocolate color (R:210,G:105,B:30,A:255). - /// - public static Color Chocolate => new(210, 105, 30); - - /// - /// Coral color (R:255,G:127,B:80,A:255). - /// - public static Color Coral => new (255, 127, 80); - - /// - /// CornflowerBlue color (R:100,G:149,B:237,A:255). - /// - public static Color CornflowerBlue => new(100, 149, 237); - - /// - /// Cornsilk color (R:255,G:248,B:220,A:255). - /// - public static Color Cornsilk => new(255, 248, 220); - - /// - /// Crimson color (R:220,G:20,B:60,A:255). - /// - public static Color Crimson => new(220, 20, 60); - - /// - /// Cyan color (R:0,G:255,B:255,A:255). - /// - public static Color Cyan => new(0, 255, 255); - - /// - /// DarkBlue color (R:0,G:0,B:139,A:255). - /// - public static Color DarkBlue => new(0, 0, 139); - - /// - /// DarkCyan color (R:0,G:139,B:139,A:255). - /// - public static Color DarkCyan => new(0, 139, 139); - - /// - /// DarkGoldenrod color (R:184,G:134,B:11,A:255). - /// - public static Color DarkGoldenrod => new(184, 134, 11); - - /// - /// DarkGray color (R:169,G:169,B:169,A:255). - /// - public static Color DarkGray => new(169, 169, 169); - - /// - /// DarkGreen color (R:0,G:100,B:0,A:255). - /// - public static Color DarkGreen => new(0, 100, 0); - - /// - /// DarkKhaki color (R:189,G:183,B:107,A:255). - /// - public static Color DarkKhaki => new(189, 183, 107); - - /// - /// DarkMagenta color (R:139,G:0,B:139,A:255). - /// - public static Color DarkMagenta => new(139, 0, 139); - - /// - /// DarkOliveGreen color (R:85,G:107,B:47,A:255). - /// - public static Color DarkOliveGreen => new(85, 107, 47); - - /// - /// DarkOrange color (R:255,G:140,B:0,A:255). - /// - public static Color DarkOrange => new(255, 140, 0); - - /// - /// DarkOrchid color (R:153,G:50,B:204,A:255). - /// - public static Color DarkOrchid => new(153, 50, 204); - - /// - /// DarkRed color (R:139,G:0,B:0,A:255). - /// - public static Color DarkRed => new(139, 0, 0); - - /// - /// DarkSalmon color (R:233,G:150,B:122,A:255). - /// - public static Color DarkSalmon => new(233, 150, 122); - - /// - /// DarkSeaGreen color (R:143,G:188,B:139,A:255). - /// - public static Color DarkSeaGreen => new(143, 188, 139); - - /// - /// DarkSlateBlue color (R:72,G:61,B:139,A:255). - /// - public static Color DarkSlateBlue => new(72, 61, 139); - - /// - /// DarkSlateGray color (R:47,G:79,B:79,A:255). - /// - public static Color DarkSlateGray => new(47, 79, 79); - - /// - /// DarkTurquoise color (R:0,G:206,B:209,A:255). - /// - public static Color DarkTurquoise => new(0, 206, 209); - - /// - /// DarkViolet color (R:148,G:0,B:211,A:255). - /// - public static Color DarkViolet => new(148, 0, 211); - - /// - /// DeepPink color (R:255,G:20,B:147,A:255). - /// - public static Color DeepPink => new(255, 20, 147); - - /// - /// DeepSkyBlue color (R:0,G:191,B:255,A:255). - /// - public static Color DeepSkyBlue => new(0, 191, 255); - - /// - /// DimGray color (R:105,G:105,B:105,A:255). - /// - public static Color DimGray => new(105, 105, 105); - - /// - /// DodgerBlue color (R:30,G:144,B:255,A:255). - /// - public static Color DodgerBlue => new(30, 144, 255); - - /// - /// Firebrick color (R:178,G:34,B:34,A:255). - /// - public static Color Firebrick => new(178, 34, 34); - - /// - /// FloralWhite color (R:255,G:250,B:240,A:255). - /// - public static Color FloralWhite => new(255, 250, 240); - - /// - /// ForestGreen color (R:34,G:139,B:34,A:255). - /// - public static Color ForestGreen => new(34, 139, 34); - - /// - /// Fuchsia color (R:255,G:0,B:255,A:255). - /// - public static Color Fuchsia => new(255, 0, 255); - - /// - /// Gainsboro color (R:220,G:220,B:220,A:255). - /// - public static Color Gainsboro => new(220, 220, 220); - - /// - /// GhostWhite color (R:248,G:248,B:255,A:255). - /// - public static Color GhostWhite => new(248, 248, 255); - - /// - /// Gold color (R:255,G:215,B:0,A:255). - /// - public static Color Gold => new(255, 215, 0); - - /// - /// Goldenrod color (R:218,G:165,B:32,A:255). - /// - public static Color Goldenrod => new(218, 165, 32); - - /// - /// Gray color (R:128,G:128,B:128,A:255). - /// - public static Color Gray => new(128, 128, 128); - - /// - /// Green color (R:0,G:128,B:0,A:255). - /// - public static Color Green => new(0, 128, 0); - - /// - /// GreenYellow color (R:173,G:255,B:47,A:255). - /// - public static Color GreenYellow => new(173, 255, 47); - - /// - /// Honeydew color (R:240,G:255,B:240,A:255). - /// - public static Color Honeydew => new(240, 255, 240); - - /// - /// HotPink color (R:255,G:105,B:180,A:255). - /// - public static Color HotPink => new(255, 105, 180); - - /// - /// IndianRed color (R:205,G:92,B:92,A:255). - /// - public static Color IndianRed => new(205, 92, 92); - - /// - /// Indigo color (R:75,G:0,B:130,A:255). - /// - public static Color Indigo => new(75, 0, 130); - - /// - /// Ivory color (R:255,G:255,B:240,A:255). - /// - public static Color Ivory => new(255, 255, 240); - - /// - /// Khaki color (R:240,G:230,B:140,A:255). - /// - public static Color Khaki => new(240, 230, 140); - - /// - /// Lavender color (R:230,G:230,B:250,A:255). - /// - public static Color Lavender => new(230, 230, 250); - - /// - /// LavenderBlush color (R:255,G:240,B:245,A:255). - /// - public static Color LavenderBlush => new(255, 240, 245); - - /// - /// LawnGreen color (R:124,G:252,B:0,A:255). - /// - public static Color LawnGreen => new(124, 252, 0); - - /// - /// LemonChiffon color (R:255,G:250,B:205,A:255). - /// - public static Color LemonChiffon => new(255, 250, 205); - - /// - /// LightBlue color (R:173,G:216,B:230,A:255). - /// - public static Color LightBlue => new(173, 216, 230); - - /// - /// LightCoral color (R:240,G:128,B:128,A:255). - /// - public static Color LightCoral => new(240, 128, 128); - - /// - /// LightCyan color (R:224,G:255,B:255,A:255). - /// - public static Color LightCyan => new(224, 255, 255); - - /// - /// LightGoldenrodYellow color (R:250,G:250,B:210,A:255). - /// - public static Color LightGoldenrodYellow => new(250, 250, 210); - - /// - /// LightGray color (R:211,G:211,B:211,A:255). - /// - public static Color LightGray => new(211, 211, 211); - - /// - /// LightGreen color (R:144,G:238,B:144,A:255). - /// - public static Color LightGreen => new(144, 238, 144); - - /// - /// LightPink color (R:255,G:182,B:193,A:255). - /// - public static Color LightPink => new(255, 182, 193); - - /// - /// LightSalmon color (R:255,G:160,B:122,A:255). - /// - public static Color LightSalmon => new(255, 160, 122); - - /// - /// LightSeaGreen color (R:32,G:178,B:170,A:255). - /// - public static Color LightSeaGreen => new(32, 178, 170); - - /// - /// LightSkyBlue color (R:135,G:206,B:250,A:255). - /// - public static Color LightSkyBlue => new(135, 206, 250); - - /// - /// LightSlateGray color (R:119,G:136,B:153,A:255). - /// - public static Color LightSlateGray => new(119, 136, 153); - - /// - /// LightSteelBlue color (R:176,G:196,B:222,A:255). - /// - public static Color LightSteelBlue => new(179, 196, 222); - - /// - /// LightYellow color (R:255,G:255,B:224,A:255). - /// - public static Color LightYellow => new(255, 255, 224); - - /// - /// Lime color (R:0,G:255,B:0,A:255). - /// - public static Color Lime => new(0, 255, 0); - - /// - /// LimeGreen color (R:50,G:205,B:50,A:255). - /// - public static Color LimeGreen => new(50, 205, 50); - - /// - /// Linen color (R:250,G:240,B:230,A:255). - /// - public static Color Linen => new(250, 240, 230); - - /// - /// Magenta color (R:255,G:0,B:255,A:255). - /// - public static Color Magenta => new(255, 0, 255); - - /// - /// Maroon color (R:128,G:0,B:0,A:255). - /// - public static Color Maroon => new(128, 0, 0, 255); - - /// - /// MediumAquamarine color (R:102,G:205,B:170,A:255). - /// - public static Color MediumAquamarine => new(102, 205, 170); - - /// - /// MediumBlue color (R:0,G:0,B:205,A:255). - /// - public static Color MediumBlue => new(0, 0, 205); - - /// - /// MediumOrchid color (R:186,G:85,B:211,A:255). - /// - public static Color MediumOrchid => new(186, 85, 211); - - /// - /// MediumPurple color (R:147,G:112,B:219,A:255). - /// - public static Color MediumPurple => new(147, 112, 219); - - /// - /// MediumSeaGreen color (R:60,G:179,B:113,A:255). - /// - public static Color MediumSeaGreen => new(60, 179, 113); - - /// - /// MediumSlateBlue color (R:123,G:104,B:238,A:255). - /// - public static Color MediumSlateBlue => new(123, 104, 238); - - /// - /// MediumSpringGreen color (R:0,G:250,B:154,A:255). - /// - public static Color MediumSpringGreen => new(0, 250, 154); - - /// - /// MediumTurquoise color (R:72,G:209,B:204,A:255). - /// - public static Color MediumTurquoise => new(72, 209, 204); - - /// - /// MediumVioletRed color (R:199,G:21,B:133,A:255). - /// - public static Color MediumVioletRed => new(199, 21, 133); - - /// - /// MidnightBlue color (R:25,G:25,B:112,A:255). - /// - public static Color MidnightBlue => new(25, 25, 112); - - /// - /// MintCream color (R:245,G:255,B:250,A:255). - /// - public static Color MintCream => new(245, 255, 250); - - /// - /// MistyRose color (R:255,G:228,B:225,A:255). - /// - public static Color MistyRose => new(255, 228, 225); - - /// - /// Moccasin color (R:255,G:228,B:181,A:255). - /// - public static Color Moccasin => new(255, 228, 181); - - /// - /// NavajoWhite color (R:255,G:222,B:173,A:255). - /// - public static Color NavajoWhite => new(255, 222, 173); - - /// - /// Navy color (R:0,G:0,B:128,A:255). - /// - public static Color Navy => new(0, 0, 128); - - /// - /// OldLace color (R:253,G:245,B:230,A:255). - /// - public static Color OldLace => new(253, 245, 230); - - /// - /// Olive color (R:128,G:128,B:0,A:255). - /// - public static Color Olive => new(128, 128, 0); - - /// - /// OliveDrab color (R:107,G:142,B:35,A:255). - /// - public static Color OliveDrab => new(107, 142, 35); - - /// - /// Orange color (R:255,G:165,B:0,A:255). - /// - public static Color Orange => new(255, 165, 0); - - /// - /// OrangeRed color (R:255,G:69,B:0,A:255). - /// - public static Color OrangeRed => new(255, 69, 0); - - /// - /// Orchid color (R:218,G:112,B:214,A:255). - /// - public static Color Orchid => new(218, 112, 214); - - /// - /// PaleGoldenrod color (R:238,G:232,B:170,A:255). - /// - public static Color PaleGoldenrod => new(238, 232, 170); - - /// - /// PaleGreen color (R:152,G:251,B:152,A:255). - /// - public static Color PaleGreen => new(152, 251, 152); - - /// - /// PaleTurquoise color (R:175,G:238,B:238,A:255). - /// - public static Color PaleTurquoise => new(175, 238, 238); - - /// - /// PaleVioletRed color (R:219,G:112,B:147,A:255). - /// - public static Color PaleVioletRed => new(219, 112, 147); - - /// - /// PapayaWhip color (R:255,G:239,B:213,A:255). - /// - public static Color PapayaWhip => new(255, 239, 213); - - /// - /// PeachPuff color (R:255,G:218,B:185,A:255). - /// - public static Color PeachPuff => new(255, 218, 185); - - /// - /// Peru color (R:205,G:133,B:63,A:255). - /// - public static Color Peru => new(205, 133, 63); - - /// - /// Pink color (R:255,G:192,B:203,A:255). - /// - public static Color Pink => new(255, 192, 203); - - /// - /// Plum color (R:221,G:160,B:221,A:255). - /// - public static Color Plum => new(221, 160, 221); - - /// - /// PowderBlue color (R:176,G:224,B:230,A:255). - /// - public static Color PowderBlue => new(176, 224, 230); - - /// - /// Purple color (R:128,G:0,B:128,A:255). - /// - public static Color Purple => new(128, 0, 128); - - /// - /// Red color (R:255,G:0,B:0,A:255). - /// - public static Color Red => new(255, 0, 0); - - /// - /// RosyBrown color (R:188,G:143,B:143,A:255). - /// - public static Color RosyBrown => new(188, 143, 143); - - /// - /// RoyalBlue color (R:65,G:105,B:225,A:255). - /// - public static Color RoyalBlue => new(65, 105, 225); - - /// - /// SaddleBrown color (R:139,G:69,B:19,A:255). - /// - public static Color SaddleBrown => new(139, 69, 19); - - /// - /// Salmon color (R:250,G:128,B:114,A:255). - /// - public static Color Salmon => new(250, 128, 114); - - /// - /// SandyBrown color (R:244,G:164,B:96,A:255). - /// - public static Color SandyBrown => new(244, 164, 96); - - /// - /// SeaGreen color (R:46,G:139,B:87,A:255). - /// - public static Color SeaGreen => new(46, 139, 87); - - /// - /// SeaShell color (R:255,G:245,B:238,A:255). - /// - public static Color SeaShell => new(255, 245, 238); - - /// - /// Sienna color (R:160,G:82,B:45,A:255). - /// - public static Color Sienna => new(160, 82, 45); - - /// - /// Silver color (R:192,G:192,B:192,A:255). - /// - public static Color Silver => new(192, 192, 192); - - /// - /// SkyBlue color (R:135,G:206,B:235,A:255). - /// - public static Color SkyBlue => new(135, 206, 235); - - /// - /// SlateBlue color (R:106,G:90,B:205,A:255). - /// - public static Color SlateBlue => new(106, 90, 205); - - /// - /// SlateGray color (R:112,G:128,B:144,A:255). - /// - public static Color SlateGray => new(112, 128, 144); - - /// - /// Snow color (R:255,G:250,B:250,A:255). - /// - public static Color Snow => new(255, 250, 250); - - /// - /// SpringGreen color (R:0,G:255,B:127,A:255). - /// - public static Color SpringGreen => new(0, 255, 127); - - /// - /// SteelBlue color (R:70,G:130,B:180,A:255). - /// - public static Color SteelBlue => new(70, 130, 180); - - /// - /// Tan color (R:210,G:180,B:140,A:255). - /// - public static Color Tan => new(210, 180, 140); - - /// - /// Teal color (R:0,G:128,B:128,A:255). - /// - public static Color Teal => new(0, 128, 128); - - /// - /// Thistle color (R:216,G:191,B:216,A:255). - /// - public static Color Thistle => new(216, 191, 216); - - /// - /// Tomato color (R:255,G:99,B:71,A:255). - /// - public static Color Tomato => new(255, 99, 71); - - /// - /// Turquoise color (R:64,G:224,B:208,A:255). - /// - public static Color Turquoise => new(64, 224, 208); - - /// - /// Violet color (R:238,G:130,B:238,A:255). - /// - public static Color Violet => new(238, 130, 238); - - /// - /// Wheat color (R:245,G:222,B:179,A:255). - /// - public static Color Wheat => new(245, 222, 179); - - /// - /// White color (R:255,G:255,B:255,A:255). - /// - public static Color White => new(255, 255, 255); - - /// - /// WhiteSmoke color (R:245,G:245,B:245,A:255). - /// - public static Color WhiteSmoke => new(245, 245, 245); - - /// - /// Yellow color (R:255,G:255,B:0,A:255). - /// - public static Color Yellow => new(255, 255, 0); - - /// - /// YellowGreen color (R:154,G:205,B:50,A:255). - /// - public static Color YellowGreen => new(154, 205, 50); - - /// - /// Gets a representation for this object. - /// - /// A representation for this object. - public Vector3 ToVector3() - { - return new Vector3(R / 255.0f, G / 255.0f, B / 255.0f); - } + return ((uint)R << 24) | ((uint)G << 16) | ((uint)B << 8) | A; + } + + /// + /// Converts a big-endian RGBA packed color into a .
+ /// Example valid input: `0xF0F8FFFF`, aka . + ///
+ /// A big-endian packed color that specifies R, G, B, and A values. + /// A representation for the big-endian RGBA packed value. + public static Color FromBigEndianRGBA(uint bigEndian_RGBA) + { + return new Color(bigEndian_RGBA); + } + + /// + /// Converts a big-endian RGB packed color into a .
+ /// Example valid input: `0xF0F8FF`, aka . + /// The above will be interpeted as a big-endian RGBA input of `0xF0F8FF(alpha)`.
+ ///
+ /// A big-endian packed color that specifies R, G, and B values. + /// The Alpha channel value for the color. + /// A representation for the big-endian RGB packed value. + public static Color FromBigEndianRGB(int bigEndian_RGB, byte alpha = 255) + { + return new Color(bigEndian_RGB, alpha); + } - /// - /// Gets a representation for this object. - /// - /// A representation for this object. - public Vector4 ToVector4() - { - return new Vector4(R / 255.0f, G / 255.0f, B / 255.0f, A / 255.0f); - } + /// + /// Gets a representation for this object. + /// + /// A representation for this object. + public Vector3 ToVector3() + { + return new Vector3(R / 255.0f, G / 255.0f, B / 255.0f); + } - /// - /// Performs linear interpolation of . - /// - /// Source . - /// Destination . - /// Interpolation factor. - /// Interpolated . - public static Color Lerp(Color value1, Color value2, float amount) - { - amount = float.Clamp(amount, 0.0f, 1.0f); - return new Color( - float.Lerp(value1.R / 255f, value2.R / 255f, amount), - float.Lerp(value1.G / 255f, value2.G / 255f, amount), - float.Lerp(value1.B / 255f, value2.B / 255f, amount), - float.Lerp(value1.A / 255f, value2.A / 255f, amount) - ); - } + /// + /// Gets a representation for this object. + /// + /// A representation for this object. + public Vector4 ToVector4() + { + return new Vector4(R / 255.0f, G / 255.0f, B / 255.0f, A / 255.0f); + } + + /// + /// Performs linear interpolation of . + /// + /// Source . + /// Destination . + /// Interpolation factor. + /// Interpolated . + public static Color Lerp(Color value1, Color value2, float amount) + { + amount = float.Clamp(amount, 0.0f, 1.0f); + return new Color( + float.Lerp(value1.R / 255f, value2.R / 255f, amount), + float.Lerp(value1.G / 255f, value2.G / 255f, amount), + float.Lerp(value1.B / 255f, value2.B / 255f, amount), + float.Lerp(value1.A / 255f, value2.A / 255f, amount) + ); + } - /// - /// Translate a non-premultipled alpha to a - /// that contains premultiplied alpha. - /// - /// A representing color. - /// A which contains premultiplied alpha data. - public static Color FromNonPremultiplied(System.Numerics.Vector4 vector) + /// + /// Translate a non-premultipled alpha to a + /// that contains premultiplied alpha. + /// + /// A representing color. + /// A which contains premultiplied alpha data. + public static Color FromNonPremultiplied(System.Numerics.Vector4 vector) + { + return new Color( + vector.X * vector.W, + vector.Y * vector.W, + vector.Z * vector.W, + vector.W + ); + } + + /// + /// Translate a non-premultipled alpha to a + /// that contains premultiplied alpha. + /// + /// Red component value. + /// Green component value. + /// Blue component value. + /// Alpha component value. + /// A which contains premultiplied alpha data. + public static Color FromNonPremultiplied(byte r, byte g, byte b, byte a) + { + return new Color( + r * a / 255, + g * a / 255, + b * a / 255, + a + ); + } + + // Modified from one of the responses here: + // https://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb-in-range-0-255-for-both/6930407#6930407 + public static Color FromHSV(float r, float g, float b) + { + r = (100 + r) % 1f; + + float hueSlice = 6 * r; // [0, 6) + float hueSliceInteger = MathF.Floor(hueSlice); + + // In [0,1) for each hue slice + float hueSliceInterpolant = hueSlice - hueSliceInteger; + + Vector3 tempRGB = new Vector3( + b * (1f - g), + b * (1f - g * hueSliceInterpolant), + b * (1f - g * (1f - hueSliceInterpolant)) + ); + + // The idea here to avoid conditions is to notice that the conversion code can be rewritten: + // if ( var_i == 0 ) { R = V ; G = TempRGB.z ; B = TempRGB.x } + // else if ( var_i == 2 ) { R = TempRGB.x ; G = V ; B = TempRGB.z } + // else if ( var_i == 4 ) { R = TempRGB.z ; G = TempRGB.x ; B = V } + // + // else if ( var_i == 1 ) { R = TempRGB.y ; G = V ; B = TempRGB.x } + // else if ( var_i == 3 ) { R = TempRGB.x ; G = TempRGB.y ; B = V } + // else if ( var_i == 5 ) { R = V ; G = TempRGB.x ; B = TempRGB.y } + // + // This shows several things: + // . A separation between even and odd slices + // . If slices (0,2,4) and (1,3,5) can be rewritten as basically being slices (0,1,2) then + // the operation simply amounts to performing a "rotate right" on the RGB components + // . The base value to rotate is either (V, B, R) for even slices or (G, V, R) for odd slices + // + float isOddSlice = hueSliceInteger % 2f; // 0 if even (slices 0, 2, 4), 1 if odd (slices 1, 3, 5) + float threeSliceSelector = 0.5f * (hueSliceInteger - isOddSlice); // (0, 1, 2) corresponding to slices (0, 2, 4) and (1, 3, 5) + + Vector3 scrollingRGBForEvenSlices = new Vector3(b, tempRGB.Z, tempRGB.X); // (V, Temp Blue, Temp Red) for even slices (0, 2, 4) + Vector3 scrollingRGBForOddSlices = new Vector3(tempRGB.Y, b, tempRGB.X); // (Temp Green, V, Temp Red) for odd slices (1, 3, 5) + Vector3 scrollingRGB = Vector3.Lerp(scrollingRGBForEvenSlices, scrollingRGBForOddSlices, isOddSlice); + + float IsNotFirstSlice = float.Clamp(threeSliceSelector, 0f, 1f); // 1 if NOT the first slice (true for slices 1 and 2) + float IsNotSecondSlice = float.Clamp(threeSliceSelector - 1f, 0f, 1f); // 1 if NOT the first or second slice (true only for slice 2) + + Vector3 color = Vector3.Lerp( + scrollingRGB, + Vector3.Lerp( + new Vector3(scrollingRGB.Z, scrollingRGB.X, scrollingRGB.Y), + new Vector3(scrollingRGB.Y, scrollingRGB.Z, scrollingRGB.X), + IsNotSecondSlice + ), + IsNotFirstSlice + ); + + return new Color(color.X, color.Y, color.Z, 1f); + } + + public static Color FromHSV(int r, int g, int b) + { + return FromHSV(r / 255f, g / 255f, b / 255f); + } + + /// + /// Multiply by value. + /// + /// Source . + /// Multiplicator. + /// Multiplication result. + public static Color operator *(Color value, float scale) + { + return new Color( + value.R * scale / 255f, + value.G * scale / 255f, + value.B * scale / 255f, + value.A * scale / 255f + ); + } + + /// + /// Returns a representation of this in the format: + /// {R:[red] G:[green] B:[blue] A:[alpha]} + /// + /// representation of this . + public override string ToString() + { + StringBuilder sb = new StringBuilder(25); + sb.Append("{R:"); + sb.Append(R); + sb.Append(" G:"); + sb.Append(G); + sb.Append(" B:"); + sb.Append(B); + sb.Append(" A:"); + sb.Append(A); + sb.Append("}"); + return sb.ToString(); + } + + /// + /// Returns a hexadecimal representation of this in the format: + /// (Prefix)[R][G][B][A]
+ /// Thus, it's in Big Endian format.
+ /// The prefix will either be "0x" (default) or "#". + ///
+ /// "0x" prefix if false, "#" otherwise. + /// representation of this . + public string ToHexString(bool hexadecimalOrHashtagPrefix = false) + { + StringBuilder sb = new StringBuilder(10); + if (hexadecimalOrHashtagPrefix) + { + sb.Append("#"); + } + else + { + sb.Append("0x"); + } + sb.Append(BigEndianPackedValue().ToString("X8")); + return sb.ToString(); + } + + /// + /// Returns a representation of a in hexadecimal format.
+ /// If the conversion fails, returns null.
+ /// The string must have the following big-endian format: + /// (Prefix)[R][G][B][A]*
+ /// Only "#", "0x", or no prefix at all are valid prefixes.
+ /// *: Specifying A is optional. In this case, a default of 0xFF / 255 (fully opaque) is assumed. + ///
+ /// A representation of the hex . Null if the conversion fails. + public static Color? FromHexString(string hexString) + { + if (hexString.StartsWith("0x", StringComparison.CurrentCultureIgnoreCase)) { - return new Color( - vector.X * vector.W, - vector.Y * vector.W, - vector.Z * vector.W, - vector.W - ); + hexString = hexString.Substring(2); } - - /// - /// Translate a non-premultipled alpha to a - /// that contains premultiplied alpha. - /// - /// Red component value. - /// Green component value. - /// Blue component value. - /// Alpha component value. - /// A which contains premultiplied alpha data. - public static Color FromNonPremultiplied(byte r, byte g, byte b, byte a) + else if (hexString.StartsWith("#", StringComparison.CurrentCultureIgnoreCase)) { - return new Color( - r * a / 255, - g * a / 255, - b * a / 255, - a - ); + hexString = hexString.Substring(1); } - // Modified from one of the responses here: - // https://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb-in-range-0-255-for-both/6930407#6930407 - public static Color FromHSV(float r, float g, float b) + if (hexString.Length != 6 && hexString.Length != 8) { - r = (100 + r) % 1f; - - float hueSlice = 6 * r; // [0, 6) - float hueSliceInteger = MathF.Floor(hueSlice); - - // In [0,1) for each hue slice - float hueSliceInterpolant = hueSlice - hueSliceInteger; - - Vector3 tempRGB = new Vector3( - b * (1f - g), - b * (1f - g * hueSliceInterpolant), - b * (1f - g * (1f - hueSliceInterpolant)) - ); - - // The idea here to avoid conditions is to notice that the conversion code can be rewritten: - // if ( var_i == 0 ) { R = V ; G = TempRGB.z ; B = TempRGB.x } - // else if ( var_i == 2 ) { R = TempRGB.x ; G = V ; B = TempRGB.z } - // else if ( var_i == 4 ) { R = TempRGB.z ; G = TempRGB.x ; B = V } - // - // else if ( var_i == 1 ) { R = TempRGB.y ; G = V ; B = TempRGB.x } - // else if ( var_i == 3 ) { R = TempRGB.x ; G = TempRGB.y ; B = V } - // else if ( var_i == 5 ) { R = V ; G = TempRGB.x ; B = TempRGB.y } - // - // This shows several things: - // . A separation between even and odd slices - // . If slices (0,2,4) and (1,3,5) can be rewritten as basically being slices (0,1,2) then - // the operation simply amounts to performing a "rotate right" on the RGB components - // . The base value to rotate is either (V, B, R) for even slices or (G, V, R) for odd slices - // - float isOddSlice = hueSliceInteger % 2f; // 0 if even (slices 0, 2, 4), 1 if odd (slices 1, 3, 5) - float threeSliceSelector = 0.5f * (hueSliceInteger - isOddSlice); // (0, 1, 2) corresponding to slices (0, 2, 4) and (1, 3, 5) - - Vector3 scrollingRGBForEvenSlices = new Vector3(b, tempRGB.Z, tempRGB.X); // (V, Temp Blue, Temp Red) for even slices (0, 2, 4) - Vector3 scrollingRGBForOddSlices = new Vector3(tempRGB.Y, b, tempRGB.X); // (Temp Green, V, Temp Red) for odd slices (1, 3, 5) - Vector3 scrollingRGB = Vector3.Lerp(scrollingRGBForEvenSlices, scrollingRGBForOddSlices, isOddSlice); - - float IsNotFirstSlice = float.Clamp(threeSliceSelector, 0f, 1f); // 1 if NOT the first slice (true for slices 1 and 2) - float IsNotSecondSlice = float.Clamp(threeSliceSelector - 1f, 0f, 1f); // 1 if NOT the first or second slice (true only for slice 2) - - Vector3 color = Vector3.Lerp( - scrollingRGB, - Vector3.Lerp( - new Vector3(scrollingRGB.Z, scrollingRGB.X, scrollingRGB.Y), - new Vector3(scrollingRGB.Y, scrollingRGB.Z, scrollingRGB.X), - IsNotSecondSlice - ), - IsNotFirstSlice - ); - - return new Color(color.X, color.Y, color.Z, 1f); + return null; } - public static Color FromHSV(int r, int g, int b) + uint bigEndianPackedValue; + bool success = uint.TryParse( + hexString, + NumberStyles.HexNumber, + CultureInfo.InvariantCulture, + out bigEndianPackedValue + ); + + if (!success) { - return FromHSV(r / 255f, g / 255f, b / 255f); + return null; } - /// - /// Multiply by value. - /// - /// Source . - /// Multiplicator. - /// Multiplication result. - public static Color operator *(Color value, float scale) + if (hexString.Length == 8) { - return new Color( - value.R * scale / 255f, - value.G * scale / 255f, - value.B * scale / 255f, - value.A * scale / 255f - ); + // Assume all RGBA values were specified. + return FromBigEndianRGBA(bigEndianPackedValue); } - - /// - /// Returns a representation of this in the format: - /// {R:[red] G:[green] B:[blue] A:[alpha]} - /// - /// representation of this . - public override string ToString() + else { - StringBuilder sb = new StringBuilder(25); - sb.Append("{R:"); - sb.Append(R); - sb.Append(" G:"); - sb.Append(G); - sb.Append(" B:"); - sb.Append(B); - sb.Append(" A:"); - sb.Append(A); - sb.Append("}"); - return sb.ToString(); + // Assume only RGB values were specified. + return FromBigEndianRGB((int)bigEndianPackedValue); } + } - public static implicit operator VertexStructs.Ubyte4Norm(Color color) => new VertexStructs.Ubyte4Norm - { - X = color.R, - Y = color.G, - Z = color.B, - W = color.A - }; + public static implicit operator VertexStructs.Ubyte4Norm(Color color) => new VertexStructs.Ubyte4Norm + { + X = color.R, + Y = color.G, + Z = color.B, + W = color.A + }; - public static implicit operator FColor(Color color) => new FColor - { - R = color.R / 255f, - G = color.G / 255f, - B = color.B / 255f, - A = color.A / 255f - }; - } -} + public static implicit operator FColor(Color color) => new FColor + { + R = color.R / 255f, + G = color.G / 255f, + B = color.B / 255f, + A = color.A / 255f + }; + + + //MARK: Built-In Colors + + /// + /// Transparent color (R:0, G:0, B:0, A:0). + /// + public static Color Transparent => new((byte)0, (byte)0, (byte)0, (byte)0); + + /// + /// AliceBlue color (R:240, G:248, B:255, A:255).
+ /// RGBA Hex: #F0F8FFFF. + ///
+ public static Color AliceBlue => new((byte)240, (byte)248, (byte)255); + + /// + /// AntiqueWhite color (R:250, G:235, B:215, A:255).
+ /// RGBA Hex: #FAEBD7FF. + ///
+ public static Color AntiqueWhite => new((byte)250, (byte)235, (byte)215); + + /// + /// Aqua color (R:0, G:255, B:255, A:255).
+ /// RGBA Hex: #00FFFFFF. + ///
+ public static Color Aqua => new((byte)0, (byte)255, (byte)255); + + /// + /// Aquamarine color (R:127, G:255, B:212, A:255).
+ /// RGBA Hex: #7FFFD4FF. + ///
+ public static Color Aquamarine => new((byte)127, (byte)255, (byte)212); + + /// + /// Azure color (R:240, G:255, B:255, A:255).
+ /// RGBA Hex: #F0FFFFFF. + ///
+ public static Color Azure => new((byte)240, (byte)255, (byte)255); + + /// + /// Beige color (R:245, G:245, B:220, A:255).
+ /// RGBA Hex: #F5F5DCFF. + ///
+ public static Color Beige => new((byte)245, (byte)245, (byte)220); + + /// + /// Bisque color (R:255, G:228, B:196, A:255).
+ /// RGBA Hex: #FFE4C4FF. + ///
+ public static Color Bisque => new((byte)255, (byte)228, (byte)196); + + /// + /// Black color (R:0, G:0, B:0, A:255).
+ /// RGBA Hex: #000000FF. + ///
+ public static Color Black => new((byte)0, (byte)0, (byte)0); + + /// + /// BlanchedAlmond color (R:255, G:235, B:205, A:255).
+ /// RGBA Hex: #FFEBCDFF. + ///
+ public static Color BlanchedAlmond => new((byte)255, (byte)235, (byte)205); + + /// + /// Blue color (R:0, G:0, B:255, A:255).
+ /// RGBA Hex: #0000FFFF. + ///
+ public static Color Blue => new((byte)0, (byte)0, (byte)255); + + /// + /// BlueViolet color (R:138, G:43, B:226, A:255).
+ /// RGBA Hex: #8A2BE2FF. + ///
+ public static Color BlueViolet => new((byte)138, (byte)43, (byte)226); + + /// + /// Brown color (R:165, G:42, B:42, A:255).
+ /// RGBA Hex: #A52A2AFF. + ///
+ public static Color Brown => new((byte)165, (byte)42, (byte)42); + + /// + /// BurlyWood color (R:222, G:184, B:135, A:255).
+ /// RGBA Hex: #DEB887FF. + ///
+ public static Color BurlyWood => new((byte)222, (byte)184, (byte)135); + + /// + /// CadetBlue color (R:95, G:158, B:160, A:255).
+ /// RGBA Hex: #5F9EA0FF. + ///
+ public static Color CadetBlue => new((byte)95, (byte)158, (byte)160); + + /// + /// Chartreuse color (R:127, G:255, B:0, A:255).
+ /// RGBA Hex: #7FFF00FF. + ///
+ public static Color Chartreuse => new((byte)127, (byte)255, (byte)0); + + /// + /// Chocolate color (R:210, G:105, B:30, A:255).
+ /// RGBA Hex: #D2691EFF. + ///
+ public static Color Chocolate => new((byte)210, (byte)105, (byte)30); + + /// + /// Coral color (R:255, G:127, B:80, A:255).
+ /// RGBA Hex: #FF7F50FF. + ///
+ public static Color Coral => new((byte)255, (byte)127, (byte)80); + + /// + /// CornflowerBlue color (R:100, G:149, B:237, A:255).
+ /// RGBA Hex: #6495EDFF. + ///
+ public static Color CornflowerBlue => new((byte)100, (byte)149, (byte)237); + + /// + /// Cornsilk color (R:255, G:248, B:220, A:255).
+ /// RGBA Hex: #FFF8DCFF. + ///
+ public static Color Cornsilk => new((byte)255, (byte)248, (byte)220); + + /// + /// Crimson color (R:220, G:20, B:60, A:255).
+ /// RGBA Hex: #DC143CFF. + ///
+ public static Color Crimson => new((byte)220, (byte)20, (byte)60); + + /// + /// Cyan color (R:0, G:255, B:255, A:255).
+ /// RGBA Hex: #00FFFFFF. + ///
+ public static Color Cyan => new((byte)0, (byte)255, (byte)255); + + /// + /// DarkBlue color (R:0, G:0, B:139, A:255).
+ /// RGBA Hex: #00008BFF. + ///
+ public static Color DarkBlue => new((byte)0, (byte)0, (byte)139); + + /// + /// DarkCyan color (R:0, G:139, B:139, A:255).
+ /// RGBA Hex: #008B8BFF. + ///
+ public static Color DarkCyan => new((byte)0, (byte)139, (byte)139); + + /// + /// DarkGoldenrod color (R:184, G:134, B:11, A:255).
+ /// RGBA Hex: #B8860BFF. + ///
+ public static Color DarkGoldenrod => new((byte)184, (byte)134, (byte)11); + + /// + /// DarkGray color (R:169, G:169, B:169, A:255).
+ /// RGBA Hex: #A9A9A9FF. + ///
+ public static Color DarkGray => new((byte)169, (byte)169, (byte)169); + + /// + /// DarkGreen color (R:0, G:100, B:0, A:255).
+ /// RGBA Hex: #006400FF. + ///
+ public static Color DarkGreen => new((byte)0, (byte)100, (byte)0); + + /// + /// DarkKhaki color (R:189, G:183, B:107, A:255).
+ /// RGBA Hex: #BDB76BFF. + ///
+ public static Color DarkKhaki => new((byte)189, (byte)183, (byte)107); + + /// + /// DarkMagenta color (R:139, G:0, B:139, A:255).
+ /// RGBA Hex: #8B008BFF. + ///
+ public static Color DarkMagenta => new((byte)139, (byte)0, (byte)139); + + /// + /// DarkOliveGreen color (R:85, G:107, B:47, A:255).
+ /// RGBA Hex: #556B2FFF. + ///
+ public static Color DarkOliveGreen => new((byte)85, (byte)107, (byte)47); + + /// + /// DarkOrange color (R:255, G:140, B:0, A:255).
+ /// RGBA Hex: #FF8C00FF. + ///
+ public static Color DarkOrange => new((byte)255, (byte)140, (byte)0); + + /// + /// DarkOrchid color (R:153, G:50, B:204, A:255).
+ /// RGBA Hex: #9932CCFF. + ///
+ public static Color DarkOrchid => new((byte)153, (byte)50, (byte)204); + + /// + /// DarkRed color (R:139, G:0, B:0, A:255).
+ /// RGBA Hex: #8B0000FF. + ///
+ public static Color DarkRed => new((byte)139, (byte)0, (byte)0); + + /// + /// DarkSalmon color (R:233, G:150, B:122, A:255).
+ /// RGBA Hex: #E9967AFF. + ///
+ public static Color DarkSalmon => new((byte)233, (byte)150, (byte)122); + + /// + /// DarkSeaGreen color (R:143, G:188, B:143, A:255).
+ /// RGBA Hex: #8FBC8FFF. + ///
+ public static Color DarkSeaGreen => new((byte)143, (byte)188, (byte)143); + + /// + /// DarkSlateBlue color (R:72, G:61, B:139, A:255).
+ /// RGBA Hex: #483D8BFF. + ///
+ public static Color DarkSlateBlue => new((byte)72, (byte)61, (byte)139); + + /// + /// DarkSlateGray color (R:47, G:79, B:79, A:255).
+ /// RGBA Hex: #2F4F4FFF. + ///
+ public static Color DarkSlateGray => new((byte)47, (byte)79, (byte)79); + + /// + /// DarkTurquoise color (R:0, G:206, B:209, A:255).
+ /// RGBA Hex: #00CED1FF. + ///
+ public static Color DarkTurquoise => new((byte)0, (byte)206, (byte)209); + + /// + /// DarkViolet color (R:148, G:0, B:211, A:255).
+ /// RGBA Hex: #9400D3FF. + ///
+ public static Color DarkViolet => new((byte)148, (byte)0, (byte)211); + + /// + /// DeepPink color (R:255, G:20, B:147, A:255).
+ /// RGBA Hex: #FF1493FF. + ///
+ public static Color DeepPink => new((byte)255, (byte)20, (byte)147); + + /// + /// DeepSkyBlue color (R:0, G:191, B:255, A:255).
+ /// RGBA Hex: #00BFFFFF. + ///
+ public static Color DeepSkyBlue => new((byte)0, (byte)191, (byte)255); + + /// + /// DimGray color (R:105, G:105, B:105, A:255).
+ /// RGBA Hex: #696969FF. + ///
+ public static Color DimGray => new((byte)105, (byte)105, (byte)105); + + /// + /// DodgerBlue color (R:30, G:144, B:255, A:255).
+ /// RGBA Hex: #1E90FFFF. + ///
+ public static Color DodgerBlue => new((byte)30, (byte)144, (byte)255); + + /// + /// Firebrick color (R:178, G:34, B:34, A:255).
+ /// RGBA Hex: #B22222FF. + ///
+ public static Color Firebrick => new((byte)178, (byte)34, (byte)34); + + /// + /// FloralWhite color (R:255, G:250, B:240, A:255).
+ /// RGBA Hex: #FFFAF0FF. + ///
+ public static Color FloralWhite => new((byte)255, (byte)250, (byte)240); + + /// + /// ForestGreen color (R:34, G:139, B:34, A:255).
+ /// RGBA Hex: #228B22FF. + ///
+ public static Color ForestGreen => new((byte)34, (byte)139, (byte)34); + + /// + /// Fuchsia color (R:255, G:0, B:255, A:255).
+ /// RGBA Hex: #FF00FFFF. + ///
+ public static Color Fuchsia => new((byte)255, (byte)0, (byte)255); + + /// + /// Gainsboro color (R:220, G:220, B:220, A:255).
+ /// RGBA Hex: #DCDCDCFF. + ///
+ public static Color Gainsboro => new((byte)220, (byte)220, (byte)220); + + /// + /// GhostWhite color (R:248, G:248, B:255, A:255).
+ /// RGBA Hex: #F8F8FFFF. + ///
+ public static Color GhostWhite => new((byte)248, (byte)248, (byte)255); + + /// + /// Gold color (R:255, G:215, B:0, A:255).
+ /// RGBA Hex: #FFD700FF. + ///
+ public static Color Gold => new((byte)255, (byte)215, (byte)0); + + /// + /// Goldenrod color (R:218, G:165, B:32, A:255).
+ /// RGBA Hex: #DAA520FF. + ///
+ public static Color Goldenrod => new((byte)218, (byte)165, (byte)32); + + /// + /// Gray color (R:128, G:128, B:128, A:255).
+ /// RGBA Hex: #808080FF. + ///
+ public static Color Gray => new((byte)128, (byte)128, (byte)128); + + /// + /// Green color (R:0, G:128, B:0, A:255).
+ /// RGBA Hex: #008000FF. + ///
+ public static Color Green => new((byte)0, (byte)128, (byte)0); + + /// + /// GreenYellow color (R:173, G:255, B:47, A:255).
+ /// RGBA Hex: #ADFF2FFF. + ///
+ public static Color GreenYellow => new((byte)173, (byte)255, (byte)47); + + /// + /// Honeydew color (R:240, G:255, B:240, A:255).
+ /// RGBA Hex: #F0FFF0FF. + ///
+ public static Color Honeydew => new((byte)240, (byte)255, (byte)240); + + /// + /// HotPink color (R:255, G:105, B:180, A:255).
+ /// RGBA Hex: #FF69B4FF. + ///
+ public static Color HotPink => new((byte)255, (byte)105, (byte)180); + + /// + /// IndianRed color (R:205, G:92, B:92, A:255).
+ /// RGBA Hex: #CD5C5CFF. + ///
+ public static Color IndianRed => new((byte)205, (byte)92, (byte)92); + + /// + /// Indigo color (R:75, G:0, B:130, A:255).
+ /// RGBA Hex: #4B0082FF. + ///
+ public static Color Indigo => new((byte)75, (byte)0, (byte)130); + + /// + /// Ivory color (R:255, G:255, B:240, A:255).
+ /// RGBA Hex: #FFFFF0FF. + ///
+ public static Color Ivory => new((byte)255, (byte)255, (byte)240); + + /// + /// Khaki color (R:240, G:230, B:140, A:255).
+ /// RGBA Hex: #F0E68CFF. + ///
+ public static Color Khaki => new((byte)240, (byte)230, (byte)140); + + /// + /// Lavender color (R:230, G:230, B:250, A:255).
+ /// RGBA Hex: #E6E6FAFF. + ///
+ public static Color Lavender => new((byte)230, (byte)230, (byte)250); + + /// + /// LavenderBlush color (R:255, G:240, B:245, A:255).
+ /// RGBA Hex: #FFF0F5FF. + ///
+ public static Color LavenderBlush => new((byte)255, (byte)240, (byte)245); + + /// + /// LawnGreen color (R:124, G:252, B:0, A:255).
+ /// RGBA Hex: #7CFC00FF. + ///
+ public static Color LawnGreen => new((byte)124, (byte)252, (byte)0); + + /// + /// LemonChiffon color (R:255, G:250, B:205, A:255).
+ /// RGBA Hex: #FFFACDFF. + ///
+ public static Color LemonChiffon => new((byte)255, (byte)250, (byte)205); + + /// + /// LightBlue color (R:173, G:216, B:230, A:255).
+ /// RGBA Hex: #ADD8E6FF. + ///
+ public static Color LightBlue => new((byte)173, (byte)216, (byte)230); + + /// + /// LightCoral color (R:240, G:128, B:128, A:255).
+ /// RGBA Hex: #F08080FF. + ///
+ public static Color LightCoral => new((byte)240, (byte)128, (byte)128); + + /// + /// LightCyan color (R:224, G:255, B:255, A:255).
+ /// RGBA Hex: #E0FFFFFF. + ///
+ public static Color LightCyan => new((byte)224, (byte)255, (byte)255); + + /// + /// LightGoldenrodYellow color (R:250, G:250, B:210, A:255).
+ /// RGBA Hex: #FAFAD2FF. + ///
+ public static Color LightGoldenrodYellow => new((byte)250, (byte)250, (byte)210); + + /// + /// LightGray color (R:211, G:211, B:211, A:255).
+ /// RGBA Hex: #D3D3D3FF. + ///
+ public static Color LightGray => new((byte)211, (byte)211, (byte)211); + + /// + /// LightGreen color (R:144, G:238, B:144, A:255).
+ /// RGBA Hex: #90EE90FF. + ///
+ public static Color LightGreen => new((byte)144, (byte)238, (byte)144); + + /// + /// LightPink color (R:255, G:182, B:193, A:255).
+ /// RGBA Hex: #FFB6C1FF. + ///
+ public static Color LightPink => new((byte)255, (byte)182, (byte)193); + + /// + /// LightSalmon color (R:255, G:160, B:122, A:255).
+ /// RGBA Hex: #FFA07AFF. + ///
+ public static Color LightSalmon => new((byte)255, (byte)160, (byte)122); + + /// + /// LightSeaGreen color (R:32, G:178, B:170, A:255).
+ /// RGBA Hex: #20B2AAFF. + ///
+ public static Color LightSeaGreen => new((byte)32, (byte)178, (byte)170); + + /// + /// LightSkyBlue color (R:135, G:206, B:250, A:255).
+ /// RGBA Hex: #87CEFAFF. + ///
+ public static Color LightSkyBlue => new((byte)135, (byte)206, (byte)250); + + /// + /// LightSlateGray color (R:119, G:136, B:153, A:255).
+ /// RGBA Hex: #778899FF. + ///
+ public static Color LightSlateGray => new((byte)119, (byte)136, (byte)153); + + /// + /// LightSteelBlue color (R:176, G:196, B:222, A:255).
+ /// RGBA Hex: #B0C4DEFF. + ///
+ public static Color LightSteelBlue => new((byte)176, (byte)196, (byte)222); + + /// + /// LightYellow color (R:255, G:255, B:224, A:255).
+ /// RGBA Hex: #FFFFE0FF. + ///
+ public static Color LightYellow => new((byte)255, (byte)255, (byte)224); + + /// + /// Lime color (R:0, G:255, B:0, A:255).
+ /// RGBA Hex: #00FF00FF. + ///
+ public static Color Lime => new((byte)0, (byte)255, (byte)0); + + /// + /// LimeGreen color (R:50, G:205, B:50, A:255).
+ /// RGBA Hex: #32CD32FF. + ///
+ public static Color LimeGreen => new((byte)50, (byte)205, (byte)50); + + /// + /// Linen color (R:250, G:240, B:230, A:255).
+ /// RGBA Hex: #FAF0E6FF. + ///
+ public static Color Linen => new((byte)250, (byte)240, (byte)230); + + /// + /// Magenta color (R:255, G:0, B:255, A:255).
+ /// RGBA Hex: #FF00FFFF. + ///
+ public static Color Magenta => new((byte)255, (byte)0, (byte)255); + + /// + /// Maroon color (R:128, G:0, B:0, A:255).
+ /// RGBA Hex: #800000FF. + ///
+ public static Color Maroon => new((byte)128, (byte)0, (byte)0); + + /// + /// MediumAquamarine color (R:102, G:205, B:170, A:255).
+ /// RGBA Hex: #66CDAAFF. + ///
+ public static Color MediumAquamarine => new((byte)102, (byte)205, (byte)170); + + /// + /// MediumBlue color (R:0, G:0, B:205, A:255).
+ /// RGBA Hex: #0000CDFF. + ///
+ public static Color MediumBlue => new((byte)0, (byte)0, (byte)205); + + /// + /// MediumOrchid color (R:186, G:85, B:211, A:255).
+ /// RGBA Hex: #BA55D3FF. + ///
+ public static Color MediumOrchid => new((byte)186, (byte)85, (byte)211); + + /// + /// MediumPurple color (R:147, G:112, B:219, A:255).
+ /// RGBA Hex: #9370DBFF. + ///
+ public static Color MediumPurple => new((byte)147, (byte)112, (byte)219); + + /// + /// MediumSeaGreen color (R:60, G:179, B:113, A:255).
+ /// RGBA Hex: #3CB371FF. + ///
+ public static Color MediumSeaGreen => new((byte)60, (byte)179, (byte)113); + + /// + /// MediumSlateBlue color (R:123, G:104, B:238, A:255).
+ /// RGBA Hex: #7B68EEFF. + ///
+ public static Color MediumSlateBlue => new((byte)123, (byte)104, (byte)238); + + /// + /// MediumSpringGreen color (R:0, G:250, B:154, A:255).
+ /// RGBA Hex: #00FA9AFF. + ///
+ public static Color MediumSpringGreen => new((byte)0, (byte)250, (byte)154); + + /// + /// MediumTurquoise color (R:72, G:209, B:204, A:255).
+ /// RGBA Hex: #48D1CCFF. + ///
+ public static Color MediumTurquoise => new((byte)72, (byte)209, (byte)204); + + /// + /// MediumVioletRed color (R:199, G:21, B:133, A:255).
+ /// RGBA Hex: #C71585FF. + ///
+ public static Color MediumVioletRed => new((byte)199, (byte)21, (byte)133); + + /// + /// MidnightBlue color (R:25, G:25, B:112, A:255).
+ /// RGBA Hex: #191970FF. + ///
+ public static Color MidnightBlue => new((byte)25, (byte)25, (byte)112); + + /// + /// MintCream color (R:245, G:255, B:250, A:255).
+ /// RGBA Hex: #F5FFFAFF. + ///
+ public static Color MintCream => new((byte)245, (byte)255, (byte)250); + + /// + /// MistyRose color (R:255, G:228, B:225, A:255).
+ /// RGBA Hex: #FFE4E1FF. + ///
+ public static Color MistyRose => new((byte)255, (byte)228, (byte)225); + + /// + /// Moccasin color (R:255, G:228, B:181, A:255).
+ /// RGBA Hex: #FFE4B5FF. + ///
+ public static Color Moccasin => new((byte)255, (byte)228, (byte)181); + + /// + /// NavajoWhite color (R:255, G:222, B:173, A:255).
+ /// RGBA Hex: #FFDEADFF. + ///
+ public static Color NavajoWhite => new((byte)255, (byte)222, (byte)173); + + /// + /// Navy color (R:0, G:0, B:128, A:255).
+ /// RGBA Hex: #000080FF. + ///
+ public static Color Navy => new((byte)0, (byte)0, (byte)128); + + /// + /// OldLace color (R:253, G:245, B:230, A:255).
+ /// RGBA Hex: #FDF5E6FF. + ///
+ public static Color OldLace => new((byte)253, (byte)245, (byte)230); + + /// + /// Olive color (R:128, G:128, B:0, A:255).
+ /// RGBA Hex: #808000FF. + ///
+ public static Color Olive => new((byte)128, (byte)128, (byte)0); + + /// + /// OliveDrab color (R:107, G:142, B:35, A:255).
+ /// RGBA Hex: #6B8E23FF. + ///
+ public static Color OliveDrab => new((byte)107, (byte)142, (byte)35); + + /// + /// Orange color (R:255, G:165, B:0, A:255).
+ /// RGBA Hex: #FFA500FF. + ///
+ public static Color Orange => new((byte)255, (byte)165, (byte)0); + + /// + /// OrangeRed color (R:255, G:69, B:0, A:255).
+ /// RGBA Hex: #FF4500FF. + ///
+ public static Color OrangeRed => new((byte)255, (byte)69, (byte)0); + + /// + /// Orchid color (R:218, G:112, B:214, A:255).
+ /// RGBA Hex: #DA70D6FF. + ///
+ public static Color Orchid => new((byte)218, (byte)112, (byte)214); + + /// + /// PaleGoldenrod color (R:238, G:232, B:170, A:255).
+ /// RGBA Hex: #EEE8AAFF. + ///
+ public static Color PaleGoldenrod => new((byte)238, (byte)232, (byte)170); + + /// + /// PaleGreen color (R:152, G:251, B:152, A:255).
+ /// RGBA Hex: #98FB98FF. + ///
+ public static Color PaleGreen => new((byte)152, (byte)251, (byte)152); + + /// + /// PaleTurquoise color (R:175, G:238, B:238, A:255).
+ /// RGBA Hex: #AFEEEEFF. + ///
+ public static Color PaleTurquoise => new((byte)175, (byte)238, (byte)238); + + /// + /// PaleVioletRed color (R:219, G:112, B:147, A:255).
+ /// RGBA Hex: #DB7093FF. + ///
+ public static Color PaleVioletRed => new((byte)219, (byte)112, (byte)147); + + /// + /// PapayaWhip color (R:255, G:239, B:213, A:255).
+ /// RGBA Hex: #FFEFD5FF. + ///
+ public static Color PapayaWhip => new((byte)255, (byte)239, (byte)213); + + /// + /// PeachPuff color (R:255, G:218, B:185, A:255).
+ /// RGBA Hex: #FFDAB9FF. + ///
+ public static Color PeachPuff => new((byte)255, (byte)218, (byte)185); + + /// + /// Peru color (R:205, G:133, B:63, A:255).
+ /// RGBA Hex: #CD853FFF. + ///
+ public static Color Peru => new((byte)205, (byte)133, (byte)63); + + /// + /// Pink color (R:255, G:192, B:203, A:255).
+ /// RGBA Hex: #FFC0CBFF. + ///
+ public static Color Pink => new((byte)255, (byte)192, (byte)203); + + /// + /// Plum color (R:221, G:160, B:221, A:255).
+ /// RGBA Hex: #DDA0DDFF. + ///
+ public static Color Plum => new((byte)221, (byte)160, (byte)221); + + /// + /// PowderBlue color (R:176, G:224, B:230, A:255).
+ /// RGBA Hex: #B0E0E6FF. + ///
+ public static Color PowderBlue => new((byte)176, (byte)224, (byte)230); + + /// + /// Purple color (R:128, G:0, B:128, A:255).
+ /// RGBA Hex: #800080FF. + ///
+ public static Color Purple => new((byte)128, (byte)0, (byte)128); + + /// + /// Red color (R:255, G:0, B:0, A:255).
+ /// RGBA Hex: #FF0000FF. + ///
+ public static Color Red => new((byte)255, (byte)0, (byte)0); + + /// + /// RosyBrown color (R:188, G:143, B:143, A:255).
+ /// RGBA Hex: #BC8F8FFF. + ///
+ public static Color RosyBrown => new((byte)188, (byte)143, (byte)143); + + /// + /// RoyalBlue color (R:65, G:105, B:225, A:255).
+ /// RGBA Hex: #4169E1FF. + ///
+ public static Color RoyalBlue => new((byte)65, (byte)105, (byte)225); + + /// + /// SaddleBrown color (R:139, G:69, B:19, A:255).
+ /// RGBA Hex: #8B4513FF. + ///
+ public static Color SaddleBrown => new((byte)139, (byte)69, (byte)19); + + /// + /// Salmon color (R:250, G:128, B:114, A:255).
+ /// RGBA Hex: #FA8072FF. + ///
+ public static Color Salmon => new((byte)250, (byte)128, (byte)114); + + /// + /// SandyBrown color (R:244, G:164, B:96, A:255).
+ /// RGBA Hex: #F4A460FF. + ///
+ public static Color SandyBrown => new((byte)244, (byte)164, (byte)96); + + /// + /// SeaGreen color (R:46, G:139, B:87, A:255).
+ /// RGBA Hex: #2E8B57FF. + ///
+ public static Color SeaGreen => new((byte)46, (byte)139, (byte)87); + + /// + /// SeaShell color (R:255, G:245, B:238, A:255).
+ /// RGBA Hex: #FFF5EEFF. + ///
+ public static Color SeaShell => new((byte)255, (byte)245, (byte)238); + + /// + /// Sienna color (R:160, G:82, B:45, A:255).
+ /// RGBA Hex: #A0522DFF. + ///
+ public static Color Sienna => new((byte)160, (byte)82, (byte)45); + + /// + /// Silver color (R:192, G:192, B:192, A:255).
+ /// RGBA Hex: #C0C0C0FF. + ///
+ public static Color Silver => new((byte)192, (byte)192, (byte)192); + + /// + /// SkyBlue color (R:135, G:206, B:235, A:255).
+ /// RGBA Hex: #87CEEBFF. + ///
+ public static Color SkyBlue => new((byte)135, (byte)206, (byte)235); + + /// + /// SlateBlue color (R:106, G:90, B:205, A:255).
+ /// RGBA Hex: #6A5ACDFF. + ///
+ public static Color SlateBlue => new((byte)106, (byte)90, (byte)205); + + /// + /// SlateGray color (R:112, G:128, B:144, A:255).
+ /// RGBA Hex: #708090FF. + ///
+ public static Color SlateGray => new((byte)112, (byte)128, (byte)144); + + /// + /// Snow color (R:255, G:250, B:250, A:255).
+ /// RGBA Hex: #FFFAFAFF. + ///
+ public static Color Snow => new((byte)255, (byte)250, (byte)250); + + /// + /// SpringGreen color (R:0, G:255, B:127, A:255).
+ /// RGBA Hex: #00FF7FFF. + ///
+ public static Color SpringGreen => new((byte)0, (byte)255, (byte)127); + + /// + /// SteelBlue color (R:70, G:130, B:180, A:255).
+ /// RGBA Hex: #4682B4FF. + ///
+ public static Color SteelBlue => new((byte)70, (byte)130, (byte)180); + + /// + /// Tan color (R:210, G:180, B:140, A:255).
+ /// RGBA Hex: #D2B48CFF. + ///
+ public static Color Tan => new((byte)210, (byte)180, (byte)140); + + /// + /// Teal color (R:0, G:128, B:128, A:255).
+ /// RGBA Hex: #008080FF. + ///
+ public static Color Teal => new((byte)0, (byte)128, (byte)128); + + /// + /// Thistle color (R:216, G:191, B:216, A:255).
+ /// RGBA Hex: #D8BFD8FF. + ///
+ public static Color Thistle => new((byte)216, (byte)191, (byte)216); + + /// + /// Tomato color (R:255, G:99, B:71, A:255).
+ /// RGBA Hex: #FF6347FF. + ///
+ public static Color Tomato => new((byte)255, (byte)99, (byte)71); + + /// + /// Turquoise color (R:64, G:224, B:208, A:255).
+ /// RGBA Hex: #40E0D0FF. + ///
+ public static Color Turquoise => new((byte)64, (byte)224, (byte)208); + + /// + /// Violet color (R:238, G:130, B:238, A:255).
+ /// RGBA Hex: #EE82EEFF. + ///
+ public static Color Violet => new((byte)238, (byte)130, (byte)238); + + /// + /// Wheat color (R:245, G:222, B:179, A:255).
+ /// RGBA Hex: #F5DEB3FF. + ///
+ public static Color Wheat => new((byte)245, (byte)222, (byte)179); + + /// + /// White color (R:255, G:255, B:255, A:255).
+ /// RGBA Hex: #FFFFFFFF. + ///
+ public static Color White => new((byte)255, (byte)255, (byte)255); + + /// + /// WhiteSmoke color (R:245, G:245, B:245, A:255).
+ /// RGBA Hex: #F5F5F5FF. + ///
+ public static Color WhiteSmoke => new((byte)245, (byte)245, (byte)245); + + /// + /// Yellow color (R:255, G:255, B:0, A:255).
+ /// RGBA Hex: #FFFF00FF. + ///
+ public static Color Yellow => new((byte)255, (byte)255, (byte)0); + + /// + /// YellowGreen color (R:154, G:205, B:50, A:255).
+ /// RGBA Hex: #9ACD32FF. + ///
+ public static Color YellowGreen => new((byte)154, (byte)205, (byte)50); + + /// + /// RebeccaPurple color (R:102, G:51, B:153, A:255).
+ /// RGBA Hex: #663399FF. + ///
+ public static Color RebeccaPurple => new((byte)102, (byte)51, (byte)153); +} \ No newline at end of file