diff --git a/src/ImageSharp.Processing/Overlays/Glow.cs b/src/ImageSharp.Processing/Overlays/Glow.cs index 91fbfc7f6..9c5fe017f 100644 --- a/src/ImageSharp.Processing/Overlays/Glow.cs +++ b/src/ImageSharp.Processing/Overlays/Glow.cs @@ -23,7 +23,7 @@ namespace ImageSharp public static Image Glow(this Image source) where TColor : struct, IPackedPixel, IEquatable { - return Glow(source, default(TColor), source.Bounds.Width * .5F, source.Bounds); + return Glow(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds); } /// @@ -49,7 +49,7 @@ namespace ImageSharp public static Image Glow(this Image source, float radius) where TColor : struct, IPackedPixel, IEquatable { - return Glow(source, default(TColor), radius, source.Bounds); + return Glow(source, NamedColors.Black, radius, source.Bounds); } /// @@ -64,7 +64,7 @@ namespace ImageSharp public static Image Glow(this Image source, Rectangle rectangle) where TColor : struct, IPackedPixel, IEquatable { - return Glow(source, default(TColor), 0, rectangle); + return Glow(source, NamedColors.Black, 0, rectangle); } /// @@ -81,13 +81,7 @@ namespace ImageSharp public static Image Glow(this Image source, TColor color, float radius, Rectangle rectangle) where TColor : struct, IPackedPixel, IEquatable { - GlowProcessor processor = new GlowProcessor { Radius = radius, }; - - if (!color.Equals(default(TColor))) - { - processor.GlowColor = color; - } - + GlowProcessor processor = new GlowProcessor(color) { Radius = radius, }; source.ApplyProcessor(processor, rectangle); return source; } diff --git a/src/ImageSharp.Processing/Overlays/Vignette.cs b/src/ImageSharp.Processing/Overlays/Vignette.cs index c6cd0ab1e..4a505ad9b 100644 --- a/src/ImageSharp.Processing/Overlays/Vignette.cs +++ b/src/ImageSharp.Processing/Overlays/Vignette.cs @@ -23,7 +23,7 @@ namespace ImageSharp public static Image Vignette(this Image source) where TColor : struct, IPackedPixel, IEquatable { - return Vignette(source, default(TColor), source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); + return Vignette(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); } /// @@ -50,7 +50,7 @@ namespace ImageSharp public static Image Vignette(this Image source, float radiusX, float radiusY) where TColor : struct, IPackedPixel, IEquatable { - return Vignette(source, default(TColor), radiusX, radiusY, source.Bounds); + return Vignette(source, NamedColors.Black, radiusX, radiusY, source.Bounds); } /// @@ -65,7 +65,7 @@ namespace ImageSharp public static Image Vignette(this Image source, Rectangle rectangle) where TColor : struct, IPackedPixel, IEquatable { - return Vignette(source, default(TColor), 0, 0, rectangle); + return Vignette(source, NamedColors.Black, 0, 0, rectangle); } /// @@ -83,13 +83,7 @@ namespace ImageSharp public static Image Vignette(this Image source, TColor color, float radiusX, float radiusY, Rectangle rectangle) where TColor : struct, IPackedPixel, IEquatable { - VignetteProcessor processor = new VignetteProcessor { RadiusX = radiusX, RadiusY = radiusY }; - - if (!color.Equals(default(TColor))) - { - processor.VignetteColor = color; - } - + VignetteProcessor processor = new VignetteProcessor(color) { RadiusX = radiusX, RadiusY = radiusY }; source.ApplyProcessor(processor, rectangle); return source; } diff --git a/src/ImageSharp.Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp.Processing/Processors/Binarization/BinaryThresholdProcessor.cs index cb3758748..e4010413f 100644 --- a/src/ImageSharp.Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Binarization/BinaryThresholdProcessor.cs @@ -27,13 +27,8 @@ namespace ImageSharp.Processing.Processors this.Threshold = threshold; // Default to white/black for upper/lower. - TColor upper = default(TColor); - upper.PackFromBytes(255, 255, 255, 255); - this.UpperColor = upper; - - TColor lower = default(TColor); - lower.PackFromBytes(0, 0, 0, 255); - this.LowerColor = lower; + this.UpperColor = NamedColors.White; + this.LowerColor = NamedColors.Black; } /// diff --git a/src/ImageSharp.Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs b/src/ImageSharp.Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs index 6429ce6f0..25b464c69 100644 --- a/src/ImageSharp.Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs @@ -29,13 +29,8 @@ namespace ImageSharp.Processing.Processors this.Threshold = threshold; // Default to white/black for upper/lower. - TColor upper = default(TColor); - upper.PackFromBytes(255, 255, 255, 255); - this.UpperColor = upper; - - TColor lower = default(TColor); - lower.PackFromBytes(0, 0, 0, 255); - this.LowerColor = lower; + this.UpperColor = NamedColors.White; + this.LowerColor = NamedColors.Black; } /// diff --git a/src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs b/src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs index ae1224bad..f201ba49a 100644 --- a/src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs @@ -37,13 +37,8 @@ namespace ImageSharp.Processing.Processors this.Index = index; // Default to white/black for upper/lower. - TColor upper = default(TColor); - upper.PackFromBytes(255, 255, 255, 255); - this.UpperColor = upper; - - TColor lower = default(TColor); - lower.PackFromBytes(0, 0, 0, 255); - this.LowerColor = lower; + this.UpperColor = NamedColors.White; + this.LowerColor = NamedColors.Black; } /// diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/LomographProcessor.cs b/src/ImageSharp.Processing/Processors/ColorMatrix/LomographProcessor.cs index 731e04bf7..ad166b134 100644 --- a/src/ImageSharp.Processing/Processors/ColorMatrix/LomographProcessor.cs +++ b/src/ImageSharp.Processing/Processors/ColorMatrix/LomographProcessor.cs @@ -15,6 +15,8 @@ namespace ImageSharp.Processing.Processors public class LomographProcessor : ColorMatrixFilter where TColor : struct, IPackedPixel, IEquatable { + private static readonly TColor VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); + /// public override Matrix4x4 Matrix => new Matrix4x4() { @@ -30,9 +32,7 @@ namespace ImageSharp.Processing.Processors /// protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) { - TColor packed = default(TColor); - packed.PackFromVector4(new Color(0, 10, 0).ToVector4()); // Very dark (mostly black) lime green. - new VignetteProcessor { VignetteColor = packed }.Apply(source, sourceRectangle); + new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle); } } } \ No newline at end of file diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageSharp.Processing/Processors/ColorMatrix/PolaroidProcessor.cs index 678edf011..5df11160f 100644 --- a/src/ImageSharp.Processing/Processors/ColorMatrix/PolaroidProcessor.cs +++ b/src/ImageSharp.Processing/Processors/ColorMatrix/PolaroidProcessor.cs @@ -15,6 +15,9 @@ namespace ImageSharp.Processing.Processors public class PolaroidProcessor : ColorMatrixFilter where TColor : struct, IPackedPixel, IEquatable { + private static TColor veryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); + private static TColor lightOrange = ColorBuilder.FromRGBA(255, 153, 102, 178); + /// public override Matrix4x4 Matrix => new Matrix4x4() { @@ -36,13 +39,8 @@ namespace ImageSharp.Processing.Processors /// protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) { - TColor packedV = default(TColor); - packedV.PackFromVector4(new Color(102, 34, 0).ToVector4()); // Very dark orange [Brown tone] - new VignetteProcessor { VignetteColor = packedV }.Apply(source, sourceRectangle); - - TColor packedG = default(TColor); - packedG.PackFromVector4(new Color(255, 153, 102, 178).ToVector4()); // Light orange - new GlowProcessor { GlowColor = packedG, Radius = source.Width / 4F }.Apply(source, sourceRectangle); + new VignetteProcessor(veryDarkOrange).Apply(source, sourceRectangle); + new GlowProcessor(lightOrange) { Radius = source.Width / 4F }.Apply(source, sourceRectangle); } } } \ No newline at end of file diff --git a/src/ImageSharp.Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp.Processing/Processors/Overlays/GlowProcessor.cs index f0e32f1fa..690f57ab7 100644 --- a/src/ImageSharp.Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Overlays/GlowProcessor.cs @@ -17,12 +17,11 @@ namespace ImageSharp.Processing.Processors where TColor : struct, IPackedPixel, IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public GlowProcessor() + /// The color or the glow. + public GlowProcessor(TColor color) { - TColor color = default(TColor); - color.PackFromVector4(Color.Black.ToVector4()); this.GlowColor = color; } diff --git a/src/ImageSharp.Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp.Processing/Processors/Overlays/VignetteProcessor.cs index 8449f1833..6e94a4c2a 100644 --- a/src/ImageSharp.Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Overlays/VignetteProcessor.cs @@ -17,12 +17,11 @@ namespace ImageSharp.Processing.Processors where TColor : struct, IPackedPixel, IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public VignetteProcessor() + /// The color of the vignette. + public VignetteProcessor(TColor color) { - TColor color = default(TColor); - color.PackFromVector4(Color.Black.ToVector4()); this.VignetteColor = color; } diff --git a/src/ImageSharp/Colors/Color.cs b/src/ImageSharp/Colors/Color.cs index b2f9437ca..730fe45a5 100644 --- a/src/ImageSharp/Colors/Color.cs +++ b/src/ImageSharp/Colors/Color.cs @@ -67,28 +67,6 @@ namespace ImageSharp this.packedValue = Pack(r, g, b, a); } - /// - /// Initializes a new instance of the struct. - /// - /// - /// The hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. - /// - public Color(string hex) - { - Guard.NotNullOrEmpty(hex, nameof(hex)); - - hex = ToRgbaHex(hex); - - if (hex == null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out this.packedValue)) - { - throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); - } - - // Order parsed from hex string will be backwards, so reverse it. - this.packedValue = Pack(this.A, this.B, this.G, this.R); - } - /// /// Initializes a new instance of the struct. /// @@ -264,7 +242,7 @@ namespace ImageSharp /// public static Color FromHex(string hex) { - return new Color(hex); + return ColorBuilder.FromHex(hex); } /// @@ -421,39 +399,5 @@ namespace ImageSharp { return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift); } - - /// - /// Converts the specified hex value to an rrggbbaa hex value. - /// - /// The hex value to convert. - /// - /// A rrggbbaa hex value. - /// - private static string ToRgbaHex(string hex) - { - hex = hex.StartsWith("#") ? hex.Substring(1) : hex; - - if (hex.Length == 8) - { - return hex; - } - - if (hex.Length == 6) - { - return hex + "FF"; - } - - if (hex.Length < 3 || hex.Length > 4) - { - return null; - } - - string red = char.ToString(hex[0]); - string green = char.ToString(hex[1]); - string blue = char.ToString(hex[2]); - string alpha = hex.Length == 3 ? "F" : char.ToString(hex[3]); - - return red + red + green + green + blue + blue + alpha + alpha; - } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Colors/ColorBuilder{TColor}.cs b/src/ImageSharp/Colors/ColorBuilder{TColor}.cs new file mode 100644 index 000000000..47506af49 --- /dev/null +++ b/src/ImageSharp/Colors/ColorBuilder{TColor}.cs @@ -0,0 +1,110 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.Globalization; + + /// + /// A set of named colors mapped to the provided Color space. + /// + /// The type of the color. + public static class ColorBuilder + where TColor : struct, IPackedPixel, IEquatable + { + /// + /// Creates a new representation from the string representing a color. + /// + /// + /// The hexadecimal representation of the combined color components arranged + /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. + /// + /// Returns a that represents the color defined by the provided RGBA heax string. + public static TColor FromHex(string hex) + { + Guard.NotNullOrEmpty(hex, nameof(hex)); + + hex = ToRgbaHex(hex); + uint packedValue; + if (hex == null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out packedValue)) + { + throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); + } + + TColor result = default(TColor); + + result.PackFromBytes( + (byte)(packedValue >> 24), + (byte)(packedValue >> 16), + (byte)(packedValue >> 8), + (byte)(packedValue >> 0)); + return result; + } + + /// + /// Creates a new representation from standard RGB bytes with 100% opacity. + /// + /// The red intensity. + /// The green intensity. + /// The blue intensity. + /// Returns a that represents the color defined by the provided RGB values with 100% opacity. + public static TColor FromRGB(byte red, byte green, byte blue) + { + TColor color = default(TColor); + color.PackFromBytes(red, green, blue, 255); + return color; + } + + /// + /// Creates a new representation from standard RGBA bytes. + /// + /// The red intensity. + /// The green intensity. + /// The blue intensity. + /// The alpha intensity. + /// Returns a that represents the color defined by the provided RGBA values. + public static TColor FromRGBA(byte red, byte green, byte blue, byte alpha) + { + TColor color = default(TColor); + color.PackFromBytes(red, green, blue, alpha); + return color; + } + + /// + /// Converts the specified hex value to an rrggbbaa hex value. + /// + /// The hex value to convert. + /// + /// A rrggbbaa hex value. + /// + private static string ToRgbaHex(string hex) + { + hex = hex.StartsWith("#") ? hex.Substring(1) : hex; + + if (hex.Length == 8) + { + return hex; + } + + if (hex.Length == 6) + { + return hex + "FF"; + } + + if (hex.Length < 3 || hex.Length > 4) + { + return null; + } + + string red = char.ToString(hex[0]); + string green = char.ToString(hex[1]); + string blue = char.ToString(hex[2]); + string alpha = hex.Length == 3 ? "F" : char.ToString(hex[3]); + + return string.Concat(red, red, green, green, blue, blue, alpha, alpha); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Colors/ColorDefinitions.cs b/src/ImageSharp/Colors/ColorDefinitions.cs index 5c1c30fbd..65165289d 100644 --- a/src/ImageSharp/Colors/ColorDefinitions.cs +++ b/src/ImageSharp/Colors/ColorDefinitions.cs @@ -18,711 +18,711 @@ namespace ImageSharp /// /// Represents a matching the W3C definition that has an hex value of #F0F8FF. /// - public static readonly Color AliceBlue = new Color(240, 248, 255, 255); + public static readonly Color AliceBlue = NamedColors.AliceBlue; /// /// Represents a matching the W3C definition that has an hex value of #FAEBD7. /// - public static readonly Color AntiqueWhite = new Color(250, 235, 215, 255); + public static readonly Color AntiqueWhite = NamedColors.AntiqueWhite; /// /// Represents a matching the W3C definition that has an hex value of #00FFFF. /// - public static readonly Color Aqua = new Color(0, 255, 255, 255); + public static readonly Color Aqua = NamedColors.Aqua; /// /// Represents a matching the W3C definition that has an hex value of #7FFFD4. /// - public static readonly Color Aquamarine = new Color(127, 255, 212, 255); + public static readonly Color Aquamarine = NamedColors.Aquamarine; /// /// Represents a matching the W3C definition that has an hex value of #F0FFFF. /// - public static readonly Color Azure = new Color(240, 255, 255, 255); + public static readonly Color Azure = NamedColors.Azure; /// /// Represents a matching the W3C definition that has an hex value of #F5F5DC. /// - public static readonly Color Beige = new Color(245, 245, 220, 255); + public static readonly Color Beige = NamedColors.Beige; /// /// Represents a matching the W3C definition that has an hex value of #FFE4C4. /// - public static readonly Color Bisque = new Color(255, 228, 196, 255); + public static readonly Color Bisque = NamedColors.Bisque; /// /// Represents a matching the W3C definition that has an hex value of #000000. /// - public static readonly Color Black = new Color(0, 0, 0, 255); + public static readonly Color Black = NamedColors.Black; /// /// Represents a matching the W3C definition that has an hex value of #FFEBCD. /// - public static readonly Color BlanchedAlmond = new Color(255, 235, 205, 255); + public static readonly Color BlanchedAlmond = NamedColors.BlanchedAlmond; /// /// Represents a matching the W3C definition that has an hex value of #0000FF. /// - public static readonly Color Blue = new Color(0, 0, 255, 255); + public static readonly Color Blue = NamedColors.Blue; /// /// Represents a matching the W3C definition that has an hex value of #8A2BE2. /// - public static readonly Color BlueViolet = new Color(138, 43, 226, 255); + public static readonly Color BlueViolet = NamedColors.BlueViolet; /// /// Represents a matching the W3C definition that has an hex value of #A52A2A. /// - public static readonly Color Brown = new Color(165, 42, 42, 255); + public static readonly Color Brown = NamedColors.Brown; /// /// Represents a matching the W3C definition that has an hex value of #DEB887. /// - public static readonly Color BurlyWood = new Color(222, 184, 135, 255); + public static readonly Color BurlyWood = NamedColors.BurlyWood; /// /// Represents a matching the W3C definition that has an hex value of #5F9EA0. /// - public static readonly Color CadetBlue = new Color(95, 158, 160, 255); + public static readonly Color CadetBlue = NamedColors.CadetBlue; /// /// Represents a matching the W3C definition that has an hex value of #7FFF00. /// - public static readonly Color Chartreuse = new Color(127, 255, 0, 255); + public static readonly Color Chartreuse = NamedColors.Chartreuse; /// /// Represents a matching the W3C definition that has an hex value of #D2691E. /// - public static readonly Color Chocolate = new Color(210, 105, 30, 255); + public static readonly Color Chocolate = NamedColors.Chocolate; /// /// Represents a matching the W3C definition that has an hex value of #FF7F50. /// - public static readonly Color Coral = new Color(255, 127, 80, 255); + public static readonly Color Coral = NamedColors.Coral; /// /// Represents a matching the W3C definition that has an hex value of #6495ED. /// - public static readonly Color CornflowerBlue = new Color(100, 149, 237, 255); + public static readonly Color CornflowerBlue = NamedColors.CornflowerBlue; /// /// Represents a matching the W3C definition that has an hex value of #FFF8DC. /// - public static readonly Color Cornsilk = new Color(255, 248, 220, 255); + public static readonly Color Cornsilk = NamedColors.Cornsilk; /// /// Represents a matching the W3C definition that has an hex value of #DC143C. /// - public static readonly Color Crimson = new Color(220, 20, 60, 255); + public static readonly Color Crimson = NamedColors.Crimson; /// /// Represents a matching the W3C definition that has an hex value of #00FFFF. /// - public static readonly Color Cyan = new Color(0, 255, 255, 255); + public static readonly Color Cyan = NamedColors.Cyan; /// /// Represents a matching the W3C definition that has an hex value of #00008B. /// - public static readonly Color DarkBlue = new Color(0, 0, 139, 255); + public static readonly Color DarkBlue = NamedColors.DarkBlue; /// /// Represents a matching the W3C definition that has an hex value of #008B8B. /// - public static readonly Color DarkCyan = new Color(0, 139, 139, 255); + public static readonly Color DarkCyan = NamedColors.DarkCyan; /// /// Represents a matching the W3C definition that has an hex value of #B8860B. /// - public static readonly Color DarkGoldenrod = new Color(184, 134, 11, 255); + public static readonly Color DarkGoldenrod = NamedColors.DarkGoldenrod; /// /// Represents a matching the W3C definition that has an hex value of #A9A9A9. /// - public static readonly Color DarkGray = new Color(169, 169, 169, 255); + public static readonly Color DarkGray = NamedColors.DarkGray; /// /// Represents a matching the W3C definition that has an hex value of #006400. /// - public static readonly Color DarkGreen = new Color(0, 100, 0, 255); + public static readonly Color DarkGreen = NamedColors.DarkGreen; /// /// Represents a matching the W3C definition that has an hex value of #BDB76B. /// - public static readonly Color DarkKhaki = new Color(189, 183, 107, 255); + public static readonly Color DarkKhaki = NamedColors.DarkKhaki; /// /// Represents a matching the W3C definition that has an hex value of #8B008B. /// - public static readonly Color DarkMagenta = new Color(139, 0, 139, 255); + public static readonly Color DarkMagenta = NamedColors.DarkMagenta; /// /// Represents a matching the W3C definition that has an hex value of #556B2F. /// - public static readonly Color DarkOliveGreen = new Color(85, 107, 47, 255); + public static readonly Color DarkOliveGreen = NamedColors.DarkOliveGreen; /// /// Represents a matching the W3C definition that has an hex value of #FF8C00. /// - public static readonly Color DarkOrange = new Color(255, 140, 0, 255); + public static readonly Color DarkOrange = NamedColors.DarkOrange; /// /// Represents a matching the W3C definition that has an hex value of #9932CC. /// - public static readonly Color DarkOrchid = new Color(153, 50, 204, 255); + public static readonly Color DarkOrchid = NamedColors.DarkOrchid; /// /// Represents a matching the W3C definition that has an hex value of #8B0000. /// - public static readonly Color DarkRed = new Color(139, 0, 0, 255); + public static readonly Color DarkRed = NamedColors.DarkRed; /// /// Represents a matching the W3C definition that has an hex value of #E9967A. /// - public static readonly Color DarkSalmon = new Color(233, 150, 122, 255); + public static readonly Color DarkSalmon = NamedColors.DarkSalmon; /// /// Represents a matching the W3C definition that has an hex value of #8FBC8B. /// - public static readonly Color DarkSeaGreen = new Color(143, 188, 139, 255); + public static readonly Color DarkSeaGreen = NamedColors.DarkSeaGreen; /// /// Represents a matching the W3C definition that has an hex value of #483D8B. /// - public static readonly Color DarkSlateBlue = new Color(72, 61, 139, 255); + public static readonly Color DarkSlateBlue = NamedColors.DarkSlateBlue; /// /// Represents a matching the W3C definition that has an hex value of #2F4F4F. /// - public static readonly Color DarkSlateGray = new Color(47, 79, 79, 255); + public static readonly Color DarkSlateGray = NamedColors.DarkSlateGray; /// /// Represents a matching the W3C definition that has an hex value of #00CED1. /// - public static readonly Color DarkTurquoise = new Color(0, 206, 209, 255); + public static readonly Color DarkTurquoise = NamedColors.DarkTurquoise; /// /// Represents a matching the W3C definition that has an hex value of #9400D3. /// - public static readonly Color DarkViolet = new Color(148, 0, 211, 255); + public static readonly Color DarkViolet = NamedColors.DarkViolet; /// /// Represents a matching the W3C definition that has an hex value of #FF1493. /// - public static readonly Color DeepPink = new Color(255, 20, 147, 255); + public static readonly Color DeepPink = NamedColors.DeepPink; /// /// Represents a matching the W3C definition that has an hex value of #00BFFF. /// - public static readonly Color DeepSkyBlue = new Color(0, 191, 255, 255); + public static readonly Color DeepSkyBlue = NamedColors.DeepSkyBlue; /// /// Represents a matching the W3C definition that has an hex value of #696969. /// - public static readonly Color DimGray = new Color(105, 105, 105, 255); + public static readonly Color DimGray = NamedColors.DimGray; /// /// Represents a matching the W3C definition that has an hex value of #1E90FF. /// - public static readonly Color DodgerBlue = new Color(30, 144, 255, 255); + public static readonly Color DodgerBlue = NamedColors.DodgerBlue; /// /// Represents a matching the W3C definition that has an hex value of #B22222. /// - public static readonly Color Firebrick = new Color(178, 34, 34, 255); + public static readonly Color Firebrick = NamedColors.Firebrick; /// /// Represents a matching the W3C definition that has an hex value of #FFFAF0. /// - public static readonly Color FloralWhite = new Color(255, 250, 240, 255); + public static readonly Color FloralWhite = NamedColors.FloralWhite; /// /// Represents a matching the W3C definition that has an hex value of #228B22. /// - public static readonly Color ForestGreen = new Color(34, 139, 34, 255); + public static readonly Color ForestGreen = NamedColors.ForestGreen; /// /// Represents a matching the W3C definition that has an hex value of #FF00FF. /// - public static readonly Color Fuchsia = new Color(255, 0, 255, 255); + public static readonly Color Fuchsia = NamedColors.Fuchsia; /// /// Represents a matching the W3C definition that has an hex value of #DCDCDC. /// - public static readonly Color Gainsboro = new Color(220, 220, 220, 255); + public static readonly Color Gainsboro = NamedColors.Gainsboro; /// /// Represents a matching the W3C definition that has an hex value of #F8F8FF. /// - public static readonly Color GhostWhite = new Color(248, 248, 255, 255); + public static readonly Color GhostWhite = NamedColors.GhostWhite; /// /// Represents a matching the W3C definition that has an hex value of #FFD700. /// - public static readonly Color Gold = new Color(255, 215, 0, 255); + public static readonly Color Gold = NamedColors.Gold; /// /// Represents a matching the W3C definition that has an hex value of #DAA520. /// - public static readonly Color Goldenrod = new Color(218, 165, 32, 255); + public static readonly Color Goldenrod = NamedColors.Goldenrod; /// /// Represents a matching the W3C definition that has an hex value of #808080. /// - public static readonly Color Gray = new Color(128, 128, 128, 255); + public static readonly Color Gray = NamedColors.Gray; /// /// Represents a matching the W3C definition that has an hex value of #008000. /// - public static readonly Color Green = new Color(0, 128, 0, 255); + public static readonly Color Green = NamedColors.Green; /// /// Represents a matching the W3C definition that has an hex value of #ADFF2F. /// - public static readonly Color GreenYellow = new Color(173, 255, 47, 255); + public static readonly Color GreenYellow = NamedColors.GreenYellow; /// /// Represents a matching the W3C definition that has an hex value of #F0FFF0. /// - public static readonly Color Honeydew = new Color(240, 255, 240, 255); + public static readonly Color Honeydew = NamedColors.Honeydew; /// /// Represents a matching the W3C definition that has an hex value of #FF69B4. /// - public static readonly Color HotPink = new Color(255, 105, 180, 255); + public static readonly Color HotPink = NamedColors.HotPink; /// /// Represents a matching the W3C definition that has an hex value of #CD5C5C. /// - public static readonly Color IndianRed = new Color(205, 92, 92, 255); + public static readonly Color IndianRed = NamedColors.IndianRed; /// /// Represents a matching the W3C definition that has an hex value of #4B0082. /// - public static readonly Color Indigo = new Color(75, 0, 130, 255); + public static readonly Color Indigo = NamedColors.Indigo; /// /// Represents a matching the W3C definition that has an hex value of #FFFFF0. /// - public static readonly Color Ivory = new Color(255, 255, 240, 255); + public static readonly Color Ivory = NamedColors.Ivory; /// /// Represents a matching the W3C definition that has an hex value of #F0E68C. /// - public static readonly Color Khaki = new Color(240, 230, 140, 255); + public static readonly Color Khaki = NamedColors.Khaki; /// /// Represents a matching the W3C definition that has an hex value of #E6E6FA. /// - public static readonly Color Lavender = new Color(230, 230, 250, 255); + public static readonly Color Lavender = NamedColors.Lavender; /// /// Represents a matching the W3C definition that has an hex value of #FFF0F5. /// - public static readonly Color LavenderBlush = new Color(255, 240, 245, 255); + public static readonly Color LavenderBlush = NamedColors.LavenderBlush; /// /// Represents a matching the W3C definition that has an hex value of #7CFC00. /// - public static readonly Color LawnGreen = new Color(124, 252, 0, 255); + public static readonly Color LawnGreen = NamedColors.LawnGreen; /// /// Represents a matching the W3C definition that has an hex value of #FFFACD. /// - public static readonly Color LemonChiffon = new Color(255, 250, 205, 255); + public static readonly Color LemonChiffon = NamedColors.LemonChiffon; /// /// Represents a matching the W3C definition that has an hex value of #ADD8E6. /// - public static readonly Color LightBlue = new Color(173, 216, 230, 255); + public static readonly Color LightBlue = NamedColors.LightBlue; /// /// Represents a matching the W3C definition that has an hex value of #F08080. /// - public static readonly Color LightCoral = new Color(240, 128, 128, 255); + public static readonly Color LightCoral = NamedColors.LightCoral; /// /// Represents a matching the W3C definition that has an hex value of #E0FFFF. /// - public static readonly Color LightCyan = new Color(224, 255, 255, 255); + public static readonly Color LightCyan = NamedColors.LightCyan; /// /// Represents a matching the W3C definition that has an hex value of #FAFAD2. /// - public static readonly Color LightGoldenrodYellow = new Color(250, 250, 210, 255); + public static readonly Color LightGoldenrodYellow = NamedColors.LightGoldenrodYellow; /// /// Represents a matching the W3C definition that has an hex value of #D3D3D3. /// - public static readonly Color LightGray = new Color(211, 211, 211, 255); + public static readonly Color LightGray = NamedColors.LightGray; /// /// Represents a matching the W3C definition that has an hex value of #90EE90. /// - public static readonly Color LightGreen = new Color(144, 238, 144, 255); + public static readonly Color LightGreen = NamedColors.LightGreen; /// /// Represents a matching the W3C definition that has an hex value of #FFB6C1. /// - public static readonly Color LightPink = new Color(255, 182, 193, 255); + public static readonly Color LightPink = NamedColors.LightPink; /// /// Represents a matching the W3C definition that has an hex value of #FFA07A. /// - public static readonly Color LightSalmon = new Color(255, 160, 122, 255); + public static readonly Color LightSalmon = NamedColors.LightSalmon; /// /// Represents a matching the W3C definition that has an hex value of #20B2AA. /// - public static readonly Color LightSeaGreen = new Color(32, 178, 170, 255); + public static readonly Color LightSeaGreen = NamedColors.LightSeaGreen; /// /// Represents a matching the W3C definition that has an hex value of #87CEFA. /// - public static readonly Color LightSkyBlue = new Color(135, 206, 250, 255); + public static readonly Color LightSkyBlue = NamedColors.LightSkyBlue; /// /// Represents a matching the W3C definition that has an hex value of #778899. /// - public static readonly Color LightSlateGray = new Color(119, 136, 153, 255); + public static readonly Color LightSlateGray = NamedColors.LightSlateGray; /// /// Represents a matching the W3C definition that has an hex value of #B0C4DE. /// - public static readonly Color LightSteelBlue = new Color(176, 196, 222, 255); + public static readonly Color LightSteelBlue = NamedColors.LightSteelBlue; /// /// Represents a matching the W3C definition that has an hex value of #FFFFE0. /// - public static readonly Color LightYellow = new Color(255, 255, 224, 255); + public static readonly Color LightYellow = NamedColors.LightYellow; /// /// Represents a matching the W3C definition that has an hex value of #00FF00. /// - public static readonly Color Lime = new Color(0, 255, 0, 255); + public static readonly Color Lime = NamedColors.Lime; /// /// Represents a matching the W3C definition that has an hex value of #32CD32. /// - public static readonly Color LimeGreen = new Color(50, 205, 50, 255); + public static readonly Color LimeGreen = NamedColors.LimeGreen; /// /// Represents a matching the W3C definition that has an hex value of #FAF0E6. /// - public static readonly Color Linen = new Color(250, 240, 230, 255); + public static readonly Color Linen = NamedColors.Linen; /// /// Represents a matching the W3C definition that has an hex value of #FF00FF. /// - public static readonly Color Magenta = new Color(255, 0, 255, 255); + public static readonly Color Magenta = NamedColors.Magenta; /// /// Represents a matching the W3C definition that has an hex value of #800000. /// - public static readonly Color Maroon = new Color(128, 0, 0, 255); + public static readonly Color Maroon = NamedColors.Maroon; /// /// Represents a matching the W3C definition that has an hex value of #66CDAA. /// - public static readonly Color MediumAquamarine = new Color(102, 205, 170, 255); + public static readonly Color MediumAquamarine = NamedColors.MediumAquamarine; /// /// Represents a matching the W3C definition that has an hex value of #0000CD. /// - public static readonly Color MediumBlue = new Color(0, 0, 205, 255); + public static readonly Color MediumBlue = NamedColors.MediumBlue; /// /// Represents a matching the W3C definition that has an hex value of #BA55D3. /// - public static readonly Color MediumOrchid = new Color(186, 85, 211, 255); + public static readonly Color MediumOrchid = NamedColors.MediumOrchid; /// /// Represents a matching the W3C definition that has an hex value of #9370DB. /// - public static readonly Color MediumPurple = new Color(147, 112, 219, 255); + public static readonly Color MediumPurple = NamedColors.MediumPurple; /// /// Represents a matching the W3C definition that has an hex value of #3CB371. /// - public static readonly Color MediumSeaGreen = new Color(60, 179, 113, 255); + public static readonly Color MediumSeaGreen = NamedColors.MediumSeaGreen; /// /// Represents a matching the W3C definition that has an hex value of #7B68EE. /// - public static readonly Color MediumSlateBlue = new Color(123, 104, 238, 255); + public static readonly Color MediumSlateBlue = NamedColors.MediumSlateBlue; /// /// Represents a matching the W3C definition that has an hex value of #00FA9A. /// - public static readonly Color MediumSpringGreen = new Color(0, 250, 154, 255); + public static readonly Color MediumSpringGreen = NamedColors.MediumSpringGreen; /// /// Represents a matching the W3C definition that has an hex value of #48D1CC. /// - public static readonly Color MediumTurquoise = new Color(72, 209, 204, 255); + public static readonly Color MediumTurquoise = NamedColors.MediumTurquoise; /// /// Represents a matching the W3C definition that has an hex value of #C71585. /// - public static readonly Color MediumVioletRed = new Color(199, 21, 133, 255); + public static readonly Color MediumVioletRed = NamedColors.MediumVioletRed; /// /// Represents a matching the W3C definition that has an hex value of #191970. /// - public static readonly Color MidnightBlue = new Color(25, 25, 112, 255); + public static readonly Color MidnightBlue = NamedColors.MidnightBlue; /// /// Represents a matching the W3C definition that has an hex value of #F5FFFA. /// - public static readonly Color MintCream = new Color(245, 255, 250, 255); + public static readonly Color MintCream = NamedColors.MintCream; /// /// Represents a matching the W3C definition that has an hex value of #FFE4E1. /// - public static readonly Color MistyRose = new Color(255, 228, 225, 255); + public static readonly Color MistyRose = NamedColors.MistyRose; /// /// Represents a matching the W3C definition that has an hex value of #FFE4B5. /// - public static readonly Color Moccasin = new Color(255, 228, 181, 255); + public static readonly Color Moccasin = NamedColors.Moccasin; /// /// Represents a matching the W3C definition that has an hex value of #FFDEAD. /// - public static readonly Color NavajoWhite = new Color(255, 222, 173, 255); + public static readonly Color NavajoWhite = NamedColors.NavajoWhite; /// /// Represents a matching the W3C definition that has an hex value of #000080. /// - public static readonly Color Navy = new Color(0, 0, 128, 255); + public static readonly Color Navy = NamedColors.Navy; /// /// Represents a matching the W3C definition that has an hex value of #FDF5E6. /// - public static readonly Color OldLace = new Color(253, 245, 230, 255); + public static readonly Color OldLace = NamedColors.OldLace; /// /// Represents a matching the W3C definition that has an hex value of #808000. /// - public static readonly Color Olive = new Color(128, 128, 0, 255); + public static readonly Color Olive = NamedColors.Olive; /// /// Represents a matching the W3C definition that has an hex value of #6B8E23. /// - public static readonly Color OliveDrab = new Color(107, 142, 35, 255); + public static readonly Color OliveDrab = NamedColors.OliveDrab; /// /// Represents a matching the W3C definition that has an hex value of #FFA500. /// - public static readonly Color Orange = new Color(255, 165, 0, 255); + public static readonly Color Orange = NamedColors.Orange; /// /// Represents a matching the W3C definition that has an hex value of #FF4500. /// - public static readonly Color OrangeRed = new Color(255, 69, 0, 255); + public static readonly Color OrangeRed = NamedColors.OrangeRed; /// /// Represents a matching the W3C definition that has an hex value of #DA70D6. /// - public static readonly Color Orchid = new Color(218, 112, 214, 255); + public static readonly Color Orchid = NamedColors.Orchid; /// /// Represents a matching the W3C definition that has an hex value of #EEE8AA. /// - public static readonly Color PaleGoldenrod = new Color(238, 232, 170, 255); + public static readonly Color PaleGoldenrod = NamedColors.PaleGoldenrod; /// /// Represents a matching the W3C definition that has an hex value of #98FB98. /// - public static readonly Color PaleGreen = new Color(152, 251, 152, 255); + public static readonly Color PaleGreen = NamedColors.PaleGreen; /// /// Represents a matching the W3C definition that has an hex value of #AFEEEE. /// - public static readonly Color PaleTurquoise = new Color(175, 238, 238, 255); + public static readonly Color PaleTurquoise = NamedColors.PaleTurquoise; /// /// Represents a matching the W3C definition that has an hex value of #DB7093. /// - public static readonly Color PaleVioletRed = new Color(219, 112, 147, 255); + public static readonly Color PaleVioletRed = NamedColors.PaleVioletRed; /// /// Represents a matching the W3C definition that has an hex value of #FFEFD5. /// - public static readonly Color PapayaWhip = new Color(255, 239, 213, 255); + public static readonly Color PapayaWhip = NamedColors.PapayaWhip; /// /// Represents a matching the W3C definition that has an hex value of #FFDAB9. /// - public static readonly Color PeachPuff = new Color(255, 218, 185, 255); + public static readonly Color PeachPuff = NamedColors.PeachPuff; /// /// Represents a matching the W3C definition that has an hex value of #CD853F. /// - public static readonly Color Peru = new Color(205, 133, 63, 255); + public static readonly Color Peru = NamedColors.Peru; /// /// Represents a matching the W3C definition that has an hex value of #FFC0CB. /// - public static readonly Color Pink = new Color(255, 192, 203, 255); + public static readonly Color Pink = NamedColors.Pink; /// /// Represents a matching the W3C definition that has an hex value of #DDA0DD. /// - public static readonly Color Plum = new Color(221, 160, 221, 255); + public static readonly Color Plum = NamedColors.Plum; /// /// Represents a matching the W3C definition that has an hex value of #B0E0E6. /// - public static readonly Color PowderBlue = new Color(176, 224, 230, 255); + public static readonly Color PowderBlue = NamedColors.PowderBlue; /// /// Represents a matching the W3C definition that has an hex value of #800080. /// - public static readonly Color Purple = new Color(128, 0, 128, 255); + public static readonly Color Purple = NamedColors.Purple; /// /// Represents a matching the W3C definition that has an hex value of #663399. /// - public static readonly Color RebeccaPurple = new Color(102, 51, 153, 255); + public static readonly Color RebeccaPurple = NamedColors.RebeccaPurple; /// /// Represents a matching the W3C definition that has an hex value of #FF0000. /// - public static readonly Color Red = new Color(255, 0, 0, 255); + public static readonly Color Red = NamedColors.Red; /// /// Represents a matching the W3C definition that has an hex value of #BC8F8F. /// - public static readonly Color RosyBrown = new Color(188, 143, 143, 255); + public static readonly Color RosyBrown = NamedColors.RosyBrown; /// /// Represents a matching the W3C definition that has an hex value of #4169E1. /// - public static readonly Color RoyalBlue = new Color(65, 105, 225, 255); + public static readonly Color RoyalBlue = NamedColors.RoyalBlue; /// /// Represents a matching the W3C definition that has an hex value of #8B4513. /// - public static readonly Color SaddleBrown = new Color(139, 69, 19, 255); + public static readonly Color SaddleBrown = NamedColors.SaddleBrown; /// /// Represents a matching the W3C definition that has an hex value of #FA8072. /// - public static readonly Color Salmon = new Color(250, 128, 114, 255); + public static readonly Color Salmon = NamedColors.Salmon; /// /// Represents a matching the W3C definition that has an hex value of #F4A460. /// - public static readonly Color SandyBrown = new Color(244, 164, 96, 255); + public static readonly Color SandyBrown = NamedColors.SandyBrown; /// /// Represents a matching the W3C definition that has an hex value of #2E8B57. /// - public static readonly Color SeaGreen = new Color(46, 139, 87, 255); + public static readonly Color SeaGreen = NamedColors.SeaGreen; /// /// Represents a matching the W3C definition that has an hex value of #FFF5EE. /// - public static readonly Color SeaShell = new Color(255, 245, 238, 255); + public static readonly Color SeaShell = NamedColors.SeaShell; /// /// Represents a matching the W3C definition that has an hex value of #A0522D. /// - public static readonly Color Sienna = new Color(160, 82, 45, 255); + public static readonly Color Sienna = NamedColors.Sienna; /// /// Represents a matching the W3C definition that has an hex value of #C0C0C0. /// - public static readonly Color Silver = new Color(192, 192, 192, 255); + public static readonly Color Silver = NamedColors.Silver; /// /// Represents a matching the W3C definition that has an hex value of #87CEEB. /// - public static readonly Color SkyBlue = new Color(135, 206, 235, 255); + public static readonly Color SkyBlue = NamedColors.SkyBlue; /// /// Represents a matching the W3C definition that has an hex value of #6A5ACD. /// - public static readonly Color SlateBlue = new Color(106, 90, 205, 255); + public static readonly Color SlateBlue = NamedColors.SlateBlue; /// /// Represents a matching the W3C definition that has an hex value of #708090. /// - public static readonly Color SlateGray = new Color(112, 128, 144, 255); + public static readonly Color SlateGray = NamedColors.SlateGray; /// /// Represents a matching the W3C definition that has an hex value of #FFFAFA. /// - public static readonly Color Snow = new Color(255, 250, 250, 255); + public static readonly Color Snow = NamedColors.Snow; /// /// Represents a matching the W3C definition that has an hex value of #00FF7F. /// - public static readonly Color SpringGreen = new Color(0, 255, 127, 255); + public static readonly Color SpringGreen = NamedColors.SpringGreen; /// /// Represents a matching the W3C definition that has an hex value of #4682B4. /// - public static readonly Color SteelBlue = new Color(70, 130, 180, 255); + public static readonly Color SteelBlue = NamedColors.SteelBlue; /// /// Represents a matching the W3C definition that has an hex value of #D2B48C. /// - public static readonly Color Tan = new Color(210, 180, 140, 255); + public static readonly Color Tan = NamedColors.Tan; /// /// Represents a matching the W3C definition that has an hex value of #008080. /// - public static readonly Color Teal = new Color(0, 128, 128, 255); + public static readonly Color Teal = NamedColors.Teal; /// /// Represents a matching the W3C definition that has an hex value of #D8BFD8. /// - public static readonly Color Thistle = new Color(216, 191, 216, 255); + public static readonly Color Thistle = NamedColors.Thistle; /// /// Represents a matching the W3C definition that has an hex value of #FF6347. /// - public static readonly Color Tomato = new Color(255, 99, 71, 255); + public static readonly Color Tomato = NamedColors.Tomato; /// /// Represents a matching the W3C definition that has an hex value of #FFFFFF. /// - public static readonly Color Transparent = new Color(255, 255, 255, 0); + public static readonly Color Transparent = NamedColors.Transparent; /// /// Represents a matching the W3C definition that has an hex value of #40E0D0. /// - public static readonly Color Turquoise = new Color(64, 224, 208, 255); + public static readonly Color Turquoise = NamedColors.Turquoise; /// /// Represents a matching the W3C definition that has an hex value of #EE82EE. /// - public static readonly Color Violet = new Color(238, 130, 238, 255); + public static readonly Color Violet = NamedColors.Violet; /// /// Represents a matching the W3C definition that has an hex value of #F5DEB3. /// - public static readonly Color Wheat = new Color(245, 222, 179, 255); + public static readonly Color Wheat = NamedColors.Wheat; /// /// Represents a matching the W3C definition that has an hex value of #FFFFFF. /// - public static readonly Color White = new Color(255, 255, 255, 255); + public static readonly Color White = NamedColors.White; /// /// Represents a matching the W3C definition that has an hex value of #F5F5F5. /// - public static readonly Color WhiteSmoke = new Color(245, 245, 245, 255); + public static readonly Color WhiteSmoke = NamedColors.WhiteSmoke; /// /// Represents a matching the W3C definition that has an hex value of #FFFF00. /// - public static readonly Color Yellow = new Color(255, 255, 0, 255); + public static readonly Color Yellow = NamedColors.Yellow; /// /// Represents a matching the W3C definition that has an hex value of #9ACD32. /// - public static readonly Color YellowGreen = new Color(154, 205, 50, 255); + public static readonly Color YellowGreen = NamedColors.YellowGreen; } } \ No newline at end of file diff --git a/src/ImageSharp/Colors/NamedColors{TColor}.cs b/src/ImageSharp/Colors/NamedColors{TColor}.cs new file mode 100644 index 000000000..77a537f0f --- /dev/null +++ b/src/ImageSharp/Colors/NamedColors{TColor}.cs @@ -0,0 +1,727 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + + /// + /// A set of named colors mapped to the provided Color space. + /// + /// The type of the color. + public static class NamedColors + where TColor : struct, IPackedPixel, IEquatable + { + /// + /// Represents a matching the W3C definition that has an hex value of #F0F8FF. + /// + public static readonly TColor AliceBlue = ColorBuilder.FromRGBA(240, 248, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAEBD7. + /// + public static readonly TColor AntiqueWhite = ColorBuilder.FromRGBA(250, 235, 215, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FFFF. + /// + public static readonly TColor Aqua = ColorBuilder.FromRGBA(0, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7FFFD4. + /// + public static readonly TColor Aquamarine = ColorBuilder.FromRGBA(127, 255, 212, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0FFFF. + /// + public static readonly TColor Azure = ColorBuilder.FromRGBA(240, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5F5DC. + /// + public static readonly TColor Beige = ColorBuilder.FromRGBA(245, 245, 220, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4C4. + /// + public static readonly TColor Bisque = ColorBuilder.FromRGBA(255, 228, 196, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #000000. + /// + public static readonly TColor Black = ColorBuilder.FromRGBA(0, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFEBCD. + /// + public static readonly TColor BlanchedAlmond = ColorBuilder.FromRGBA(255, 235, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #0000FF. + /// + public static readonly TColor Blue = ColorBuilder.FromRGBA(0, 0, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8A2BE2. + /// + public static readonly TColor BlueViolet = ColorBuilder.FromRGBA(138, 43, 226, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #A52A2A. + /// + public static readonly TColor Brown = ColorBuilder.FromRGBA(165, 42, 42, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DEB887. + /// + public static readonly TColor BurlyWood = ColorBuilder.FromRGBA(222, 184, 135, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #5F9EA0. + /// + public static readonly TColor CadetBlue = ColorBuilder.FromRGBA(95, 158, 160, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7FFF00. + /// + public static readonly TColor Chartreuse = ColorBuilder.FromRGBA(127, 255, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D2691E. + /// + public static readonly TColor Chocolate = ColorBuilder.FromRGBA(210, 105, 30, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF7F50. + /// + public static readonly TColor Coral = ColorBuilder.FromRGBA(255, 127, 80, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #6495ED. + /// + public static readonly TColor CornflowerBlue = ColorBuilder.FromRGBA(100, 149, 237, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF8DC. + /// + public static readonly TColor Cornsilk = ColorBuilder.FromRGBA(255, 248, 220, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DC143C. + /// + public static readonly TColor Crimson = ColorBuilder.FromRGBA(220, 20, 60, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FFFF. + /// + public static readonly TColor Cyan = ColorBuilder.FromRGBA(0, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00008B. + /// + public static readonly TColor DarkBlue = ColorBuilder.FromRGBA(0, 0, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #008B8B. + /// + public static readonly TColor DarkCyan = ColorBuilder.FromRGBA(0, 139, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B8860B. + /// + public static readonly TColor DarkGoldenrod = ColorBuilder.FromRGBA(184, 134, 11, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #A9A9A9. + /// + public static readonly TColor DarkGray = ColorBuilder.FromRGBA(169, 169, 169, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #006400. + /// + public static readonly TColor DarkGreen = ColorBuilder.FromRGBA(0, 100, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #BDB76B. + /// + public static readonly TColor DarkKhaki = ColorBuilder.FromRGBA(189, 183, 107, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B008B. + /// + public static readonly TColor DarkMagenta = ColorBuilder.FromRGBA(139, 0, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #556B2F. + /// + public static readonly TColor DarkOliveGreen = ColorBuilder.FromRGBA(85, 107, 47, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF8C00. + /// + public static readonly TColor DarkOrange = ColorBuilder.FromRGBA(255, 140, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9932CC. + /// + public static readonly TColor DarkOrchid = ColorBuilder.FromRGBA(153, 50, 204, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B0000. + /// + public static readonly TColor DarkRed = ColorBuilder.FromRGBA(139, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #E9967A. + /// + public static readonly TColor DarkSalmon = ColorBuilder.FromRGBA(233, 150, 122, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8FBC8B. + /// + public static readonly TColor DarkSeaGreen = ColorBuilder.FromRGBA(143, 188, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #483D8B. + /// + public static readonly TColor DarkSlateBlue = ColorBuilder.FromRGBA(72, 61, 139, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #2F4F4F. + /// + public static readonly TColor DarkSlateGray = ColorBuilder.FromRGBA(47, 79, 79, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00CED1. + /// + public static readonly TColor DarkTurquoise = ColorBuilder.FromRGBA(0, 206, 209, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9400D3. + /// + public static readonly TColor DarkViolet = ColorBuilder.FromRGBA(148, 0, 211, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF1493. + /// + public static readonly TColor DeepPink = ColorBuilder.FromRGBA(255, 20, 147, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00BFFF. + /// + public static readonly TColor DeepSkyBlue = ColorBuilder.FromRGBA(0, 191, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #696969. + /// + public static readonly TColor DimGray = ColorBuilder.FromRGBA(105, 105, 105, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #1E90FF. + /// + public static readonly TColor DodgerBlue = ColorBuilder.FromRGBA(30, 144, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B22222. + /// + public static readonly TColor Firebrick = ColorBuilder.FromRGBA(178, 34, 34, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFAF0. + /// + public static readonly TColor FloralWhite = ColorBuilder.FromRGBA(255, 250, 240, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #228B22. + /// + public static readonly TColor ForestGreen = ColorBuilder.FromRGBA(34, 139, 34, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF00FF. + /// + public static readonly TColor Fuchsia = ColorBuilder.FromRGBA(255, 0, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DCDCDC. + /// + public static readonly TColor Gainsboro = ColorBuilder.FromRGBA(220, 220, 220, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F8F8FF. + /// + public static readonly TColor GhostWhite = ColorBuilder.FromRGBA(248, 248, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFD700. + /// + public static readonly TColor Gold = ColorBuilder.FromRGBA(255, 215, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DAA520. + /// + public static readonly TColor Goldenrod = ColorBuilder.FromRGBA(218, 165, 32, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #808080. + /// + public static readonly TColor Gray = ColorBuilder.FromRGBA(128, 128, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #008000. + /// + public static readonly TColor Green = ColorBuilder.FromRGBA(0, 128, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #ADFF2F. + /// + public static readonly TColor GreenYellow = ColorBuilder.FromRGBA(173, 255, 47, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0FFF0. + /// + public static readonly TColor Honeydew = ColorBuilder.FromRGBA(240, 255, 240, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF69B4. + /// + public static readonly TColor HotPink = ColorBuilder.FromRGBA(255, 105, 180, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #CD5C5C. + /// + public static readonly TColor IndianRed = ColorBuilder.FromRGBA(205, 92, 92, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #4B0082. + /// + public static readonly TColor Indigo = ColorBuilder.FromRGBA(75, 0, 130, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFF0. + /// + public static readonly TColor Ivory = ColorBuilder.FromRGBA(255, 255, 240, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0E68C. + /// + public static readonly TColor Khaki = ColorBuilder.FromRGBA(240, 230, 140, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #E6E6FA. + /// + public static readonly TColor Lavender = ColorBuilder.FromRGBA(230, 230, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF0F5. + /// + public static readonly TColor LavenderBlush = ColorBuilder.FromRGBA(255, 240, 245, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7CFC00. + /// + public static readonly TColor LawnGreen = ColorBuilder.FromRGBA(124, 252, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFACD. + /// + public static readonly TColor LemonChiffon = ColorBuilder.FromRGBA(255, 250, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #ADD8E6. + /// + public static readonly TColor LightBlue = ColorBuilder.FromRGBA(173, 216, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F08080. + /// + public static readonly TColor LightCoral = ColorBuilder.FromRGBA(240, 128, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #E0FFFF. + /// + public static readonly TColor LightCyan = ColorBuilder.FromRGBA(224, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAFAD2. + /// + public static readonly TColor LightGoldenrodYellow = ColorBuilder.FromRGBA(250, 250, 210, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D3D3D3. + /// + public static readonly TColor LightGray = ColorBuilder.FromRGBA(211, 211, 211, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #90EE90. + /// + public static readonly TColor LightGreen = ColorBuilder.FromRGBA(144, 238, 144, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFB6C1. + /// + public static readonly TColor LightPink = ColorBuilder.FromRGBA(255, 182, 193, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFA07A. + /// + public static readonly TColor LightSalmon = ColorBuilder.FromRGBA(255, 160, 122, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #20B2AA. + /// + public static readonly TColor LightSeaGreen = ColorBuilder.FromRGBA(32, 178, 170, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #87CEFA. + /// + public static readonly TColor LightSkyBlue = ColorBuilder.FromRGBA(135, 206, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #778899. + /// + public static readonly TColor LightSlateGray = ColorBuilder.FromRGBA(119, 136, 153, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B0C4DE. + /// + public static readonly TColor LightSteelBlue = ColorBuilder.FromRGBA(176, 196, 222, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFE0. + /// + public static readonly TColor LightYellow = ColorBuilder.FromRGBA(255, 255, 224, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FF00. + /// + public static readonly TColor Lime = ColorBuilder.FromRGBA(0, 255, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #32CD32. + /// + public static readonly TColor LimeGreen = ColorBuilder.FromRGBA(50, 205, 50, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAF0E6. + /// + public static readonly TColor Linen = ColorBuilder.FromRGBA(250, 240, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF00FF. + /// + public static readonly TColor Magenta = ColorBuilder.FromRGBA(255, 0, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #800000. + /// + public static readonly TColor Maroon = ColorBuilder.FromRGBA(128, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #66CDAA. + /// + public static readonly TColor MediumAquamarine = ColorBuilder.FromRGBA(102, 205, 170, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #0000CD. + /// + public static readonly TColor MediumBlue = ColorBuilder.FromRGBA(0, 0, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #BA55D3. + /// + public static readonly TColor MediumOrchid = ColorBuilder.FromRGBA(186, 85, 211, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9370DB. + /// + public static readonly TColor MediumPurple = ColorBuilder.FromRGBA(147, 112, 219, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #3CB371. + /// + public static readonly TColor MediumSeaGreen = ColorBuilder.FromRGBA(60, 179, 113, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #7B68EE. + /// + public static readonly TColor MediumSlateBlue = ColorBuilder.FromRGBA(123, 104, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FA9A. + /// + public static readonly TColor MediumSpringGreen = ColorBuilder.FromRGBA(0, 250, 154, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #48D1CC. + /// + public static readonly TColor MediumTurquoise = ColorBuilder.FromRGBA(72, 209, 204, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #C71585. + /// + public static readonly TColor MediumVioletRed = ColorBuilder.FromRGBA(199, 21, 133, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #191970. + /// + public static readonly TColor MidnightBlue = ColorBuilder.FromRGBA(25, 25, 112, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5FFFA. + /// + public static readonly TColor MintCream = ColorBuilder.FromRGBA(245, 255, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4E1. + /// + public static readonly TColor MistyRose = ColorBuilder.FromRGBA(255, 228, 225, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4B5. + /// + public static readonly TColor Moccasin = ColorBuilder.FromRGBA(255, 228, 181, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFDEAD. + /// + public static readonly TColor NavajoWhite = ColorBuilder.FromRGBA(255, 222, 173, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #000080. + /// + public static readonly TColor Navy = ColorBuilder.FromRGBA(0, 0, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FDF5E6. + /// + public static readonly TColor OldLace = ColorBuilder.FromRGBA(253, 245, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #808000. + /// + public static readonly TColor Olive = ColorBuilder.FromRGBA(128, 128, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #6B8E23. + /// + public static readonly TColor OliveDrab = ColorBuilder.FromRGBA(107, 142, 35, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFA500. + /// + public static readonly TColor Orange = ColorBuilder.FromRGBA(255, 165, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF4500. + /// + public static readonly TColor OrangeRed = ColorBuilder.FromRGBA(255, 69, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DA70D6. + /// + public static readonly TColor Orchid = ColorBuilder.FromRGBA(218, 112, 214, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #EEE8AA. + /// + public static readonly TColor PaleGoldenrod = ColorBuilder.FromRGBA(238, 232, 170, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #98FB98. + /// + public static readonly TColor PaleGreen = ColorBuilder.FromRGBA(152, 251, 152, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #AFEEEE. + /// + public static readonly TColor PaleTurquoise = ColorBuilder.FromRGBA(175, 238, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DB7093. + /// + public static readonly TColor PaleVioletRed = ColorBuilder.FromRGBA(219, 112, 147, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFEFD5. + /// + public static readonly TColor PapayaWhip = ColorBuilder.FromRGBA(255, 239, 213, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFDAB9. + /// + public static readonly TColor PeachPuff = ColorBuilder.FromRGBA(255, 218, 185, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #CD853F. + /// + public static readonly TColor Peru = ColorBuilder.FromRGBA(205, 133, 63, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFC0CB. + /// + public static readonly TColor Pink = ColorBuilder.FromRGBA(255, 192, 203, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #DDA0DD. + /// + public static readonly TColor Plum = ColorBuilder.FromRGBA(221, 160, 221, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #B0E0E6. + /// + public static readonly TColor PowderBlue = ColorBuilder.FromRGBA(176, 224, 230, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #800080. + /// + public static readonly TColor Purple = ColorBuilder.FromRGBA(128, 0, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #663399. + /// + public static readonly TColor RebeccaPurple = ColorBuilder.FromRGBA(102, 51, 153, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF0000. + /// + public static readonly TColor Red = ColorBuilder.FromRGBA(255, 0, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #BC8F8F. + /// + public static readonly TColor RosyBrown = ColorBuilder.FromRGBA(188, 143, 143, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #4169E1. + /// + public static readonly TColor RoyalBlue = ColorBuilder.FromRGBA(65, 105, 225, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B4513. + /// + public static readonly TColor SaddleBrown = ColorBuilder.FromRGBA(139, 69, 19, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FA8072. + /// + public static readonly TColor Salmon = ColorBuilder.FromRGBA(250, 128, 114, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F4A460. + /// + public static readonly TColor SandyBrown = ColorBuilder.FromRGBA(244, 164, 96, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #2E8B57. + /// + public static readonly TColor SeaGreen = ColorBuilder.FromRGBA(46, 139, 87, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF5EE. + /// + public static readonly TColor SeaShell = ColorBuilder.FromRGBA(255, 245, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #A0522D. + /// + public static readonly TColor Sienna = ColorBuilder.FromRGBA(160, 82, 45, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #C0C0C0. + /// + public static readonly TColor Silver = ColorBuilder.FromRGBA(192, 192, 192, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #87CEEB. + /// + public static readonly TColor SkyBlue = ColorBuilder.FromRGBA(135, 206, 235, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #6A5ACD. + /// + public static readonly TColor SlateBlue = ColorBuilder.FromRGBA(106, 90, 205, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #708090. + /// + public static readonly TColor SlateGray = ColorBuilder.FromRGBA(112, 128, 144, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFAFA. + /// + public static readonly TColor Snow = ColorBuilder.FromRGBA(255, 250, 250, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FF7F. + /// + public static readonly TColor SpringGreen = ColorBuilder.FromRGBA(0, 255, 127, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #4682B4. + /// + public static readonly TColor SteelBlue = ColorBuilder.FromRGBA(70, 130, 180, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D2B48C. + /// + public static readonly TColor Tan = ColorBuilder.FromRGBA(210, 180, 140, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #008080. + /// + public static readonly TColor Teal = ColorBuilder.FromRGBA(0, 128, 128, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #D8BFD8. + /// + public static readonly TColor Thistle = ColorBuilder.FromRGBA(216, 191, 216, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF6347. + /// + public static readonly TColor Tomato = ColorBuilder.FromRGBA(255, 99, 71, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFFF. + /// + public static readonly TColor Transparent = ColorBuilder.FromRGBA(255, 255, 255, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #40E0D0. + /// + public static readonly TColor Turquoise = ColorBuilder.FromRGBA(64, 224, 208, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #EE82EE. + /// + public static readonly TColor Violet = ColorBuilder.FromRGBA(238, 130, 238, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5DEB3. + /// + public static readonly TColor Wheat = ColorBuilder.FromRGBA(245, 222, 179, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFFF. + /// + public static readonly TColor White = ColorBuilder.FromRGBA(255, 255, 255, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5F5F5. + /// + public static readonly TColor WhiteSmoke = ColorBuilder.FromRGBA(245, 245, 245, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFF00. + /// + public static readonly TColor Yellow = ColorBuilder.FromRGBA(255, 255, 0, 255); + + /// + /// Represents a matching the W3C definition that has an hex value of #9ACD32. + /// + public static readonly TColor YellowGreen = ColorBuilder.FromRGBA(154, 205, 50, 255); + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Colors/ColorDefinitionTests.cs b/tests/ImageSharp.Tests/Colors/ColorDefinitionTests.cs new file mode 100644 index 000000000..899ce4f77 --- /dev/null +++ b/tests/ImageSharp.Tests/Colors/ColorDefinitionTests.cs @@ -0,0 +1,38 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Tests +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Linq; + using System.Reflection; + + using ImageSharp.Colors.Spaces; + using Xunit; + public class ColorDefinitionTests + { + public static IEnumerable ColorNames => typeof(NamedColors).GetTypeInfo().GetFields().Select(x => new[] { x.Name }); + + [Theory] + [MemberData(nameof(ColorNames))] + public void AllColorsAreOnGenericAndBaseColor(string name) + { + FieldInfo generic = typeof(NamedColors).GetTypeInfo().GetField(name); + FieldInfo specific = typeof(Color).GetTypeInfo().GetField(name); + + Assert.NotNull(specific); + Assert.NotNull(generic); + Assert.True(specific.Attributes.HasFlag(FieldAttributes.Public), "specific must be public"); + Assert.True(specific.Attributes.HasFlag(FieldAttributes.Static), "specific must be static"); + Assert.True(generic.Attributes.HasFlag(FieldAttributes.Public), "generic must be public"); + Assert.True(generic.Attributes.HasFlag(FieldAttributes.Static), "generic must be static"); + Color expected = (Color)generic.GetValue(null); + Color actual = (Color)specific.GetValue(null); + Assert.Equal(expected, actual); + } + } +} diff --git a/tests/ImageSharp.Tests/Colors/ColorTests.cs b/tests/ImageSharp.Tests/Colors/ColorTests.cs index ec75ae6f7..312e66466 100644 --- a/tests/ImageSharp.Tests/Colors/ColorTests.cs +++ b/tests/ImageSharp.Tests/Colors/ColorTests.cs @@ -23,10 +23,10 @@ namespace ImageSharp.Tests { Color color1 = new Color(0, 0, 0); Color color2 = new Color(0, 0, 0, 1F); - Color color3 = new Color("#000"); - Color color4 = new Color("#000F"); - Color color5 = new Color("#000000"); - Color color6 = new Color("#000000FF"); + Color color3 = Color.FromHex("#000"); + Color color4 = Color.FromHex("#000F"); + Color color5 = Color.FromHex("#000000"); + Color color6 = Color.FromHex("#000000FF"); Assert.Equal(color1, color2); Assert.Equal(color1, color3); @@ -43,9 +43,9 @@ namespace ImageSharp.Tests { Color color1 = new Color(255, 0, 0, 255); Color color2 = new Color(0, 0, 0, 255); - Color color3 = new Color("#000"); - Color color4 = new Color("#000000"); - Color color5 = new Color("#FF000000"); + Color color3 = Color.FromHex("#000"); + Color color4 = Color.FromHex("#000000"); + Color color5 = Color.FromHex("#FF000000"); Assert.NotEqual(color1, color2); Assert.NotEqual(color1, color3); @@ -71,12 +71,6 @@ namespace ImageSharp.Tests Assert.Equal(Math.Round(.133f * 255), color2.B); Assert.Equal(255, color2.A); - Color color3 = new Color("#FF0000"); - Assert.Equal(255, color3.R); - Assert.Equal(0, color3.G); - Assert.Equal(0, color3.B); - Assert.Equal(255, color3.A); - Color color4 = new Color(new Vector3(1, .1f, .133f)); Assert.Equal(255, color4.R); Assert.Equal(Math.Round(.1f * 255), color4.G); diff --git a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs index a0bf2cf7a..46f667e70 100644 --- a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs +++ b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs @@ -91,17 +91,12 @@ namespace ImageSharp.Tests [WithBlankImages(16, 16, PixelTypes.All, ComponentOrder.Zyxw)] public void CopyToThenCopyFromWithOffset(TestImageProvider provider, ComponentOrder order) where TColor : struct, IPackedPixel, IEquatable - { using (Image destImage = new Image(8, 8)) { - TColor color; using (Image srcImage = provider.GetImage()) { - color = default(TColor); - color.PackFromBytes(255, 0, 0, 255); - - Fill(srcImage, new Rectangle(4, 4, 8, 8), color); + Fill(srcImage, new Rectangle(4, 4, 8, 8), NamedColors.Red); using (PixelAccessor srcPixels = srcImage.Lock()) { using (PixelArea area = new PixelArea(8, 8, order)) @@ -119,7 +114,7 @@ namespace ImageSharp.Tests provider.Utility.SourceFileOrDescription = order.ToString(); provider.Utility.SaveTestOutputFile(destImage, "bmp"); - using (Image expectedImage = new Image(8, 8).Fill(color)) + using (Image expectedImage = new Image(8, 8).Fill(NamedColors.Red)) { Assert.True(destImage.IsEquivalentTo(expectedImage)); }