diff --git a/Terminal.Gui/Drawing/Color/Color.ColorExtensions.cs b/Terminal.Gui/Drawing/Color/Color.ColorExtensions.cs index 84e5f089aa..5a00884518 100644 --- a/Terminal.Gui/Drawing/Color/Color.ColorExtensions.cs +++ b/Terminal.Gui/Drawing/Color/Color.ColorExtensions.cs @@ -45,7 +45,7 @@ static ColorExtensions () { new Color(255, 0, 255), ColorName16.Magenta }, { new Color(255, 255, 0), ColorName16.Yellow }, { new Color(128, 128, 128), ColorName16.Gray }, - { new Color(118, 118, 118), ColorName16.DarkGray }, + { new Color(169, 169, 169), ColorName16.DarkGray }, { new Color(59, 120, 255), ColorName16.BrightBlue }, { new Color(22, 198, 12), ColorName16.BrightGreen }, { new Color(97, 214, 214), ColorName16.BrightCyan }, diff --git a/Terminal.Gui/Drawing/Color/Color.cs b/Terminal.Gui/Drawing/Color/Color.cs index f220de1ab5..c8dc3b8680 100644 --- a/Terminal.Gui/Drawing/Color/Color.cs +++ b/Terminal.Gui/Drawing/Color/Color.cs @@ -19,9 +19,14 @@ namespace Terminal.Gui.Drawing; /// [JsonConverter (typeof (ColorJsonConverter))] [StructLayout (LayoutKind.Explicit)] -public readonly partial record struct Color : ISpanParsable, IUtf8SpanParsable, ISpanFormattable, +public readonly partial record struct Color : ISpanParsable, IUtf8SpanParsable, ISpanFormattable, IUtf8SpanFormattable, IMinMaxValue { + /// + /// Transparent color (0 for all elements). This is interpreted as default console color. + /// + public static readonly Color Transparent = new Color (0, 0, 0, 0); + /// The value of the alpha channel component /// /// The alpha channel is not currently supported, so the value of the alpha channel bits will not affect @@ -86,14 +91,15 @@ public Color (int red = 0, int green = 0, int blue = 0, int alpha = byte.MaxValu /// /// Initializes a new instance of the class with an encoded signed 32-bit color value in - /// ARGB32 format. + /// RGB32 format. Note that is insufficient to represent alpha so assumed to be 255 unless + /// the value is /// - /// The encoded 32-bit color value (see ). + /// The encoded 32-bit color value (see ). /// /// The alpha channel is not currently supported, so the value of the alpha channel bits will not affect /// rendering. /// - public Color (int rgba) { Rgba = rgba; } + public Color (int rgb) { Rgba = rgb; } /// /// Initializes a new instance of the class with an encoded unsigned 32-bit color value in @@ -113,7 +119,7 @@ public Color (int red = 0, int green = 0, int blue = 0, int alpha = byte.MaxValu /// Initializes a new instance of the color from a value in the enum. /// The 16-color value. - public Color (in StandardColor colorName) : this ((int)colorName) { } + public Color (in StandardColor colorName) : this ((uint)colorName) { } /// /// Initializes a new instance of the color from string. See diff --git a/Terminal.Gui/Drawing/Color/StandardColor.cs b/Terminal.Gui/Drawing/Color/StandardColor.cs index 45d586a03f..210f23bd20 100644 --- a/Terminal.Gui/Drawing/Color/StandardColor.cs +++ b/Terminal.Gui/Drawing/Color/StandardColor.cs @@ -7,7 +7,7 @@ /// /// Based on https://www.w3schools.com/colors/color_tryit.asp page. /// -public enum StandardColor +public enum StandardColor : uint { /// /// Alice blue RGB(240, 248, 255). @@ -15,7 +15,7 @@ public enum StandardColor /// A very pale shade of blue, almost white. /// /// - AliceBlue = 0xF0F8FF, + AliceBlue = 0xFFF0F8FF, /// /// Antique white RGB(250, 235, 215). @@ -23,7 +23,7 @@ public enum StandardColor /// A light beige color with a hint of orange.c /// /// - AntiqueWhite = 0xFAEBD7, + AntiqueWhite = 0xFFFAEBD7, /// /// Amber Phosphor RGB(255, 191, 0). @@ -31,7 +31,7 @@ public enum StandardColor /// Matches the Amber Phosphor color used on classic terminals. /// /// - AmberPhosphor = 0xFFBF00, + AmberPhosphor = 0xFFFFBF00, /// /// Aqua RGB(0, 255, 255). @@ -39,7 +39,7 @@ public enum StandardColor /// A bright cyan color, often associated with water. /// /// - Aqua = 0x00FFFF, + Aqua = 0xFF00FFFF, /// /// Aquamarine RGB(127, 255, 212). @@ -47,7 +47,7 @@ public enum StandardColor /// A light greenish-blue color, resembling the gemstone aquamarine. /// /// - Aquamarine = 0x7FFFD4, + Aquamarine = 0xFF7FFFD4, /// /// Azure RGB(240, 255, 255). @@ -55,7 +55,7 @@ public enum StandardColor /// A pale cyan color, resembling the color of the sky on a clear day. /// /// - Azure = 0xF0FFFF, + Azure = 0xFFF0FFFF, /// /// Beige RGB(245, 245, 220). @@ -63,7 +63,7 @@ public enum StandardColor /// A pale sandy yellow color, often used in interior design. /// /// - Beige = 0xF5F5DC, + Beige = 0xFFF5F5DC, /// /// Bisque RGB(255, 228, 196). @@ -71,7 +71,7 @@ public enum StandardColor /// A pale orange color, resembling the color of bisque pottery. /// /// - Bisque = 0xFFE4C4, + Bisque = 0xFFFFE4C4, /// /// Black RGB(0, 0, 0). @@ -79,7 +79,17 @@ public enum StandardColor /// The darkest color, representing the absence of light. /// /// - Black = 0x000000, + Black = 0xFF000000, + + + /// + /// Transparent RGBA(0, 0, 0, 0). + /// + /// No color and transparent, typically means to use below color or console default + /// color (i.e. clear attribute) + /// + /// + Transparent = 0x00000000, /// /// Blanched almond RGB(255, 235, 205). @@ -87,7 +97,7 @@ public enum StandardColor /// A pale yellowish-orange color, resembling blanched almonds. /// /// - BlanchedAlmond = 0xFFEBCD, + BlanchedAlmond = 0xFFFFEBCD, /// /// Blue RGB(0, 0, 255). @@ -95,7 +105,7 @@ public enum StandardColor /// A primary color, often associated with the sky and the sea. /// /// - Blue = 0x0000FF, + Blue = 0xFF0000FF, /// /// Blue violet RGB(138, 43, 226). @@ -103,7 +113,7 @@ public enum StandardColor /// A deep purple color with a hint of blue. /// /// - BlueViolet = 0x8A2BE2, + BlueViolet = 0xFF8A2BE2, /// /// Brown RGB(165, 42, 42). @@ -111,7 +121,7 @@ public enum StandardColor /// A dark reddish-brown color, resembling the color of wood or soil. /// /// - Brown = 0xA52A2A, + Brown = 0xFFA52A2A, /// /// Burly wood RGB(222, 184, 135). @@ -119,7 +129,7 @@ public enum StandardColor /// A light brown color, resembling the color of burly wood. /// /// - BurlyWood = 0xDEB887, + BurlyWood = 0xFFDEB887, /// /// Cadet blue RGB(95, 158, 160). @@ -127,7 +137,7 @@ public enum StandardColor /// A light bluish-green color, first used as a color name in English in 1892. /// /// - CadetBlue = 0x5F9EA0, + CadetBlue = 0xFF5F9EA0, /// /// Charcoal RGB(54, 69, 79). @@ -135,7 +145,7 @@ public enum StandardColor /// A dark grayish-black color, resembling burnt wood. /// /// - Charcoal = 0x36454F, + Charcoal = 0xFF36454F, /// /// Cornflower blue RGB(100, 149, 237). @@ -143,7 +153,7 @@ public enum StandardColor /// A medium blue color, resembling the cornflower plant. /// /// - CornflowerBlue = 0x6495ED, + CornflowerBlue = 0xFF6495ED, /// /// Cornsilk RGB(255, 248, 220). @@ -151,7 +161,7 @@ public enum StandardColor /// A pale yellow color, resembling the silky threads of corn. /// /// - Cornsilk = 0xFFF8DC, + Cornsilk = 0xFFFFF8DC, /// /// Crimson RGB(220, 20, 60). @@ -159,7 +169,7 @@ public enum StandardColor /// A deep red color, resembling the color of blood. /// /// - Crimson = 0xDC143C, + Crimson = 0xFFDC143C, /// /// Cyan RGB(0, 255, 255). @@ -175,7 +185,7 @@ public enum StandardColor /// A very dark shade of blue. /// /// - DarkBlue = 0x00008B, + DarkBlue = 0xFF00008B, /// /// Dark cyan RGB(0, 139, 139). @@ -183,7 +193,7 @@ public enum StandardColor /// A dark shade of cyan. /// /// - DarkCyan = 0x008B8B, + DarkCyan = 0xFF008B8B, /// /// Dark goldenrod RGB(184, 134, 11). @@ -191,7 +201,7 @@ public enum StandardColor /// A dark yellowish-brown color. /// /// - DarkGoldenrod = 0xB8860B, + DarkGoldenrod = 0xFFB8860B, /// /// Dark gray RGB(169, 169, 169). @@ -199,7 +209,7 @@ public enum StandardColor /// A medium-dark shade of gray. /// /// - DarkGray = 0xA9A9A9, + DarkGray = 0xFFA9A9A9, /// /// Dark green RGB(0, 100, 0). @@ -207,7 +217,7 @@ public enum StandardColor /// A dark shade of green. /// /// - DarkGreen = 0x006400, + DarkGreen = 0xFF006400, /// /// Dark grey RGB(169, 169, 169). @@ -223,7 +233,7 @@ public enum StandardColor /// A dark yellowish-brown color. /// /// - DarkKhaki = 0xBDB76B, + DarkKhaki = 0xFFBDB76B, /// /// Dark magenta RGB(139, 0, 139). @@ -231,7 +241,7 @@ public enum StandardColor /// A dark shade of magenta. /// /// - DarkMagenta = 0x8B008B, + DarkMagenta = 0xFF8B008B, /// /// Dark olive green RGB(85, 107, 47). @@ -239,7 +249,7 @@ public enum StandardColor /// A dark yellowish-green color. /// /// - DarkOliveGreen = 0x556B2F, + DarkOliveGreen = 0xFF556B2F, /// /// Dark orange RGB(255, 140, 0). @@ -247,7 +257,7 @@ public enum StandardColor /// A dark shade of orange. /// /// - DarkOrange = 0xFF8C00, + DarkOrange = 0xFFFF8C00, /// /// Dark orchid RGB(153, 50, 204). @@ -255,7 +265,7 @@ public enum StandardColor /// A dark purple color with a hint of blue. /// /// - DarkOrchid = 0x9932CC, + DarkOrchid = 0xFF9932CC, /// /// Dark red RGB(139, 0, 0). @@ -263,7 +273,7 @@ public enum StandardColor /// A dark shade of red. /// /// - DarkRed = 0x8B0000, + DarkRed = 0xFF8B0000, /// /// Dark salmon RGB(233, 150, 122). @@ -271,7 +281,7 @@ public enum StandardColor /// A dark pinkish-orange color. /// /// - DarkSalmon = 0xE9967A, + DarkSalmon = 0xFFE9967A, /// /// Dark sea green RGB(143, 188, 143). @@ -279,7 +289,7 @@ public enum StandardColor /// A dark shade of sea green. /// /// - DarkSeaGreen = 0x8FBC8F, + DarkSeaGreen = 0xFF8FBC8F, /// /// Dark slate blue RGB(72, 61, 139). @@ -287,7 +297,7 @@ public enum StandardColor /// A dark blue color with a hint of gray. /// /// - DarkSlateBlue = 0x483D8B, + DarkSlateBlue = 0xFF483D8B, /// /// Dark slate gray RGB(47, 79, 79). @@ -295,7 +305,7 @@ public enum StandardColor /// A very dark gray color with a hint of green. /// /// - DarkSlateGray = 0x2F4F4F, + DarkSlateGray = 0xFF2F4F4F, /// /// Dark slate grey RGB(47, 79, 79). @@ -311,7 +321,7 @@ public enum StandardColor /// A dark shade of turquoise. /// /// - DarkTurquoise = 0x00CED1, + DarkTurquoise = 0xFF00CED1, /// /// Dark violet RGB(148, 0, 211). @@ -319,7 +329,7 @@ public enum StandardColor /// A dark shade of violet. /// /// - DarkViolet = 0x9400D3, + DarkViolet = 0xFF9400D3, /// /// Deep pink RGB(255, 20, 147). @@ -327,7 +337,7 @@ public enum StandardColor /// A bright and intense pink color. /// /// - DeepPink = 0xFF1493, + DeepPink = 0xFFFF1493, /// /// Deep sky blue RGB(0, 191, 255). @@ -335,7 +345,7 @@ public enum StandardColor /// A bright and intense sky blue color. /// /// - DeepSkyBlue = 0x00BFFF, + DeepSkyBlue = 0xFF00BFFF, /// /// Dim gray RGB(105, 105, 105). @@ -343,7 +353,7 @@ public enum StandardColor /// A medium-dark shade of gray. /// /// - DimGray = 0x696969, + DimGray = 0xFF696969, /// /// Dim grey RGB(105, 105, 105). @@ -359,7 +369,7 @@ public enum StandardColor /// A bright and vibrant blue color. /// /// - DodgerBlue = 0x1E90FF, + DodgerBlue = 0xFF1E90FF, /// /// Ebony RGB(85, 93, 80). @@ -367,7 +377,7 @@ public enum StandardColor /// A very dark gray color with a slight greenish tint. /// /// - Ebony = 0x555D50, + Ebony = 0xFF555D50, /// /// Fire brick RGB(178, 34, 34). @@ -375,7 +385,7 @@ public enum StandardColor /// A dark reddish-brown color, resembling bricks. /// /// - FireBrick = 0xB22222, + FireBrick = 0xFFB22222, /// /// Floral white RGB(255, 250, 240). @@ -383,7 +393,7 @@ public enum StandardColor /// A very pale shade of white with a hint of orange. /// /// - FloralWhite = 0xFFFAF0, + FloralWhite = 0xFFFFFAF0, /// @@ -400,7 +410,7 @@ public enum StandardColor /// A dark green color, resembling the color of a forest. /// /// - ForestGreen = 0x228B22, + ForestGreen = 0xFF228B22, /// /// Fuchsia RGB(255, 0, 255). @@ -408,7 +418,7 @@ public enum StandardColor /// A bright and vibrant magenta color. /// /// - Fuchsia = 0xFF00FF, + Fuchsia = 0xFFFF00FF, /// /// Gainsboro RGB(220, 220, 220). @@ -416,7 +426,7 @@ public enum StandardColor /// A very light gray color. /// /// - Gainsboro = 0xDCDCDC, + Gainsboro = 0xFFDCDCDC, /// /// Ghost white RGB(248, 248, 255). @@ -424,7 +434,7 @@ public enum StandardColor /// A very pale shade of white with a hint of blue. /// /// - GhostWhite = 0xF8F8FF, + GhostWhite = 0xFFF8F8FF, /// /// Gold RGB(255, 215, 0). @@ -432,7 +442,7 @@ public enum StandardColor /// A bright yellow color, resembling gold. /// /// - Gold = 0xFFD700, + Gold = 0xFFFFD700, /// /// Goldenrod RGB(218, 165, 32). @@ -440,7 +450,7 @@ public enum StandardColor /// A dark yellow color with a hint of brown. /// /// - Goldenrod = 0xDAA520, + Goldenrod = 0xFFDAA520, /// /// Gray RGB(128, 128, 128). @@ -448,7 +458,7 @@ public enum StandardColor /// A medium shade of gray. /// /// - Gray = 0x808080, + Gray = 0xFF808080, /// /// Green RGB(0, 128, 0). @@ -456,7 +466,7 @@ public enum StandardColor /// A medium shade of green. /// /// - Green = 0x008000, + Green = 0xFF008000, /// /// Green Phosphor RGB(0, 255, 102). @@ -464,7 +474,7 @@ public enum StandardColor /// Matches the Green Phosphor color used on classic terminals. /// /// - GreenPhosphor = 0x00FF66, + GreenPhosphor = 0xFF00FF66, /// /// Green yellow RGB(173, 255, 47). @@ -472,7 +482,7 @@ public enum StandardColor /// A bright yellowish-green color. /// /// - GreenYellow = 0xADFF2F, + GreenYellow = 0xFFADFF2F, /// /// Grey RGB(128, 128, 128). @@ -496,7 +506,7 @@ public enum StandardColor /// A very pale greenish-white color. /// /// - HoneyDew = 0xF0FFF0, + HoneyDew = 0xFFF0FFF0, /// /// Hot pink RGB(255, 105, 180). @@ -504,7 +514,7 @@ public enum StandardColor /// A bright and vibrant pink color. /// /// - HotPink = 0xFF69B4, + HotPink = 0xFFFF69B4, /// /// Indian red RGB(205, 92, 92). @@ -512,7 +522,7 @@ public enum StandardColor /// A dark reddish-brown color. /// /// - IndianRed = 0xCD5C5C, + IndianRed = 0xFFCD5C5C, /// /// Indigo RGB(75, 0, 130). @@ -520,7 +530,7 @@ public enum StandardColor /// A dark blue-purple color. /// /// - Indigo = 0x4B0082, + Indigo = 0xFF4B0082, /// /// Ivory RGB(255, 255, 240). @@ -528,7 +538,7 @@ public enum StandardColor /// A very pale yellowish-white color. /// /// - Ivory = 0xFFFFF0, + Ivory = 0xFFFFFFF0, /// /// Jet RGB(52, 52, 52). @@ -536,7 +546,7 @@ public enum StandardColor /// A very dark gray, often used as a near-black. /// /// - Jet = 0x343434, + Jet = 0xFF343434, /// /// Khaki RGB(240, 230, 140). @@ -544,7 +554,7 @@ public enum StandardColor /// A pale yellowish-brown color. /// /// - Khaki = 0xF0E68C, + Khaki = 0xFFF0E68C, /// /// Lavender RGB(230, 230, 250). @@ -552,7 +562,7 @@ public enum StandardColor /// A pale purple color, resembling the lavender flower. /// /// - Lavender = 0xE6E6FA, + Lavender = 0xFFE6E6FA, /// /// Lavender blush RGB(255, 240, 245). @@ -560,7 +570,7 @@ public enum StandardColor /// A very pale pinkish-white color. /// /// - LavenderBlush = 0xFFF0F5, + LavenderBlush = 0xFFFFF0F5, /// /// Lawn green RGB(124, 252, 0). @@ -568,7 +578,7 @@ public enum StandardColor /// A bright green color, resembling freshly cut grass. /// /// - LawnGreen = 0x7CFC00, + LawnGreen = 0xFF7CFC00, /// /// Lemon chiffon RGB(255, 250, 205). @@ -576,7 +586,7 @@ public enum StandardColor /// A pale yellow color, resembling lemon chiffon cake. /// /// - LemonChiffon = 0xFFFACD, + LemonChiffon = 0xFFFFFACD, /// /// Light blue RGB(173, 216, 230). @@ -584,7 +594,7 @@ public enum StandardColor /// A pale shade of blue. /// /// - LightBlue = 0xADD8E6, + LightBlue = 0xFFADD8E6, /// /// Light coral RGB(240, 128, 128). @@ -592,7 +602,7 @@ public enum StandardColor /// A pale pinkish-orange color. /// /// - LightCoral = 0xF08080, + LightCoral = 0xFFF08080, /// /// Light cyan RGB(224, 255, 255). @@ -600,7 +610,7 @@ public enum StandardColor /// A pale shade of cyan. /// /// - LightCyan = 0xE0FFFF, + LightCyan = 0xFFE0FFFF, /// /// Light goldenrod yellow RGB(250, 250, 210). @@ -608,7 +618,7 @@ public enum StandardColor /// A pale yellow color with a hint of gold. /// /// - LightGoldenrodYellow = 0xFAFAD2, + LightGoldenrodYellow = 0xFFFAFAD2, /// /// Light gray RGB(211, 211, 211). @@ -616,7 +626,7 @@ public enum StandardColor /// A pale shade of gray. /// /// - LightGray = 0xD3D3D3, + LightGray = 0xFFD3D3D3, /// /// Light green RGB(144, 238, 144). @@ -624,7 +634,7 @@ public enum StandardColor /// A pale shade of green. /// /// - LightGreen = 0x90EE90, + LightGreen = 0xFF90EE90, /// /// Light grey RGB(211, 211, 211). @@ -640,7 +650,7 @@ public enum StandardColor /// A pale shade of pink. /// /// - LightPink = 0xFFB6C1, + LightPink = 0xFFFFB6C1, /// /// Light salmon RGB(255, 160, 122). @@ -648,7 +658,7 @@ public enum StandardColor /// A pale pinkish-orange color. /// /// - LightSalmon = 0xFFA07A, + LightSalmon = 0xFFFFA07A, /// /// Light sea green RGB(32, 178, 170). @@ -656,7 +666,7 @@ public enum StandardColor /// A pale shade of sea green. /// /// - LightSeaGreen = 0x20B2AA, + LightSeaGreen = 0xFF20B2AA, /// /// Light sky blue RGB(135, 206, 250). @@ -664,7 +674,7 @@ public enum StandardColor /// A pale shade of sky blue. /// /// - LightSkyBlue = 0x87CEFA, + LightSkyBlue = 0xFF87CEFA, /// /// Light slate gray RGB(119, 136, 153). @@ -672,7 +682,7 @@ public enum StandardColor /// A pale shade of slate gray. /// /// - LightSlateGray = 0x778899, + LightSlateGray = 0xFF778899, /// /// Light slate grey RGB(119, 136, 153). @@ -688,7 +698,7 @@ public enum StandardColor /// A pale shade of steel blue. /// /// - LightSteelBlue = 0xB0C4DE, + LightSteelBlue = 0xFFB0C4DE, /// /// Light yellow RGB(255, 255, 224). @@ -696,7 +706,7 @@ public enum StandardColor /// A pale shade of yellow. /// /// - LightYellow = 0xFFFFE0, + LightYellow = 0xFFFFFFE0, /// /// Lime RGB(0, 255, 0). @@ -704,7 +714,7 @@ public enum StandardColor /// A bright green color. /// /// - Lime = 0x00FF00, + Lime = 0xFF00FF00, /// /// Lime green RGB(50, 205, 50). @@ -712,7 +722,7 @@ public enum StandardColor /// A bright green color with a hint of yellow. /// /// - LimeGreen = 0x32CD32, + LimeGreen = 0xFF32CD32, /// /// Linen RGB(250, 240, 230). @@ -720,7 +730,7 @@ public enum StandardColor /// A pale beige color, resembling linen fabric. /// /// - Linen = 0xFAF0E6, + Linen = 0xFFFAF0E6, /// /// Magenta RGB(255, 0, 255). @@ -728,7 +738,7 @@ public enum StandardColor /// A bright and vibrant pinkish-purple color. /// /// - Magenta = 0xFF00FF, + Magenta = 0xFFFF00FF, /// /// Maroon RGB(128, 0, 0). @@ -736,7 +746,7 @@ public enum StandardColor /// A dark reddish-brown color. /// /// - Maroon = 0x800000, + Maroon = 0xFF800000, /// /// Medium aqua marine RGB(102, 205, 170). @@ -744,7 +754,7 @@ public enum StandardColor /// A medium shade of greenish-blue. /// /// - MediumAquaMarine = 0x66CDAA, + MediumAquaMarine = 0xFF66CDAA, /// /// Medium blue RGB(0, 0, 205). @@ -752,7 +762,7 @@ public enum StandardColor /// A medium shade of blue. /// /// - MediumBlue = 0x0000CD, + MediumBlue = 0xFF0000CD, /// /// Medium orchid RGB(186, 85, 211). @@ -760,7 +770,7 @@ public enum StandardColor /// A medium shade of purple with a hint of pink. /// /// - MediumOrchid = 0xBA55D3, + MediumOrchid = 0xFFBA55D3, /// /// Medium purple RGB(147, 112, 219). @@ -768,7 +778,7 @@ public enum StandardColor /// A medium shade of purple. /// /// - MediumPurple = 0x9370DB, + MediumPurple = 0xFF9370DB, /// /// Medium sea green RGB(60, 179, 113). @@ -776,7 +786,7 @@ public enum StandardColor /// A medium shade of sea green. /// /// - MediumSeaGreen = 0x3CB371, + MediumSeaGreen = 0xFF3CB371, /// /// Medium slate blue RGB(123, 104, 238). @@ -784,7 +794,7 @@ public enum StandardColor /// A medium shade of slate blue. /// /// - MediumSlateBlue = 0x7B68EE, + MediumSlateBlue = 0xFF7B68EE, /// /// Medium spring green RGB(0, 250, 154). @@ -792,7 +802,7 @@ public enum StandardColor /// A medium shade of spring green. /// /// - MediumSpringGreen = 0x00FA9A, + MediumSpringGreen = 0xFF00FA9A, /// /// Medium turquoise RGB(72, 209, 204). @@ -800,7 +810,7 @@ public enum StandardColor /// A medium shade of turquoise. /// /// - MediumTurquoise = 0x48D1CC, + MediumTurquoise = 0xFF48D1CC, /// /// Medium violet red RGB(199, 21, 133). @@ -808,7 +818,7 @@ public enum StandardColor /// A medium shade of violet-red. /// /// - MediumVioletRed = 0xC71585, + MediumVioletRed = 0xFFC71585, /// /// Midnight blue RGB(25, 25, 112). @@ -816,7 +826,7 @@ public enum StandardColor /// A very dark shade of blue. /// /// - MidnightBlue = 0x191970, + MidnightBlue = 0xFF191970, /// /// Mint cream RGB(245, 255, 250). @@ -824,7 +834,7 @@ public enum StandardColor /// A very pale greenish-white color. /// /// - MintCream = 0xF5FFFA, + MintCream = 0xFFF5FFFA, /// /// Misty rose RGB(255, 228, 225). @@ -832,7 +842,7 @@ public enum StandardColor /// A very pale pinkish-white color. /// /// - MistyRose = 0xFFE4E1, + MistyRose = 0xFFFFE4E1, /// /// Moccasin RGB(255, 228, 181). @@ -840,7 +850,7 @@ public enum StandardColor /// A pale orange color, resembling moccasin leather. /// /// - Moccasin = 0xFFE4B5, + Moccasin = 0xFFFFE4B5, /// /// Navajo white RGB(255, 222, 173). @@ -848,7 +858,7 @@ public enum StandardColor /// A pale orange color, resembling Navajo pottery. /// /// - NavajoWhite = 0xFFDEAD, + NavajoWhite = 0xFFFFDEAD, /// /// Navy RGB(0, 0, 128). @@ -856,7 +866,7 @@ public enum StandardColor /// A very dark shade of blue. /// /// - Navy = 0x000080, + Navy = 0xFF000080, /// /// Old lace RGB(253, 245, 230). @@ -864,7 +874,7 @@ public enum StandardColor /// A very pale beige color, resembling old lace fabric. /// /// - OldLace = 0xFDF5E6, + OldLace = 0xFFFDF5E6, /// /// Olive RGB(128, 128, 0). @@ -872,7 +882,7 @@ public enum StandardColor /// A dark yellowish-green color. /// /// - Olive = 0x808000, + Olive = 0xFF808000, /// /// Olive drab RGB(107, 142, 35). @@ -880,7 +890,7 @@ public enum StandardColor /// A dark yellowish-green color, resembling olive drab fabric. /// /// - OliveDrab = 0x6B8E23, + OliveDrab = 0xFF6B8E23, /// /// Onyx RGB(53, 56, 57). @@ -888,7 +898,7 @@ public enum StandardColor /// A dark grayish-black color, resembling the onyx gemstone. /// /// - Onyx = 0x353839, + Onyx = 0xFF353839, /// /// Orange RGB(255, 165, 0). @@ -896,7 +906,7 @@ public enum StandardColor /// A bright orange color. /// /// - Orange = 0xFFA500, + Orange = 0xFFFFA500, /// /// Orange red RGB(255, 69, 0). @@ -904,7 +914,7 @@ public enum StandardColor /// A bright reddish-orange color. /// /// - OrangeRed = 0xFF4500, + OrangeRed = 0xFFFF4500, /// /// Orchid RGB(218, 112, 214). @@ -912,7 +922,7 @@ public enum StandardColor /// A pale purple color with a hint of pink. /// /// - Orchid = 0xDA70D6, + Orchid = 0xFFDA70D6, /// /// Outer space RGB(65, 74, 76). @@ -920,7 +930,7 @@ public enum StandardColor /// A dark gray color with a bluish tint, resembling the color of outer space. /// /// - OuterSpace = 0x414A4C, + OuterSpace = 0xFF414A4C, /// /// Pale goldenrod RGB(238, 232, 170). @@ -928,7 +938,7 @@ public enum StandardColor /// A pale yellow color with a hint of gold. /// /// - PaleGoldenrod = 0xEEE8AA, + PaleGoldenrod = 0xFFEEE8AA, /// /// Pale green RGB(152, 251, 152). @@ -936,7 +946,7 @@ public enum StandardColor /// A pale shade of green. /// /// - PaleGreen = 0x98FB98, + PaleGreen = 0xFF98FB98, /// /// Pale turquoise RGB(175, 238, 238). @@ -944,7 +954,7 @@ public enum StandardColor /// A pale shade of turquoise. /// /// - PaleTurquoise = 0xAFEEEE, + PaleTurquoise = 0xFFAFEEEE, /// /// Pale violet red RGB(219, 112, 147). @@ -952,7 +962,7 @@ public enum StandardColor /// A pale shade of violet-red. /// /// - PaleVioletRed = 0xDB7093, + PaleVioletRed = 0xFFDB7093, /// /// Papaya whip RGB(255, 239, 213). @@ -960,7 +970,7 @@ public enum StandardColor /// A pale orange color, resembling papaya fruit. /// /// - PapayaWhip = 0xFFEFD5, + PapayaWhip = 0xFFFFEFD5, /// /// Peach puff RGB(255, 218, 185). @@ -968,7 +978,7 @@ public enum StandardColor /// A pale orange color, resembling peach skin. /// /// - PeachPuff = 0xFFDAB9, + PeachPuff = 0xFFFFDAB9, /// /// Peru RGB(205, 133, 63). @@ -976,7 +986,7 @@ public enum StandardColor /// A dark orange-brown color. /// /// - Peru = 0xCD853F, + Peru = 0xFFCD853F, /// /// Pink RGB(255, 192, 203). @@ -984,7 +994,7 @@ public enum StandardColor /// A pale shade of pink. /// /// - Pink = 0xFFC0CB, + Pink = 0xFFFFC0CB, /// /// Plum RGB(221, 160, 221). @@ -992,7 +1002,7 @@ public enum StandardColor /// A pale purple color. /// /// - Plum = 0xDDA0DD, + Plum = 0xFFDDA0DD, /// /// Powder blue RGB(176, 224, 230). @@ -1000,7 +1010,7 @@ public enum StandardColor /// A pale shade of blue. /// /// - PowderBlue = 0xB0E0E6, + PowderBlue = 0xFFB0E0E6, /// /// Purple RGB(128, 0, 128). @@ -1008,7 +1018,7 @@ public enum StandardColor /// A dark shade of purple. /// /// - Purple = 0x800080, + Purple = 0xFF800080, /// /// Raisin black RGB(36, 33, 36). @@ -1016,7 +1026,7 @@ public enum StandardColor /// A very dark grayish-black color, resembling the color of raisins. /// /// - RaisinBlack = 0x242124, + RaisinBlack = 0xFF242124, /// /// Rebecca purple RGB(102, 51, 153). @@ -1024,7 +1034,7 @@ public enum StandardColor /// A medium-dark shade of purple. /// /// - RebeccaPurple = 0x663399, + RebeccaPurple = 0xFF663399, /// /// Red RGB(255, 0, 0). @@ -1032,7 +1042,7 @@ public enum StandardColor /// A bright red color. /// /// - Red = 0xFF0000, + Red = 0xFFFF0000, /// /// Rosy brown RGB(188, 143, 143). @@ -1040,7 +1050,7 @@ public enum StandardColor /// A pale reddish-brown color. /// /// - RosyBrown = 0xBC8F8F, + RosyBrown = 0xFFBC8F8F, /// /// Royal blue RGB(65, 105, 225). @@ -1048,7 +1058,7 @@ public enum StandardColor /// A medium shade of blue. /// /// - RoyalBlue = 0x4169E1, + RoyalBlue = 0xFF4169E1, /// /// Saddle brown RGB(139, 69, 19). @@ -1056,7 +1066,7 @@ public enum StandardColor /// A dark reddish-brown color. /// /// - SaddleBrown = 0x8B4513, + SaddleBrown = 0xFF8B4513, /// /// Salmon RGB(250, 128, 114). @@ -1064,7 +1074,7 @@ public enum StandardColor /// A pale pinkish-orange color. /// /// - Salmon = 0xFA8072, + Salmon = 0xFFFA8072, /// /// Sandy brown RGB(244, 164, 96). @@ -1072,7 +1082,7 @@ public enum StandardColor /// A pale orange-brown color. /// /// - SandyBrown = 0xF4A460, + SandyBrown = 0xFFF4A460, /// /// Sea green RGB(46, 139, 87). @@ -1080,7 +1090,7 @@ public enum StandardColor /// A medium-dark shade of green. /// /// - SeaGreen = 0x2E8B57, + SeaGreen = 0xFF2E8B57, /// /// Sea shell RGB(255, 245, 238). @@ -1088,7 +1098,7 @@ public enum StandardColor /// A very pale orange color, resembling seashells. /// /// - SeaShell = 0xFFF5EE, + SeaShell = 0xFFFFF5EE, /// /// Sienna RGB(160, 82, 45). @@ -1096,7 +1106,7 @@ public enum StandardColor /// A dark orange-brown color. /// /// - Sienna = 0xA0522D, + Sienna = 0xFFA0522D, /// /// Silver RGB(192, 192, 192). @@ -1104,7 +1114,7 @@ public enum StandardColor /// A pale gray color, resembling silver. /// /// - Silver = 0xC0C0C0, + Silver = 0xFFC0C0C0, /// /// Sky blue RGB(135, 206, 235). @@ -1112,7 +1122,7 @@ public enum StandardColor /// A pale shade of blue, resembling the sky. /// /// - SkyBlue = 0x87CEEB, + SkyBlue = 0xFF87CEEB, /// /// Slate blue RGB(106, 90, 205). @@ -1120,7 +1130,7 @@ public enum StandardColor /// A medium-dark shade of blue. /// /// - SlateBlue = 0x6A5ACD, + SlateBlue = 0xFF6A5ACD, /// /// Slate gray RGB(112, 128, 144). @@ -1128,7 +1138,7 @@ public enum StandardColor /// A medium-dark shade of gray. /// /// - SlateGray = 0x708090, + SlateGray = 0xFF708090, /// /// Slate grey RGB(112, 128, 144). @@ -1144,7 +1154,7 @@ public enum StandardColor /// A very pale shade of white with a hint of pink. /// /// - Snow = 0xFFFAFA, + Snow = 0xFFFFFAFA, /// /// Spring green RGB(0, 255, 127). @@ -1152,7 +1162,7 @@ public enum StandardColor /// A bright green color with a hint of yellow. /// /// - SpringGreen = 0x00FF7F, + SpringGreen = 0xFF00FF7F, /// /// Steel blue RGB(70, 130, 180). @@ -1160,7 +1170,7 @@ public enum StandardColor /// A medium-dark shade of blue. /// /// - SteelBlue = 0x4682B4, + SteelBlue = 0xFF4682B4, /// /// Tan RGB(210, 180, 140). @@ -1168,7 +1178,7 @@ public enum StandardColor /// A pale orange-brown color. /// /// - Tan = 0xD2B48C, + Tan = 0xFFD2B48C, /// /// Teal RGB(0, 128, 128). @@ -1176,7 +1186,7 @@ public enum StandardColor /// A medium-dark shade of greenish-blue. /// /// - Teal = 0x008080, + Teal = 0xFF008080, /// /// Thistle RGB(216, 191, 216). @@ -1184,7 +1194,7 @@ public enum StandardColor /// A pale purple color. /// /// - Thistle = 0xD8BFD8, + Thistle = 0xFFD8BFD8, /// /// Tomato RGB(255, 99, 71). @@ -1192,7 +1202,7 @@ public enum StandardColor /// A bright reddish-orange color, resembling tomatoes. /// /// - Tomato = 0xFF6347, + Tomato = 0xFFFF6347, /// /// Turquoise RGB(64, 224, 208). @@ -1200,7 +1210,7 @@ public enum StandardColor /// A bright greenish-blue color. /// /// - Turquoise = 0x40E0D0, + Turquoise = 0xFF40E0D0, /// /// Violet RGB(238, 130, 238). @@ -1208,7 +1218,7 @@ public enum StandardColor /// A bright purple color. /// /// - Violet = 0xEE82EE, + Violet = 0xFFEE82EE, /// /// Wheat RGB(245, 222, 179). @@ -1216,7 +1226,7 @@ public enum StandardColor /// A pale yellowish-brown color, resembling wheat. /// /// - Wheat = 0xF5DEB3, + Wheat = 0xFFF5DEB3, /// /// White RGB(255, 255, 255). @@ -1224,7 +1234,7 @@ public enum StandardColor /// The lightest color, representing the presence of all colors of light. /// /// - White = 0xFFFFFF, + White = 0xFFFFFFFF, /// /// White smoke RGB(245, 245, 245). @@ -1232,7 +1242,7 @@ public enum StandardColor /// A very pale shade of gray, resembling smoke. /// /// - WhiteSmoke = 0xF5F5F5, + WhiteSmoke = 0xFFF5F5F5, /// /// Yellow RGB(255, 255, 0). @@ -1240,7 +1250,7 @@ public enum StandardColor /// A bright yellow color. /// /// - Yellow = 0xFFFF00, + Yellow = 0xFFFFFF00, /// /// Yellow green RGB(154, 205, 50). @@ -1248,5 +1258,5 @@ public enum StandardColor /// A bright yellowish-green color. /// /// - YellowGreen = 0x9ACD32 + YellowGreen = 0xFF9ACD32 } diff --git a/Terminal.Gui/Drawing/Color/StandardColors.cs b/Terminal.Gui/Drawing/Color/StandardColors.cs index 05adfdb304..8b533a7660 100644 --- a/Terminal.Gui/Drawing/Color/StandardColors.cs +++ b/Terminal.Gui/Drawing/Color/StandardColors.cs @@ -80,12 +80,6 @@ public static bool TryNameColor (Color color, [NotNullWhen (true)] out string? n internal static uint GetArgb (StandardColor standardColor) { - const int ALPHA_SHIFT = 24; - const uint ALPHA_MASK = 0xFFU << ALPHA_SHIFT; - - int rgb = (int)standardColor; - - uint argb = (uint)rgb | ALPHA_MASK; - return argb; + return (uint)standardColor; } } diff --git a/Terminal.Gui/Drawing/Scheme.cs b/Terminal.Gui/Drawing/Scheme.cs index ff0933aac7..4e363870b4 100644 --- a/Terminal.Gui/Drawing/Scheme.cs +++ b/Terminal.Gui/Drawing/Scheme.cs @@ -171,7 +171,7 @@ Scheme CreateBase () { return new () { - Normal = new (StandardColor.LightBlue, StandardColor.RaisinBlack) + Normal = new (StandardColor.LightBlue, StandardColor.Transparent) }; } @@ -179,7 +179,7 @@ Scheme CreateError () { return new () { - Normal = new (StandardColor.IndianRed, StandardColor.RaisinBlack) + Normal = new (StandardColor.IndianRed, StandardColor.Transparent) }; } @@ -306,7 +306,7 @@ private Attribute GetAttributeForRoleCore (VisualRole role, HashSet VisualRole.Focus => GetAttributeForRoleCore (VisualRole.Normal, stack) with { - Foreground = GetAttributeForRoleCore (VisualRole.Normal, stack).Background, + Foreground = SwapTransparentForBlack(GetAttributeForRoleCore (VisualRole.Normal, stack).Background), Background = GetAttributeForRoleCore (VisualRole.Normal, stack).Foreground }, @@ -371,6 +371,11 @@ private Attribute GetAttributeForRoleCore (VisualRole role, HashSet return result; } + private Color SwapTransparentForBlack (Color c) + { + return c == Color.Transparent ? Color.Black : c; + } + /// /// Gets the associated with a specified string. /// diff --git a/Terminal.Gui/Drivers/EscSeqUtils/EscSeqUtils.cs b/Terminal.Gui/Drivers/EscSeqUtils/EscSeqUtils.cs index 0a99fa8b5d..de467daabd 100644 --- a/Terminal.Gui/Drivers/EscSeqUtils/EscSeqUtils.cs +++ b/Terminal.Gui/Drivers/EscSeqUtils/EscSeqUtils.cs @@ -1820,6 +1820,24 @@ public static void CSI_AppendBackgroundColorRGB (StringBuilder builder, int r, i builder.Append ($"{CSI}48;2;{r};{g};{b}m"); } + /// + /// Clears the foreground color such that it uses the terminal default + /// + /// + public static void CSI_ResetForegroundColor (StringBuilder builder) + { + builder.Append ($"{CSI}39m"); + } + + /// + /// Clears the background color such that is uses the terminal default (including any transparency) + /// + /// + public static void CSI_ResetBackgroundColor (StringBuilder builder) + { + builder.Append ($"{CSI}49m"); + } + #endregion diff --git a/Terminal.Gui/Drivers/V2/NetOutput.cs b/Terminal.Gui/Drivers/V2/NetOutput.cs index 17956a3dfa..b23b5deb47 100644 --- a/Terminal.Gui/Drivers/V2/NetOutput.cs +++ b/Terminal.Gui/Drivers/V2/NetOutput.cs @@ -47,26 +47,6 @@ public Size GetWindowSize () private Point? _lastCursorPosition; - /// - protected override void AppendOrWriteAttribute (StringBuilder output, Attribute attr, TextStyle redrawTextStyle) - { - EscSeqUtils.CSI_AppendForegroundColorRGB ( - output, - attr.Foreground.R, - attr.Foreground.G, - attr.Foreground.B - ); - - EscSeqUtils.CSI_AppendBackgroundColorRGB ( - output, - attr.Background.R, - attr.Background.G, - attr.Background.B - ); - - EscSeqUtils.CSI_AppendTextStyleChange (output, redrawTextStyle, attr.Style); - } - /// protected override void Write (StringBuilder output) { Console.Out.Write (output); } diff --git a/Terminal.Gui/Drivers/V2/OutputBase.cs b/Terminal.Gui/Drivers/V2/OutputBase.cs index b28551e4bd..ada5e700ba 100644 --- a/Terminal.Gui/Drivers/V2/OutputBase.cs +++ b/Terminal.Gui/Drivers/V2/OutputBase.cs @@ -144,7 +144,44 @@ public virtual void Write (IOutputBuffer buffer) _cachedCursorVisibility = savedVisibility; } - protected abstract void AppendOrWriteAttribute (StringBuilder output, Attribute attr, TextStyle redrawTextStyle); + /// + /// Change the color being used to render text. + /// + /// The output stream + /// The foreground and background color to switch to + /// Style + protected virtual void AppendOrWriteAttribute (StringBuilder output, Attribute attr, TextStyle redrawTextStyle) + { + if (attr.Foreground == Color.Transparent) + { + EscSeqUtils.CSI_ResetForegroundColor (output); + } + else + { + EscSeqUtils.CSI_AppendForegroundColorRGB ( + output, + attr.Foreground.R, + attr.Foreground.G, + attr.Foreground.B + ); + } + + if (attr.Background == Color.Transparent) + { + EscSeqUtils.CSI_ResetBackgroundColor (output); + } + else + { + EscSeqUtils.CSI_AppendBackgroundColorRGB ( + output, + attr.Background.R, + attr.Background.G, + attr.Background.B + ); + } + + EscSeqUtils.CSI_AppendTextStyleChange (output, redrawTextStyle, attr.Style); + } private void WriteToConsole (StringBuilder output, ref int lastCol, int row, ref int outputWidth) { diff --git a/Terminal.Gui/Drivers/V2/WindowsOutput.cs b/Terminal.Gui/Drivers/V2/WindowsOutput.cs index 5152d3a238..cd66c81dc7 100644 --- a/Terminal.Gui/Drivers/V2/WindowsOutput.cs +++ b/Terminal.Gui/Drivers/V2/WindowsOutput.cs @@ -318,9 +318,7 @@ protected override void AppendOrWriteAttribute (StringBuilder output, Attribute { if (_isVirtualTerminal) { - output.Append (EscSeqUtils.CSI_SetForegroundColor (attr.Foreground.GetAnsiColorCode ())); - output.Append (EscSeqUtils.CSI_SetBackgroundColor (attr.Background.GetAnsiColorCode ())); - EscSeqUtils.CSI_AppendTextStyleChange (output, redrawTextStyle, attr.Style); + base.AppendOrWriteAttribute (output,attr,redrawTextStyle); } else { @@ -330,9 +328,7 @@ protected override void AppendOrWriteAttribute (StringBuilder output, Attribute } else { - EscSeqUtils.CSI_AppendForegroundColorRGB (output, attr.Foreground.R, attr.Foreground.G, attr.Foreground.B); - EscSeqUtils.CSI_AppendBackgroundColorRGB (output, attr.Background.R, attr.Background.G, attr.Background.B); - EscSeqUtils.CSI_AppendTextStyleChange (output, redrawTextStyle, attr.Style); + base.AppendOrWriteAttribute (output, attr, redrawTextStyle); } } diff --git a/Tests/UnitTestsParallelizable/Drawing/Color/AnsiColorNameResolverTests.cs b/Tests/UnitTestsParallelizable/Drawing/Color/AnsiColorNameResolverTests.cs index fb8b7b661b..a6956fb237 100644 --- a/Tests/UnitTestsParallelizable/Drawing/Color/AnsiColorNameResolverTests.cs +++ b/Tests/UnitTestsParallelizable/Drawing/Color/AnsiColorNameResolverTests.cs @@ -70,7 +70,7 @@ public void GetNames_Returns16ColorNames () [InlineData (231, 72, 86, nameof (ColorName16.BrightRed))] [InlineData (249, 241, 165, nameof (ColorName16.BrightYellow))] [InlineData (0, 255, 255, nameof (ColorName16.Cyan))] - [InlineData (118, 118, 118, nameof (ColorName16.DarkGray))] + [InlineData (169, 169, 169, nameof (ColorName16.DarkGray))] [InlineData (128, 128, 128, nameof (ColorName16.Gray))] [InlineData (0, 128, 0, nameof (ColorName16.Green))] [InlineData (255, 0, 255, nameof (ColorName16.Magenta))] @@ -108,7 +108,7 @@ public void TryNameColor_NoMatchFails () [InlineData (nameof (ColorName16.BrightRed), 231, 72, 86)] [InlineData (nameof (ColorName16.BrightYellow), 249, 241, 165)] [InlineData (nameof (ColorName16.Cyan), 0, 255, 255)] - [InlineData (nameof (ColorName16.DarkGray), 118, 118, 118)] + [InlineData (nameof (ColorName16.DarkGray), 169, 169, 169)] [InlineData (nameof (ColorName16.Gray), 128, 128, 128)] [InlineData (nameof (ColorName16.Green), 0, 128, 0)] [InlineData (nameof (ColorName16.Magenta), 255, 0, 255)] diff --git a/Tests/UnitTestsParallelizable/Drawing/Color/MultiStandardColorNameResolverTests.cs b/Tests/UnitTestsParallelizable/Drawing/Color/MultiStandardColorNameResolverTests.cs index ca75dfb505..7611475525 100644 --- a/Tests/UnitTestsParallelizable/Drawing/Color/MultiStandardColorNameResolverTests.cs +++ b/Tests/UnitTestsParallelizable/Drawing/Color/MultiStandardColorNameResolverTests.cs @@ -121,8 +121,8 @@ public void TryNameColor_NoMatchFails () [Theory] [InlineData ("12", 231, 72, 86)] // ColorName16.BrightRed - [InlineData ("16737095", 255, 99, 71)] // StandardColor.Tomato - [InlineData ("#FF0000", 255, 0, 0)] // Red + [InlineData ("4294927175", 255, 99, 71)] // StandardColor.Tomato + [InlineData ("#FFFF0000", 255, 0, 0)] // Red public void TryParseColor_ResolvesValidEnumNumber (string inputName, byte r, byte g, byte b) { bool success = _candidate.TryParseColor (inputName, out Color actualColor); @@ -152,4 +152,17 @@ public void TryParseColor_FailsOnInvalidEnumNumber (string input) Assert.False (success); Assert.Equal (default, actualColor); } + + + [Fact] + public void TestDarkGraysAreSame () + { + var c1 = new Color (StandardColor.DarkGray); + var c2 = new Color (ColorName16.DarkGray); + + Assert.Equal (c1.R, c2.R); + Assert.Equal (c1.G, c2.G); + Assert.Equal (c1.B, c2.B); + Assert.Equal (c1.A, c2.A); + } } diff --git a/Tests/UnitTestsParallelizable/Drawing/Color/StandardColorNameResolverTests.cs b/Tests/UnitTestsParallelizable/Drawing/Color/StandardColorNameResolverTests.cs index 34c2767ad7..7bcf133382 100644 --- a/Tests/UnitTestsParallelizable/Drawing/Color/StandardColorNameResolverTests.cs +++ b/Tests/UnitTestsParallelizable/Drawing/Color/StandardColorNameResolverTests.cs @@ -185,7 +185,7 @@ public void TryParseColor_ReturnsExpectedColor (string inputName, int r, int g, } [Theory] - [InlineData ("16737095", 255, 99, 71)] // W3cColor.Tomato + [InlineData ("4294927175", 255, 99, 71)] // W3cColor.Tomato public void TryParseColor_ResolvesValidEnumNumber (string inputName, byte r, byte g, byte b) { var expected = (true, new Color(r, g, b)); diff --git a/Tests/UnitTestsParallelizable/Drawing/ColorTests.Constructors.cs b/Tests/UnitTestsParallelizable/Drawing/ColorTests.Constructors.cs index 7206467ebf..2d8dac530f 100644 --- a/Tests/UnitTestsParallelizable/Drawing/ColorTests.Constructors.cs +++ b/Tests/UnitTestsParallelizable/Drawing/ColorTests.Constructors.cs @@ -169,6 +169,28 @@ public void Constructor_WithUInt32_AllChannelsCorrect ( () => Assert.Equal (a, color.A) ); } + + [Fact] + public void TestBlackVsTransparent () + { + var black = new Color (StandardColor.Black); + var transparent = new Color (StandardColor.Transparent); + + Assert.Multiple( + ()=>Assert.Equal (0,black.R), + () => Assert.Equal (0, black.G), + () => Assert.Equal (0, black.B), + () => Assert.Equal (255, black.A) // Difference between black and transparent is the Alpha (black is opaque) + ); + + + Assert.Multiple ( + () => Assert.Equal (0, transparent.R), + () => Assert.Equal (0, transparent.G), + () => Assert.Equal (0, transparent.B), + () => Assert.Equal (0, transparent.A) + ); + } } public static partial class ColorTestsTheoryDataGenerators