diff --git a/src/ImageSharp/Color/Color.NamedColors.cs b/src/ImageSharp/Color/Color.NamedColors.cs
index 0575a3e99e..8eb3fbcaf7 100644
--- a/src/ImageSharp/Color/Color.NamedColors.cs
+++ b/src/ImageSharp/Color/Color.NamedColors.cs
@@ -1,6 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
+using System.Collections.Generic;
+
namespace SixLabors.ImageSharp
{
///
@@ -8,6 +11,8 @@ namespace SixLabors.ImageSharp
///
public readonly partial struct Color
{
+ private static readonly Lazy> NamedColorsLookupLazy = new Lazy>(CreateNamedColorsLookup, true);
+
///
/// Represents a matching the W3C definition that has an hex value of #F0F8FF.
///
@@ -111,7 +116,7 @@ namespace SixLabors.ImageSharp
///
/// Represents a matching the W3C definition that has an hex value of #00FFFF.
///
- public static readonly Color Cyan = FromRgba(0, 255, 255, 255);
+ public static readonly Color Cyan = Aqua;
///
/// Represents a matching the W3C definition that has an hex value of #00008B.
@@ -138,6 +143,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color DarkGreen = FromRgba(0, 100, 0, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #A9A9A9.
+ ///
+ public static readonly Color DarkGrey = DarkGray;
+
///
/// Represents a matching the W3C definition that has an hex value of #BDB76B.
///
@@ -188,6 +198,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color DarkSlateGray = FromRgba(47, 79, 79, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #2F4F4F.
+ ///
+ public static readonly Color DarkSlateGrey = DarkSlateGray;
+
///
/// Represents a matching the W3C definition that has an hex value of #00CED1.
///
@@ -213,6 +228,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color DimGray = FromRgba(105, 105, 105, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #696969.
+ ///
+ public static readonly Color DimGrey = DimGray;
+
///
/// Represents a matching the W3C definition that has an hex value of #1E90FF.
///
@@ -273,6 +293,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color GreenYellow = FromRgba(173, 255, 47, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #808080.
+ ///
+ public static readonly Color Grey = Gray;
+
///
/// Represents a matching the W3C definition that has an hex value of #F0FFF0.
///
@@ -353,6 +378,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color LightGreen = FromRgba(144, 238, 144, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #D3D3D3.
+ ///
+ public static readonly Color LightGrey = LightGray;
+
///
/// Represents a matching the W3C definition that has an hex value of #FFB6C1.
///
@@ -378,6 +408,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color LightSlateGray = FromRgba(119, 136, 153, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #778899.
+ ///
+ public static readonly Color LightSlateGrey = LightSlateGray;
+
///
/// Represents a matching the W3C definition that has an hex value of #B0C4DE.
///
@@ -406,7 +441,7 @@ namespace SixLabors.ImageSharp
///
/// Represents a matching the W3C definition that has an hex value of #FF00FF.
///
- public static readonly Color Magenta = FromRgba(255, 0, 255, 255);
+ public static readonly Color Magenta = Fuchsia;
///
/// Represents a matching the W3C definition that has an hex value of #800000.
@@ -643,6 +678,11 @@ namespace SixLabors.ImageSharp
///
public static readonly Color SlateGray = FromRgba(112, 128, 144, 255);
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #708090.
+ ///
+ public static readonly Color SlateGrey = SlateGray;
+
///
/// Represents a matching the W3C definition that has an hex value of #FFFAFA.
///
@@ -717,5 +757,161 @@ namespace SixLabors.ImageSharp
/// Represents a matching the W3C definition that has an hex value of #9ACD32.
///
public static readonly Color YellowGreen = FromRgba(154, 205, 50, 255);
+
+ private static Dictionary CreateNamedColorsLookup()
+ {
+ return new Dictionary(StringComparer.OrdinalIgnoreCase)
+ {
+ { nameof(AliceBlue), AliceBlue },
+ { nameof(AntiqueWhite), AntiqueWhite },
+ { nameof(Aqua), Aqua },
+ { nameof(Aquamarine), Aquamarine },
+ { nameof(Azure), Azure },
+ { nameof(Beige), Beige },
+ { nameof(Bisque), Bisque },
+ { nameof(Black), Black },
+ { nameof(BlanchedAlmond), BlanchedAlmond },
+ { nameof(Blue), Blue },
+ { nameof(BlueViolet), BlueViolet },
+ { nameof(Brown), Brown },
+ { nameof(BurlyWood), BurlyWood },
+ { nameof(CadetBlue), CadetBlue },
+ { nameof(Chartreuse), Chartreuse },
+ { nameof(Chocolate), Chocolate },
+ { nameof(Coral), Coral },
+ { nameof(CornflowerBlue), CornflowerBlue },
+ { nameof(Cornsilk), Cornsilk },
+ { nameof(Crimson), Crimson },
+ { nameof(Cyan), Cyan },
+ { nameof(DarkBlue), DarkBlue },
+ { nameof(DarkCyan), DarkCyan },
+ { nameof(DarkGoldenrod), DarkGoldenrod },
+ { nameof(DarkGray), DarkGray },
+ { nameof(DarkGreen), DarkGreen },
+ { nameof(DarkGrey), DarkGrey },
+ { nameof(DarkKhaki), DarkKhaki },
+ { nameof(DarkMagenta), DarkMagenta },
+ { nameof(DarkOliveGreen), DarkOliveGreen },
+ { nameof(DarkOrange), DarkOrange },
+ { nameof(DarkOrchid), DarkOrchid },
+ { nameof(DarkRed), DarkRed },
+ { nameof(DarkSalmon), DarkSalmon },
+ { nameof(DarkSeaGreen), DarkSeaGreen },
+ { nameof(DarkSlateBlue), DarkSlateBlue },
+ { nameof(DarkSlateGray), DarkSlateGray },
+ { nameof(DarkSlateGrey), DarkSlateGrey },
+ { nameof(DarkTurquoise), DarkTurquoise },
+ { nameof(DarkViolet), DarkViolet },
+ { nameof(DeepPink), DeepPink },
+ { nameof(DeepSkyBlue), DeepSkyBlue },
+ { nameof(DimGray), DimGray },
+ { nameof(DimGrey), DimGrey },
+ { nameof(DodgerBlue), DodgerBlue },
+ { nameof(Firebrick), Firebrick },
+ { nameof(FloralWhite), FloralWhite },
+ { nameof(ForestGreen), ForestGreen },
+ { nameof(Fuchsia), Fuchsia },
+ { nameof(Gainsboro), Gainsboro },
+ { nameof(GhostWhite), GhostWhite },
+ { nameof(Gold), Gold },
+ { nameof(Goldenrod), Goldenrod },
+ { nameof(Gray), Gray },
+ { nameof(Green), Green },
+ { nameof(GreenYellow), GreenYellow },
+ { nameof(Grey), Grey },
+ { nameof(Honeydew), Honeydew },
+ { nameof(HotPink), HotPink },
+ { nameof(IndianRed), IndianRed },
+ { nameof(Indigo), Indigo },
+ { nameof(Ivory), Ivory },
+ { nameof(Khaki), Khaki },
+ { nameof(Lavender), Lavender },
+ { nameof(LavenderBlush), LavenderBlush },
+ { nameof(LawnGreen), LawnGreen },
+ { nameof(LemonChiffon), LemonChiffon },
+ { nameof(LightBlue), LightBlue },
+ { nameof(LightCoral), LightCoral },
+ { nameof(LightCyan), LightCyan },
+ { nameof(LightGoldenrodYellow), LightGoldenrodYellow },
+ { nameof(LightGray), LightGray },
+ { nameof(LightGreen), LightGreen },
+ { nameof(LightGrey), LightGrey },
+ { nameof(LightPink), LightPink },
+ { nameof(LightSalmon), LightSalmon },
+ { nameof(LightSeaGreen), LightSeaGreen },
+ { nameof(LightSkyBlue), LightSkyBlue },
+ { nameof(LightSlateGray), LightSlateGray },
+ { nameof(LightSlateGrey), LightSlateGrey },
+ { nameof(LightSteelBlue), LightSteelBlue },
+ { nameof(LightYellow), LightYellow },
+ { nameof(Lime), Lime },
+ { nameof(LimeGreen), LimeGreen },
+ { nameof(Linen), Linen },
+ { nameof(Magenta), Magenta },
+ { nameof(Maroon), Maroon },
+ { nameof(MediumAquamarine), MediumAquamarine },
+ { nameof(MediumBlue), MediumBlue },
+ { nameof(MediumOrchid), MediumOrchid },
+ { nameof(MediumPurple), MediumPurple },
+ { nameof(MediumSeaGreen), MediumSeaGreen },
+ { nameof(MediumSlateBlue), MediumSlateBlue },
+ { nameof(MediumSpringGreen), MediumSpringGreen },
+ { nameof(MediumTurquoise), MediumTurquoise },
+ { nameof(MediumVioletRed), MediumVioletRed },
+ { nameof(MidnightBlue), MidnightBlue },
+ { nameof(MintCream), MintCream },
+ { nameof(MistyRose), MistyRose },
+ { nameof(Moccasin), Moccasin },
+ { nameof(NavajoWhite), NavajoWhite },
+ { nameof(Navy), Navy },
+ { nameof(OldLace), OldLace },
+ { nameof(Olive), Olive },
+ { nameof(OliveDrab), OliveDrab },
+ { nameof(Orange), Orange },
+ { nameof(OrangeRed), OrangeRed },
+ { nameof(Orchid), Orchid },
+ { nameof(PaleGoldenrod), PaleGoldenrod },
+ { nameof(PaleGreen), PaleGreen },
+ { nameof(PaleTurquoise), PaleTurquoise },
+ { nameof(PaleVioletRed), PaleVioletRed },
+ { nameof(PapayaWhip), PapayaWhip },
+ { nameof(PeachPuff), PeachPuff },
+ { nameof(Peru), Peru },
+ { nameof(Pink), Pink },
+ { nameof(Plum), Plum },
+ { nameof(PowderBlue), PowderBlue },
+ { nameof(Purple), Purple },
+ { nameof(RebeccaPurple), RebeccaPurple },
+ { nameof(Red), Red },
+ { nameof(RosyBrown), RosyBrown },
+ { nameof(RoyalBlue), RoyalBlue },
+ { nameof(SaddleBrown), SaddleBrown },
+ { nameof(Salmon), Salmon },
+ { nameof(SandyBrown), SandyBrown },
+ { nameof(SeaGreen), SeaGreen },
+ { nameof(SeaShell), SeaShell },
+ { nameof(Sienna), Sienna },
+ { nameof(Silver), Silver },
+ { nameof(SkyBlue), SkyBlue },
+ { nameof(SlateBlue), SlateBlue },
+ { nameof(SlateGray), SlateGray },
+ { nameof(SlateGrey), SlateGrey },
+ { nameof(Snow), Snow },
+ { nameof(SpringGreen), SpringGreen },
+ { nameof(SteelBlue), SteelBlue },
+ { nameof(Tan), Tan },
+ { nameof(Teal), Teal },
+ { nameof(Thistle), Thistle },
+ { nameof(Tomato), Tomato },
+ { nameof(Transparent), Transparent },
+ { nameof(Turquoise), Turquoise },
+ { nameof(Violet), Violet },
+ { nameof(Wheat), Wheat },
+ { nameof(White), White },
+ { nameof(WhiteSmoke), WhiteSmoke },
+ { nameof(Yellow), Yellow },
+ { nameof(YellowGreen), YellowGreen }
+ };
+ }
}
}
diff --git a/src/ImageSharp/Color/Color.WernerPalette.cs b/src/ImageSharp/Color/Color.WernerPalette.cs
index 768fe065cd..2948b4c52c 100644
--- a/src/ImageSharp/Color/Color.WernerPalette.cs
+++ b/src/ImageSharp/Color/Color.WernerPalette.cs
@@ -20,116 +20,116 @@ namespace SixLabors.ImageSharp
private static Color[] CreateWernerPalette() => new[]
{
- FromHex("#f1e9cd"),
- FromHex("#f2e7cf"),
- FromHex("#ece6d0"),
- FromHex("#f2eacc"),
- FromHex("#f3e9ca"),
- FromHex("#f2ebcd"),
- FromHex("#e6e1c9"),
- FromHex("#e2ddc6"),
- FromHex("#cbc8b7"),
- FromHex("#bfbbb0"),
- FromHex("#bebeb3"),
- FromHex("#b7b5ac"),
- FromHex("#bab191"),
- FromHex("#9c9d9a"),
- FromHex("#8a8d84"),
- FromHex("#5b5c61"),
- FromHex("#555152"),
- FromHex("#413f44"),
- FromHex("#454445"),
- FromHex("#423937"),
- FromHex("#433635"),
- FromHex("#252024"),
- FromHex("#241f20"),
- FromHex("#281f3f"),
- FromHex("#1c1949"),
- FromHex("#4f638d"),
- FromHex("#383867"),
- FromHex("#5c6b8f"),
- FromHex("#657abb"),
- FromHex("#6f88af"),
- FromHex("#7994b5"),
- FromHex("#6fb5a8"),
- FromHex("#719ba2"),
- FromHex("#8aa1a6"),
- FromHex("#d0d5d3"),
- FromHex("#8590ae"),
- FromHex("#3a2f52"),
- FromHex("#39334a"),
- FromHex("#6c6d94"),
- FromHex("#584c77"),
- FromHex("#533552"),
- FromHex("#463759"),
- FromHex("#bfbac0"),
- FromHex("#77747f"),
- FromHex("#4a475c"),
- FromHex("#b8bfaf"),
- FromHex("#b2b599"),
- FromHex("#979c84"),
- FromHex("#5d6161"),
- FromHex("#61ac86"),
- FromHex("#a4b6a7"),
- FromHex("#adba98"),
- FromHex("#93b778"),
- FromHex("#7d8c55"),
- FromHex("#33431e"),
- FromHex("#7c8635"),
- FromHex("#8e9849"),
- FromHex("#c2c190"),
- FromHex("#67765b"),
- FromHex("#ab924b"),
- FromHex("#c8c76f"),
- FromHex("#ccc050"),
- FromHex("#ebdd99"),
- FromHex("#ab9649"),
- FromHex("#dbc364"),
- FromHex("#e6d058"),
- FromHex("#ead665"),
- FromHex("#d09b2c"),
- FromHex("#a36629"),
- FromHex("#a77d35"),
- FromHex("#f0d696"),
- FromHex("#d7c485"),
- FromHex("#f1d28c"),
- FromHex("#efcc83"),
- FromHex("#f3daa7"),
- FromHex("#dfa837"),
- FromHex("#ebbc71"),
- FromHex("#d17c3f"),
- FromHex("#92462f"),
- FromHex("#be7249"),
- FromHex("#bb603c"),
- FromHex("#c76b4a"),
- FromHex("#a75536"),
- FromHex("#b63e36"),
- FromHex("#b5493a"),
- FromHex("#cd6d57"),
- FromHex("#711518"),
- FromHex("#e9c49d"),
- FromHex("#eedac3"),
- FromHex("#eecfbf"),
- FromHex("#ce536b"),
- FromHex("#b74a70"),
- FromHex("#b7757c"),
- FromHex("#612741"),
- FromHex("#7a4848"),
- FromHex("#3f3033"),
- FromHex("#8d746f"),
- FromHex("#4d3635"),
- FromHex("#6e3b31"),
- FromHex("#864735"),
- FromHex("#553d3a"),
- FromHex("#613936"),
- FromHex("#7a4b3a"),
- FromHex("#946943"),
- FromHex("#c39e6d"),
- FromHex("#513e32"),
- FromHex("#8b7859"),
- FromHex("#9b856b"),
- FromHex("#766051"),
- FromHex("#453b32")
+ ParseHex("#f1e9cd"),
+ ParseHex("#f2e7cf"),
+ ParseHex("#ece6d0"),
+ ParseHex("#f2eacc"),
+ ParseHex("#f3e9ca"),
+ ParseHex("#f2ebcd"),
+ ParseHex("#e6e1c9"),
+ ParseHex("#e2ddc6"),
+ ParseHex("#cbc8b7"),
+ ParseHex("#bfbbb0"),
+ ParseHex("#bebeb3"),
+ ParseHex("#b7b5ac"),
+ ParseHex("#bab191"),
+ ParseHex("#9c9d9a"),
+ ParseHex("#8a8d84"),
+ ParseHex("#5b5c61"),
+ ParseHex("#555152"),
+ ParseHex("#413f44"),
+ ParseHex("#454445"),
+ ParseHex("#423937"),
+ ParseHex("#433635"),
+ ParseHex("#252024"),
+ ParseHex("#241f20"),
+ ParseHex("#281f3f"),
+ ParseHex("#1c1949"),
+ ParseHex("#4f638d"),
+ ParseHex("#383867"),
+ ParseHex("#5c6b8f"),
+ ParseHex("#657abb"),
+ ParseHex("#6f88af"),
+ ParseHex("#7994b5"),
+ ParseHex("#6fb5a8"),
+ ParseHex("#719ba2"),
+ ParseHex("#8aa1a6"),
+ ParseHex("#d0d5d3"),
+ ParseHex("#8590ae"),
+ ParseHex("#3a2f52"),
+ ParseHex("#39334a"),
+ ParseHex("#6c6d94"),
+ ParseHex("#584c77"),
+ ParseHex("#533552"),
+ ParseHex("#463759"),
+ ParseHex("#bfbac0"),
+ ParseHex("#77747f"),
+ ParseHex("#4a475c"),
+ ParseHex("#b8bfaf"),
+ ParseHex("#b2b599"),
+ ParseHex("#979c84"),
+ ParseHex("#5d6161"),
+ ParseHex("#61ac86"),
+ ParseHex("#a4b6a7"),
+ ParseHex("#adba98"),
+ ParseHex("#93b778"),
+ ParseHex("#7d8c55"),
+ ParseHex("#33431e"),
+ ParseHex("#7c8635"),
+ ParseHex("#8e9849"),
+ ParseHex("#c2c190"),
+ ParseHex("#67765b"),
+ ParseHex("#ab924b"),
+ ParseHex("#c8c76f"),
+ ParseHex("#ccc050"),
+ ParseHex("#ebdd99"),
+ ParseHex("#ab9649"),
+ ParseHex("#dbc364"),
+ ParseHex("#e6d058"),
+ ParseHex("#ead665"),
+ ParseHex("#d09b2c"),
+ ParseHex("#a36629"),
+ ParseHex("#a77d35"),
+ ParseHex("#f0d696"),
+ ParseHex("#d7c485"),
+ ParseHex("#f1d28c"),
+ ParseHex("#efcc83"),
+ ParseHex("#f3daa7"),
+ ParseHex("#dfa837"),
+ ParseHex("#ebbc71"),
+ ParseHex("#d17c3f"),
+ ParseHex("#92462f"),
+ ParseHex("#be7249"),
+ ParseHex("#bb603c"),
+ ParseHex("#c76b4a"),
+ ParseHex("#a75536"),
+ ParseHex("#b63e36"),
+ ParseHex("#b5493a"),
+ ParseHex("#cd6d57"),
+ ParseHex("#711518"),
+ ParseHex("#e9c49d"),
+ ParseHex("#eedac3"),
+ ParseHex("#eecfbf"),
+ ParseHex("#ce536b"),
+ ParseHex("#b74a70"),
+ ParseHex("#b7757c"),
+ ParseHex("#612741"),
+ ParseHex("#7a4848"),
+ ParseHex("#3f3033"),
+ ParseHex("#8d746f"),
+ ParseHex("#4d3635"),
+ ParseHex("#6e3b31"),
+ ParseHex("#864735"),
+ ParseHex("#553d3a"),
+ ParseHex("#613936"),
+ ParseHex("#7a4b3a"),
+ ParseHex("#946943"),
+ ParseHex("#c39e6d"),
+ ParseHex("#513e32"),
+ ParseHex("#8b7859"),
+ ParseHex("#9b856b"),
+ ParseHex("#766051"),
+ ParseHex("#453b32")
};
}
-}
\ No newline at end of file
+}
diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs
index 5fad7a8e39..4a50ae073a 100644
--- a/src/ImageSharp/Color/Color.cs
+++ b/src/ImageSharp/Color/Color.cs
@@ -95,21 +95,93 @@ namespace SixLabors.ImageSharp
public static Color FromRgb(byte r, byte g, byte b) => new Color(r, g, b);
///
- /// Creates a new instance from the string representing a color in hexadecimal form.
+ /// Creates a new instance of the struct
+ /// from the given hexadecimal string.
///
///
/// 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 hex string.
+ ///
+ /// The .
+ ///
[MethodImpl(InliningOptions.ShortMethod)]
- public static Color FromHex(string hex)
+ public static Color ParseHex(string hex)
{
- var rgba = Rgba32.FromHex(hex);
+ var rgba = Rgba32.ParseHex(hex);
return new Color(rgba);
}
+ ///
+ /// Attempts to creates a new instance of the struct
+ /// from the given hexadecimal string.
+ ///
+ ///
+ /// The hexadecimal representation of the combined color components arranged
+ /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
+ ///
+ /// When this method returns, contains the equivalent of the hexadecimal input.
+ ///
+ /// The .
+ ///
+ [MethodImpl(InliningOptions.ShortMethod)]
+ public static bool TryParseHex(string hex, out Color result)
+ {
+ result = default;
+
+ if (Rgba32.TryParseHex(hex, out Rgba32 rgba))
+ {
+ result = new Color(rgba);
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Creates a new instance of the struct
+ /// from the given input string.
+ ///
+ ///
+ /// The name of the color or the hexadecimal representation of the combined color components arranged
+ /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
+ ///
+ ///
+ /// The .
+ ///
+ public static Color Parse(string input)
+ {
+ if (!TryParse(input, out Color color))
+ {
+ throw new ArgumentException("Input string is not in the correct format.", nameof(input));
+ }
+
+ return color;
+ }
+
+ ///
+ /// Attempts to creates a new instance of the struct
+ /// from the given input string.
+ ///
+ ///
+ /// The name of the color or the hexadecimal representation of the combined color components arranged
+ /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
+ ///
+ /// When this method returns, contains the equivalent of the hexadecimal input.
+ ///
+ /// The .
+ ///
+ public static bool TryParse(string input, out Color result)
+ {
+ if (NamedColorsLookupLazy.Value.TryGetValue(input, out result))
+ {
+ return true;
+ }
+
+ return TryParseHex(input, out result);
+ }
+
///
/// Alters the alpha channel of the color, returning a new instance.
///
@@ -117,7 +189,7 @@ namespace SixLabors.ImageSharp
/// The color having it's alpha channel altered.
public Color WithAlpha(float alpha)
{
- Vector4 v = (Vector4)this;
+ var v = (Vector4)this;
v.W = alpha;
return new Color(v);
}
diff --git a/src/ImageSharp/PixelFormats/ColorConstants.cs b/src/ImageSharp/PixelFormats/ColorConstants.cs
index 14df385697..40bbdb3b09 100644
--- a/src/ImageSharp/PixelFormats/ColorConstants.cs
+++ b/src/ImageSharp/PixelFormats/ColorConstants.cs
@@ -163,116 +163,116 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32[] WernerColors =
{
- Rgba32.FromHex("#f1e9cd"),
- Rgba32.FromHex("#f2e7cf"),
- Rgba32.FromHex("#ece6d0"),
- Rgba32.FromHex("#f2eacc"),
- Rgba32.FromHex("#f3e9ca"),
- Rgba32.FromHex("#f2ebcd"),
- Rgba32.FromHex("#e6e1c9"),
- Rgba32.FromHex("#e2ddc6"),
- Rgba32.FromHex("#cbc8b7"),
- Rgba32.FromHex("#bfbbb0"),
- Rgba32.FromHex("#bebeb3"),
- Rgba32.FromHex("#b7b5ac"),
- Rgba32.FromHex("#bab191"),
- Rgba32.FromHex("#9c9d9a"),
- Rgba32.FromHex("#8a8d84"),
- Rgba32.FromHex("#5b5c61"),
- Rgba32.FromHex("#555152"),
- Rgba32.FromHex("#413f44"),
- Rgba32.FromHex("#454445"),
- Rgba32.FromHex("#423937"),
- Rgba32.FromHex("#433635"),
- Rgba32.FromHex("#252024"),
- Rgba32.FromHex("#241f20"),
- Rgba32.FromHex("#281f3f"),
- Rgba32.FromHex("#1c1949"),
- Rgba32.FromHex("#4f638d"),
- Rgba32.FromHex("#383867"),
- Rgba32.FromHex("#5c6b8f"),
- Rgba32.FromHex("#657abb"),
- Rgba32.FromHex("#6f88af"),
- Rgba32.FromHex("#7994b5"),
- Rgba32.FromHex("#6fb5a8"),
- Rgba32.FromHex("#719ba2"),
- Rgba32.FromHex("#8aa1a6"),
- Rgba32.FromHex("#d0d5d3"),
- Rgba32.FromHex("#8590ae"),
- Rgba32.FromHex("#3a2f52"),
- Rgba32.FromHex("#39334a"),
- Rgba32.FromHex("#6c6d94"),
- Rgba32.FromHex("#584c77"),
- Rgba32.FromHex("#533552"),
- Rgba32.FromHex("#463759"),
- Rgba32.FromHex("#bfbac0"),
- Rgba32.FromHex("#77747f"),
- Rgba32.FromHex("#4a475c"),
- Rgba32.FromHex("#b8bfaf"),
- Rgba32.FromHex("#b2b599"),
- Rgba32.FromHex("#979c84"),
- Rgba32.FromHex("#5d6161"),
- Rgba32.FromHex("#61ac86"),
- Rgba32.FromHex("#a4b6a7"),
- Rgba32.FromHex("#adba98"),
- Rgba32.FromHex("#93b778"),
- Rgba32.FromHex("#7d8c55"),
- Rgba32.FromHex("#33431e"),
- Rgba32.FromHex("#7c8635"),
- Rgba32.FromHex("#8e9849"),
- Rgba32.FromHex("#c2c190"),
- Rgba32.FromHex("#67765b"),
- Rgba32.FromHex("#ab924b"),
- Rgba32.FromHex("#c8c76f"),
- Rgba32.FromHex("#ccc050"),
- Rgba32.FromHex("#ebdd99"),
- Rgba32.FromHex("#ab9649"),
- Rgba32.FromHex("#dbc364"),
- Rgba32.FromHex("#e6d058"),
- Rgba32.FromHex("#ead665"),
- Rgba32.FromHex("#d09b2c"),
- Rgba32.FromHex("#a36629"),
- Rgba32.FromHex("#a77d35"),
- Rgba32.FromHex("#f0d696"),
- Rgba32.FromHex("#d7c485"),
- Rgba32.FromHex("#f1d28c"),
- Rgba32.FromHex("#efcc83"),
- Rgba32.FromHex("#f3daa7"),
- Rgba32.FromHex("#dfa837"),
- Rgba32.FromHex("#ebbc71"),
- Rgba32.FromHex("#d17c3f"),
- Rgba32.FromHex("#92462f"),
- Rgba32.FromHex("#be7249"),
- Rgba32.FromHex("#bb603c"),
- Rgba32.FromHex("#c76b4a"),
- Rgba32.FromHex("#a75536"),
- Rgba32.FromHex("#b63e36"),
- Rgba32.FromHex("#b5493a"),
- Rgba32.FromHex("#cd6d57"),
- Rgba32.FromHex("#711518"),
- Rgba32.FromHex("#e9c49d"),
- Rgba32.FromHex("#eedac3"),
- Rgba32.FromHex("#eecfbf"),
- Rgba32.FromHex("#ce536b"),
- Rgba32.FromHex("#b74a70"),
- Rgba32.FromHex("#b7757c"),
- Rgba32.FromHex("#612741"),
- Rgba32.FromHex("#7a4848"),
- Rgba32.FromHex("#3f3033"),
- Rgba32.FromHex("#8d746f"),
- Rgba32.FromHex("#4d3635"),
- Rgba32.FromHex("#6e3b31"),
- Rgba32.FromHex("#864735"),
- Rgba32.FromHex("#553d3a"),
- Rgba32.FromHex("#613936"),
- Rgba32.FromHex("#7a4b3a"),
- Rgba32.FromHex("#946943"),
- Rgba32.FromHex("#c39e6d"),
- Rgba32.FromHex("#513e32"),
- Rgba32.FromHex("#8b7859"),
- Rgba32.FromHex("#9b856b"),
- Rgba32.FromHex("#766051"),
- Rgba32.FromHex("#453b32")
+ Rgba32.ParseHex("#f1e9cd"),
+ Rgba32.ParseHex("#f2e7cf"),
+ Rgba32.ParseHex("#ece6d0"),
+ Rgba32.ParseHex("#f2eacc"),
+ Rgba32.ParseHex("#f3e9ca"),
+ Rgba32.ParseHex("#f2ebcd"),
+ Rgba32.ParseHex("#e6e1c9"),
+ Rgba32.ParseHex("#e2ddc6"),
+ Rgba32.ParseHex("#cbc8b7"),
+ Rgba32.ParseHex("#bfbbb0"),
+ Rgba32.ParseHex("#bebeb3"),
+ Rgba32.ParseHex("#b7b5ac"),
+ Rgba32.ParseHex("#bab191"),
+ Rgba32.ParseHex("#9c9d9a"),
+ Rgba32.ParseHex("#8a8d84"),
+ Rgba32.ParseHex("#5b5c61"),
+ Rgba32.ParseHex("#555152"),
+ Rgba32.ParseHex("#413f44"),
+ Rgba32.ParseHex("#454445"),
+ Rgba32.ParseHex("#423937"),
+ Rgba32.ParseHex("#433635"),
+ Rgba32.ParseHex("#252024"),
+ Rgba32.ParseHex("#241f20"),
+ Rgba32.ParseHex("#281f3f"),
+ Rgba32.ParseHex("#1c1949"),
+ Rgba32.ParseHex("#4f638d"),
+ Rgba32.ParseHex("#383867"),
+ Rgba32.ParseHex("#5c6b8f"),
+ Rgba32.ParseHex("#657abb"),
+ Rgba32.ParseHex("#6f88af"),
+ Rgba32.ParseHex("#7994b5"),
+ Rgba32.ParseHex("#6fb5a8"),
+ Rgba32.ParseHex("#719ba2"),
+ Rgba32.ParseHex("#8aa1a6"),
+ Rgba32.ParseHex("#d0d5d3"),
+ Rgba32.ParseHex("#8590ae"),
+ Rgba32.ParseHex("#3a2f52"),
+ Rgba32.ParseHex("#39334a"),
+ Rgba32.ParseHex("#6c6d94"),
+ Rgba32.ParseHex("#584c77"),
+ Rgba32.ParseHex("#533552"),
+ Rgba32.ParseHex("#463759"),
+ Rgba32.ParseHex("#bfbac0"),
+ Rgba32.ParseHex("#77747f"),
+ Rgba32.ParseHex("#4a475c"),
+ Rgba32.ParseHex("#b8bfaf"),
+ Rgba32.ParseHex("#b2b599"),
+ Rgba32.ParseHex("#979c84"),
+ Rgba32.ParseHex("#5d6161"),
+ Rgba32.ParseHex("#61ac86"),
+ Rgba32.ParseHex("#a4b6a7"),
+ Rgba32.ParseHex("#adba98"),
+ Rgba32.ParseHex("#93b778"),
+ Rgba32.ParseHex("#7d8c55"),
+ Rgba32.ParseHex("#33431e"),
+ Rgba32.ParseHex("#7c8635"),
+ Rgba32.ParseHex("#8e9849"),
+ Rgba32.ParseHex("#c2c190"),
+ Rgba32.ParseHex("#67765b"),
+ Rgba32.ParseHex("#ab924b"),
+ Rgba32.ParseHex("#c8c76f"),
+ Rgba32.ParseHex("#ccc050"),
+ Rgba32.ParseHex("#ebdd99"),
+ Rgba32.ParseHex("#ab9649"),
+ Rgba32.ParseHex("#dbc364"),
+ Rgba32.ParseHex("#e6d058"),
+ Rgba32.ParseHex("#ead665"),
+ Rgba32.ParseHex("#d09b2c"),
+ Rgba32.ParseHex("#a36629"),
+ Rgba32.ParseHex("#a77d35"),
+ Rgba32.ParseHex("#f0d696"),
+ Rgba32.ParseHex("#d7c485"),
+ Rgba32.ParseHex("#f1d28c"),
+ Rgba32.ParseHex("#efcc83"),
+ Rgba32.ParseHex("#f3daa7"),
+ Rgba32.ParseHex("#dfa837"),
+ Rgba32.ParseHex("#ebbc71"),
+ Rgba32.ParseHex("#d17c3f"),
+ Rgba32.ParseHex("#92462f"),
+ Rgba32.ParseHex("#be7249"),
+ Rgba32.ParseHex("#bb603c"),
+ Rgba32.ParseHex("#c76b4a"),
+ Rgba32.ParseHex("#a75536"),
+ Rgba32.ParseHex("#b63e36"),
+ Rgba32.ParseHex("#b5493a"),
+ Rgba32.ParseHex("#cd6d57"),
+ Rgba32.ParseHex("#711518"),
+ Rgba32.ParseHex("#e9c49d"),
+ Rgba32.ParseHex("#eedac3"),
+ Rgba32.ParseHex("#eecfbf"),
+ Rgba32.ParseHex("#ce536b"),
+ Rgba32.ParseHex("#b74a70"),
+ Rgba32.ParseHex("#b7757c"),
+ Rgba32.ParseHex("#612741"),
+ Rgba32.ParseHex("#7a4848"),
+ Rgba32.ParseHex("#3f3033"),
+ Rgba32.ParseHex("#8d746f"),
+ Rgba32.ParseHex("#4d3635"),
+ Rgba32.ParseHex("#6e3b31"),
+ Rgba32.ParseHex("#864735"),
+ Rgba32.ParseHex("#553d3a"),
+ Rgba32.ParseHex("#613936"),
+ Rgba32.ParseHex("#7a4b3a"),
+ Rgba32.ParseHex("#946943"),
+ Rgba32.ParseHex("#c39e6d"),
+ Rgba32.ParseHex("#513e32"),
+ Rgba32.ParseHex("#8b7859"),
+ Rgba32.ParseHex("#9b856b"),
+ Rgba32.ParseHex("#766051"),
+ Rgba32.ParseHex("#453b32")
};
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.Definitions.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.Definitions.cs
index f9cc3256cd..deb7ff4f4d 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.Definitions.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.Definitions.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors and contributors.
+// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.PixelFormats
@@ -138,6 +138,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 DarkGreen = Color.DarkGreen;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #A9A9A9.
+ ///
+ public static readonly Rgba32 DarkGrey = Color.DarkGrey;
+
///
/// Represents a matching the W3C definition that has an hex value of #BDB76B.
///
@@ -188,6 +193,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 DarkSlateGray = Color.DarkSlateGray;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #2F4F4F.
+ ///
+ public static readonly Rgba32 DarkSlateGrey = Color.DarkSlateGrey;
+
///
/// Represents a matching the W3C definition that has an hex value of #00CED1.
///
@@ -213,6 +223,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 DimGray = Color.DimGray;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #696969.
+ ///
+ public static readonly Rgba32 DimGrey = Color.DimGrey;
+
///
/// Represents a matching the W3C definition that has an hex value of #1E90FF.
///
@@ -273,6 +288,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 GreenYellow = Color.GreenYellow;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #808080.
+ ///
+ public static readonly Rgba32 Grey = Color.Grey;
+
///
/// Represents a matching the W3C definition that has an hex value of #F0FFF0.
///
@@ -353,6 +373,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 LightGreen = Color.LightGreen;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #D3D3D3.
+ ///
+ public static readonly Rgba32 LightGrey = Color.LightGrey;
+
///
/// Represents a matching the W3C definition that has an hex value of #FFB6C1.
///
@@ -378,6 +403,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 LightSlateGray = Color.LightSlateGray;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #778899.
+ ///
+ public static readonly Rgba32 LightSlateGrey = Color.LightSlateGrey;
+
///
/// Represents a matching the W3C definition that has an hex value of #B0C4DE.
///
@@ -643,6 +673,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 SlateGray = Color.SlateGray;
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #708090.
+ ///
+ public static readonly Rgba32 SlateGrey = Color.SlateGrey;
+
///
/// Represents a matching the W3C definition that has an hex value of #FFFAFA.
///
@@ -718,4 +753,4 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public static readonly Rgba32 YellowGreen = Color.YellowGreen;
}
-}
\ No newline at end of file
+}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
index 10631e2cf9..c7d4410935 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
@@ -230,7 +230,8 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rgba32 left, Rgba32 right) => !left.Equals(right);
///
- /// Creates a new instance of the struct.
+ /// Creates a new instance of the struct
+ /// from the given hexadecimal string.
///
///
/// The hexadecimal representation of the combined color components arranged
@@ -239,19 +240,45 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The .
///
- public static Rgba32 FromHex(string hex)
+ [MethodImpl(InliningOptions.ShortMethod)]
+ public static Rgba32 ParseHex(string hex)
{
+ if (!TryParseHex(hex, out Rgba32 rgba))
+ {
+ throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex));
+ }
+
+ return rgba;
+ }
+
+ ///
+ /// Attempts to creates a new instance of the struct
+ /// from the given hexadecimal string.
+ ///
+ ///
+ /// The hexadecimal representation of the combined color components arranged
+ /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
+ ///
+ /// When this method returns, contains the equivalent of the hexadecimal input.
+ ///
+ /// The .
+ ///
+ [MethodImpl(InliningOptions.ShortMethod)]
+ public static bool TryParseHex(string hex, out Rgba32 result)
+ {
+ result = default;
Guard.NotNullOrWhiteSpace(hex, nameof(hex));
hex = ToRgbaHex(hex);
if (hex is null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint packedValue))
{
- throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex));
+ return false;
}
packedValue = BinaryPrimitives.ReverseEndianness(packedValue);
- return Unsafe.As(ref packedValue);
+ result = Unsafe.As(ref packedValue);
+ return true;
}
///
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
index 67f09f3a5d..89c5f6ddba 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
@@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The .
///
- public static RgbaVector FromHex(string hex) => Color.FromHex(hex).ToPixel();
+ public static RgbaVector FromHex(string hex) => Color.ParseHex(hex).ToPixel();
///
public PixelOperations CreatePixelOperations() => new PixelOperations();
diff --git a/tests/ImageSharp.Tests/Color/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs
index 2ac774f53e..953127f667 100644
--- a/tests/ImageSharp.Tests/Color/ColorTests.cs
+++ b/tests/ImageSharp.Tests/Color/ColorTests.cs
@@ -3,9 +3,7 @@
using System;
using System.Linq;
-
using SixLabors.ImageSharp.PixelFormats;
-
using Xunit;
namespace SixLabors.ImageSharp.Tests
@@ -15,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void WithAlpha()
{
- Color c1 = Color.FromRgba(111, 222, 55, 255);
+ var c1 = Color.FromRgba(111, 222, 55, 255);
Color c2 = c1.WithAlpha(0.5f);
var expected = new Rgba32(111, 222, 55, 128);
@@ -56,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests
public void ToHex()
{
string expected = "ABCD1234";
- Color color = Color.FromHex(expected);
+ var color = Color.ParseHex(expected);
string actual = color.ToHex();
Assert.Equal(expected, actual);
@@ -66,14 +64,22 @@ namespace SixLabors.ImageSharp.Tests
public void WebSafePalette_IsCorrect()
{
Rgba32[] actualPalette = Color.WebSafePalette.ToArray().Select(c => (Rgba32)c).ToArray();
- Assert.Equal(ReferencePalette.WebSafeColors, actualPalette);
+
+ for (int i = 0; i < ReferencePalette.WebSafeColors.Length; i++)
+ {
+ Assert.Equal(ReferencePalette.WebSafeColors[i], actualPalette[i]);
+ }
}
[Fact]
public void WernerPalette_IsCorrect()
{
Rgba32[] actualPalette = Color.WernerPalette.ToArray().Select(c => (Rgba32)c).ToArray();
- Assert.Equal(ReferencePalette.WernerColors, actualPalette);
+
+ for (int i = 0; i < ReferencePalette.WernerColors.Length; i++)
+ {
+ Assert.Equal(ReferencePalette.WernerColors[i], actualPalette[i]);
+ }
}
public class FromHex
@@ -81,28 +87,74 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ShortHex()
{
- Assert.Equal(new Rgb24(255, 255, 255), (Rgb24)Color.FromHex("#fff"));
- Assert.Equal(new Rgb24(255, 255, 255), (Rgb24)Color.FromHex("fff"));
- Assert.Equal(new Rgba32(0, 0, 0, 255), (Rgba32)Color.FromHex("000f"));
+ Assert.Equal(new Rgb24(255, 255, 255), (Rgb24)Color.ParseHex("#fff"));
+ Assert.Equal(new Rgb24(255, 255, 255), (Rgb24)Color.ParseHex("fff"));
+ Assert.Equal(new Rgba32(0, 0, 0, 255), (Rgba32)Color.ParseHex("000f"));
+ }
+
+ [Fact]
+ public void TryShortHex()
+ {
+ Assert.True(Color.TryParseHex("#fff", out Color actual));
+ Assert.Equal(new Rgb24(255, 255, 255), (Rgb24)actual);
+
+ Assert.True(Color.TryParseHex("fff", out actual));
+ Assert.Equal(new Rgb24(255, 255, 255), (Rgb24)actual);
+
+ Assert.True(Color.TryParseHex("000f", out actual));
+ Assert.Equal(new Rgba32(0, 0, 0, 255), (Rgba32)actual);
}
[Fact]
public void LeadingPoundIsOptional()
{
- Assert.Equal(new Rgb24(0, 128, 128), (Rgb24)Color.FromHex("#008080"));
- Assert.Equal(new Rgb24(0, 128, 128), (Rgb24)Color.FromHex("008080"));
+ Assert.Equal(new Rgb24(0, 128, 128), (Rgb24)Color.ParseHex("#008080"));
+ Assert.Equal(new Rgb24(0, 128, 128), (Rgb24)Color.ParseHex("008080"));
}
[Fact]
public void ThrowsOnEmpty()
{
- Assert.Throws(() => Color.FromHex(string.Empty));
+ Assert.Throws(() => Color.ParseHex(string.Empty));
}
[Fact]
public void ThrowsOnNull()
{
- Assert.Throws(() => Color.FromHex(null));
+ Assert.Throws(() => Color.ParseHex(null));
+ }
+ }
+
+ public class FromString
+ {
+ [Fact]
+ public void ColorNames()
+ {
+ foreach (string name in ReferencePalette.ColorNames.Keys)
+ {
+ Rgba32 expected = ReferencePalette.ColorNames[name];
+ Assert.Equal(expected, (Rgba32)Color.Parse(name));
+ Assert.Equal(expected, (Rgba32)Color.Parse(name.ToLowerInvariant()));
+ Assert.Equal(expected, (Rgba32)Color.Parse(expected.ToHex()));
+ }
+ }
+
+ [Fact]
+ public void TryColorNames()
+ {
+ foreach (string name in ReferencePalette.ColorNames.Keys)
+ {
+ Rgba32 expected = ReferencePalette.ColorNames[name];
+
+ Assert.True(Color.TryParse(name, out Color actual));
+ Assert.Equal(expected, (Rgba32)actual);
+
+ Assert.True(Color.TryParse(name.ToLowerInvariant(), out actual));
+ Assert.Equal(expected, (Rgba32)actual);
+
+ Assert.True(Color.TryParse(expected.ToHex(), out actual));
+ Assert.Equal(expected, (Rgba32)actual);
+ }
}
}
}
diff --git a/tests/ImageSharp.Tests/Color/ReferencePalette.cs b/tests/ImageSharp.Tests/Color/ReferencePalette.cs
index 9896731e69..583b3a58e8 100644
--- a/tests/ImageSharp.Tests/Color/ReferencePalette.cs
+++ b/tests/ImageSharp.Tests/Color/ReferencePalette.cs
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
+using System.Collections.Generic;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Tests
@@ -162,116 +164,270 @@ namespace SixLabors.ImageSharp.Tests
///
public static readonly Rgba32[] WernerColors =
{
- Rgba32.FromHex("#f1e9cd"),
- Rgba32.FromHex("#f2e7cf"),
- Rgba32.FromHex("#ece6d0"),
- Rgba32.FromHex("#f2eacc"),
- Rgba32.FromHex("#f3e9ca"),
- Rgba32.FromHex("#f2ebcd"),
- Rgba32.FromHex("#e6e1c9"),
- Rgba32.FromHex("#e2ddc6"),
- Rgba32.FromHex("#cbc8b7"),
- Rgba32.FromHex("#bfbbb0"),
- Rgba32.FromHex("#bebeb3"),
- Rgba32.FromHex("#b7b5ac"),
- Rgba32.FromHex("#bab191"),
- Rgba32.FromHex("#9c9d9a"),
- Rgba32.FromHex("#8a8d84"),
- Rgba32.FromHex("#5b5c61"),
- Rgba32.FromHex("#555152"),
- Rgba32.FromHex("#413f44"),
- Rgba32.FromHex("#454445"),
- Rgba32.FromHex("#423937"),
- Rgba32.FromHex("#433635"),
- Rgba32.FromHex("#252024"),
- Rgba32.FromHex("#241f20"),
- Rgba32.FromHex("#281f3f"),
- Rgba32.FromHex("#1c1949"),
- Rgba32.FromHex("#4f638d"),
- Rgba32.FromHex("#383867"),
- Rgba32.FromHex("#5c6b8f"),
- Rgba32.FromHex("#657abb"),
- Rgba32.FromHex("#6f88af"),
- Rgba32.FromHex("#7994b5"),
- Rgba32.FromHex("#6fb5a8"),
- Rgba32.FromHex("#719ba2"),
- Rgba32.FromHex("#8aa1a6"),
- Rgba32.FromHex("#d0d5d3"),
- Rgba32.FromHex("#8590ae"),
- Rgba32.FromHex("#3a2f52"),
- Rgba32.FromHex("#39334a"),
- Rgba32.FromHex("#6c6d94"),
- Rgba32.FromHex("#584c77"),
- Rgba32.FromHex("#533552"),
- Rgba32.FromHex("#463759"),
- Rgba32.FromHex("#bfbac0"),
- Rgba32.FromHex("#77747f"),
- Rgba32.FromHex("#4a475c"),
- Rgba32.FromHex("#b8bfaf"),
- Rgba32.FromHex("#b2b599"),
- Rgba32.FromHex("#979c84"),
- Rgba32.FromHex("#5d6161"),
- Rgba32.FromHex("#61ac86"),
- Rgba32.FromHex("#a4b6a7"),
- Rgba32.FromHex("#adba98"),
- Rgba32.FromHex("#93b778"),
- Rgba32.FromHex("#7d8c55"),
- Rgba32.FromHex("#33431e"),
- Rgba32.FromHex("#7c8635"),
- Rgba32.FromHex("#8e9849"),
- Rgba32.FromHex("#c2c190"),
- Rgba32.FromHex("#67765b"),
- Rgba32.FromHex("#ab924b"),
- Rgba32.FromHex("#c8c76f"),
- Rgba32.FromHex("#ccc050"),
- Rgba32.FromHex("#ebdd99"),
- Rgba32.FromHex("#ab9649"),
- Rgba32.FromHex("#dbc364"),
- Rgba32.FromHex("#e6d058"),
- Rgba32.FromHex("#ead665"),
- Rgba32.FromHex("#d09b2c"),
- Rgba32.FromHex("#a36629"),
- Rgba32.FromHex("#a77d35"),
- Rgba32.FromHex("#f0d696"),
- Rgba32.FromHex("#d7c485"),
- Rgba32.FromHex("#f1d28c"),
- Rgba32.FromHex("#efcc83"),
- Rgba32.FromHex("#f3daa7"),
- Rgba32.FromHex("#dfa837"),
- Rgba32.FromHex("#ebbc71"),
- Rgba32.FromHex("#d17c3f"),
- Rgba32.FromHex("#92462f"),
- Rgba32.FromHex("#be7249"),
- Rgba32.FromHex("#bb603c"),
- Rgba32.FromHex("#c76b4a"),
- Rgba32.FromHex("#a75536"),
- Rgba32.FromHex("#b63e36"),
- Rgba32.FromHex("#b5493a"),
- Rgba32.FromHex("#cd6d57"),
- Rgba32.FromHex("#711518"),
- Rgba32.FromHex("#e9c49d"),
- Rgba32.FromHex("#eedac3"),
- Rgba32.FromHex("#eecfbf"),
- Rgba32.FromHex("#ce536b"),
- Rgba32.FromHex("#b74a70"),
- Rgba32.FromHex("#b7757c"),
- Rgba32.FromHex("#612741"),
- Rgba32.FromHex("#7a4848"),
- Rgba32.FromHex("#3f3033"),
- Rgba32.FromHex("#8d746f"),
- Rgba32.FromHex("#4d3635"),
- Rgba32.FromHex("#6e3b31"),
- Rgba32.FromHex("#864735"),
- Rgba32.FromHex("#553d3a"),
- Rgba32.FromHex("#613936"),
- Rgba32.FromHex("#7a4b3a"),
- Rgba32.FromHex("#946943"),
- Rgba32.FromHex("#c39e6d"),
- Rgba32.FromHex("#513e32"),
- Rgba32.FromHex("#8b7859"),
- Rgba32.FromHex("#9b856b"),
- Rgba32.FromHex("#766051"),
- Rgba32.FromHex("#453b32")
+ Rgba32.ParseHex("#f1e9cd"),
+ Rgba32.ParseHex("#f2e7cf"),
+ Rgba32.ParseHex("#ece6d0"),
+ Rgba32.ParseHex("#f2eacc"),
+ Rgba32.ParseHex("#f3e9ca"),
+ Rgba32.ParseHex("#f2ebcd"),
+ Rgba32.ParseHex("#e6e1c9"),
+ Rgba32.ParseHex("#e2ddc6"),
+ Rgba32.ParseHex("#cbc8b7"),
+ Rgba32.ParseHex("#bfbbb0"),
+ Rgba32.ParseHex("#bebeb3"),
+ Rgba32.ParseHex("#b7b5ac"),
+ Rgba32.ParseHex("#bab191"),
+ Rgba32.ParseHex("#9c9d9a"),
+ Rgba32.ParseHex("#8a8d84"),
+ Rgba32.ParseHex("#5b5c61"),
+ Rgba32.ParseHex("#555152"),
+ Rgba32.ParseHex("#413f44"),
+ Rgba32.ParseHex("#454445"),
+ Rgba32.ParseHex("#423937"),
+ Rgba32.ParseHex("#433635"),
+ Rgba32.ParseHex("#252024"),
+ Rgba32.ParseHex("#241f20"),
+ Rgba32.ParseHex("#281f3f"),
+ Rgba32.ParseHex("#1c1949"),
+ Rgba32.ParseHex("#4f638d"),
+ Rgba32.ParseHex("#383867"),
+ Rgba32.ParseHex("#5c6b8f"),
+ Rgba32.ParseHex("#657abb"),
+ Rgba32.ParseHex("#6f88af"),
+ Rgba32.ParseHex("#7994b5"),
+ Rgba32.ParseHex("#6fb5a8"),
+ Rgba32.ParseHex("#719ba2"),
+ Rgba32.ParseHex("#8aa1a6"),
+ Rgba32.ParseHex("#d0d5d3"),
+ Rgba32.ParseHex("#8590ae"),
+ Rgba32.ParseHex("#3a2f52"),
+ Rgba32.ParseHex("#39334a"),
+ Rgba32.ParseHex("#6c6d94"),
+ Rgba32.ParseHex("#584c77"),
+ Rgba32.ParseHex("#533552"),
+ Rgba32.ParseHex("#463759"),
+ Rgba32.ParseHex("#bfbac0"),
+ Rgba32.ParseHex("#77747f"),
+ Rgba32.ParseHex("#4a475c"),
+ Rgba32.ParseHex("#b8bfaf"),
+ Rgba32.ParseHex("#b2b599"),
+ Rgba32.ParseHex("#979c84"),
+ Rgba32.ParseHex("#5d6161"),
+ Rgba32.ParseHex("#61ac86"),
+ Rgba32.ParseHex("#a4b6a7"),
+ Rgba32.ParseHex("#adba98"),
+ Rgba32.ParseHex("#93b778"),
+ Rgba32.ParseHex("#7d8c55"),
+ Rgba32.ParseHex("#33431e"),
+ Rgba32.ParseHex("#7c8635"),
+ Rgba32.ParseHex("#8e9849"),
+ Rgba32.ParseHex("#c2c190"),
+ Rgba32.ParseHex("#67765b"),
+ Rgba32.ParseHex("#ab924b"),
+ Rgba32.ParseHex("#c8c76f"),
+ Rgba32.ParseHex("#ccc050"),
+ Rgba32.ParseHex("#ebdd99"),
+ Rgba32.ParseHex("#ab9649"),
+ Rgba32.ParseHex("#dbc364"),
+ Rgba32.ParseHex("#e6d058"),
+ Rgba32.ParseHex("#ead665"),
+ Rgba32.ParseHex("#d09b2c"),
+ Rgba32.ParseHex("#a36629"),
+ Rgba32.ParseHex("#a77d35"),
+ Rgba32.ParseHex("#f0d696"),
+ Rgba32.ParseHex("#d7c485"),
+ Rgba32.ParseHex("#f1d28c"),
+ Rgba32.ParseHex("#efcc83"),
+ Rgba32.ParseHex("#f3daa7"),
+ Rgba32.ParseHex("#dfa837"),
+ Rgba32.ParseHex("#ebbc71"),
+ Rgba32.ParseHex("#d17c3f"),
+ Rgba32.ParseHex("#92462f"),
+ Rgba32.ParseHex("#be7249"),
+ Rgba32.ParseHex("#bb603c"),
+ Rgba32.ParseHex("#c76b4a"),
+ Rgba32.ParseHex("#a75536"),
+ Rgba32.ParseHex("#b63e36"),
+ Rgba32.ParseHex("#b5493a"),
+ Rgba32.ParseHex("#cd6d57"),
+ Rgba32.ParseHex("#711518"),
+ Rgba32.ParseHex("#e9c49d"),
+ Rgba32.ParseHex("#eedac3"),
+ Rgba32.ParseHex("#eecfbf"),
+ Rgba32.ParseHex("#ce536b"),
+ Rgba32.ParseHex("#b74a70"),
+ Rgba32.ParseHex("#b7757c"),
+ Rgba32.ParseHex("#612741"),
+ Rgba32.ParseHex("#7a4848"),
+ Rgba32.ParseHex("#3f3033"),
+ Rgba32.ParseHex("#8d746f"),
+ Rgba32.ParseHex("#4d3635"),
+ Rgba32.ParseHex("#6e3b31"),
+ Rgba32.ParseHex("#864735"),
+ Rgba32.ParseHex("#553d3a"),
+ Rgba32.ParseHex("#613936"),
+ Rgba32.ParseHex("#7a4b3a"),
+ Rgba32.ParseHex("#946943"),
+ Rgba32.ParseHex("#c39e6d"),
+ Rgba32.ParseHex("#513e32"),
+ Rgba32.ParseHex("#8b7859"),
+ Rgba32.ParseHex("#9b856b"),
+ Rgba32.ParseHex("#766051"),
+ Rgba32.ParseHex("#453b32")
};
+
+ public static readonly Dictionary ColorNames =
+ new Dictionary(StringComparer.OrdinalIgnoreCase)
+ {
+ { nameof(Rgba32.AliceBlue), Rgba32.AliceBlue },
+ { nameof(Rgba32.AntiqueWhite), Rgba32.AntiqueWhite },
+ { nameof(Rgba32.Aqua), Rgba32.Aqua },
+ { nameof(Rgba32.Aquamarine), Rgba32.Aquamarine },
+ { nameof(Rgba32.Azure), Rgba32.Azure },
+ { nameof(Rgba32.Beige), Rgba32.Beige },
+ { nameof(Rgba32.Bisque), Rgba32.Bisque },
+ { nameof(Rgba32.Black), Rgba32.Black },
+ { nameof(Rgba32.BlanchedAlmond), Rgba32.BlanchedAlmond },
+ { nameof(Rgba32.Blue), Rgba32.Blue },
+ { nameof(Rgba32.BlueViolet), Rgba32.BlueViolet },
+ { nameof(Rgba32.Brown), Rgba32.Brown },
+ { nameof(Rgba32.BurlyWood), Rgba32.BurlyWood },
+ { nameof(Rgba32.CadetBlue), Rgba32.CadetBlue },
+ { nameof(Rgba32.Chartreuse), Rgba32.Chartreuse },
+ { nameof(Rgba32.Chocolate), Rgba32.Chocolate },
+ { nameof(Rgba32.Coral), Rgba32.Coral },
+ { nameof(Rgba32.CornflowerBlue), Rgba32.CornflowerBlue },
+ { nameof(Rgba32.Cornsilk), Rgba32.Cornsilk },
+ { nameof(Rgba32.Crimson), Rgba32.Crimson },
+ { nameof(Rgba32.Cyan), Rgba32.Cyan },
+ { nameof(Rgba32.DarkBlue), Rgba32.DarkBlue },
+ { nameof(Rgba32.DarkCyan), Rgba32.DarkCyan },
+ { nameof(Rgba32.DarkGoldenrod), Rgba32.DarkGoldenrod },
+ { nameof(Rgba32.DarkGray), Rgba32.DarkGray },
+ { nameof(Rgba32.DarkGreen), Rgba32.DarkGreen },
+ { nameof(Rgba32.DarkGrey), Rgba32.DarkGrey },
+ { nameof(Rgba32.DarkKhaki), Rgba32.DarkKhaki },
+ { nameof(Rgba32.DarkMagenta), Rgba32.DarkMagenta },
+ { nameof(Rgba32.DarkOliveGreen), Rgba32.DarkOliveGreen },
+ { nameof(Rgba32.DarkOrange), Rgba32.DarkOrange },
+ { nameof(Rgba32.DarkOrchid), Rgba32.DarkOrchid },
+ { nameof(Rgba32.DarkRed), Rgba32.DarkRed },
+ { nameof(Rgba32.DarkSalmon), Rgba32.DarkSalmon },
+ { nameof(Rgba32.DarkSeaGreen), Rgba32.DarkSeaGreen },
+ { nameof(Rgba32.DarkSlateBlue), Rgba32.DarkSlateBlue },
+ { nameof(Rgba32.DarkSlateGray), Rgba32.DarkSlateGray },
+ { nameof(Rgba32.DarkSlateGrey), Rgba32.DarkSlateGrey },
+ { nameof(Rgba32.DarkTurquoise), Rgba32.DarkTurquoise },
+ { nameof(Rgba32.DarkViolet), Rgba32.DarkViolet },
+ { nameof(Rgba32.DeepPink), Rgba32.DeepPink },
+ { nameof(Rgba32.DeepSkyBlue), Rgba32.DeepSkyBlue },
+ { nameof(Rgba32.DimGray), Rgba32.DimGray },
+ { nameof(Rgba32.DimGrey), Rgba32.DimGrey },
+ { nameof(Rgba32.DodgerBlue), Rgba32.DodgerBlue },
+ { nameof(Rgba32.Firebrick), Rgba32.Firebrick },
+ { nameof(Rgba32.FloralWhite), Rgba32.FloralWhite },
+ { nameof(Rgba32.ForestGreen), Rgba32.ForestGreen },
+ { nameof(Rgba32.Fuchsia), Rgba32.Fuchsia },
+ { nameof(Rgba32.Gainsboro), Rgba32.Gainsboro },
+ { nameof(Rgba32.GhostWhite), Rgba32.GhostWhite },
+ { nameof(Rgba32.Gold), Rgba32.Gold },
+ { nameof(Rgba32.Goldenrod), Rgba32.Goldenrod },
+ { nameof(Rgba32.Gray), Rgba32.Gray },
+ { nameof(Rgba32.Green), Rgba32.Green },
+ { nameof(Rgba32.GreenYellow), Rgba32.GreenYellow },
+ { nameof(Rgba32.Grey), Rgba32.Grey },
+ { nameof(Rgba32.Honeydew), Rgba32.Honeydew },
+ { nameof(Rgba32.HotPink), Rgba32.HotPink },
+ { nameof(Rgba32.IndianRed), Rgba32.IndianRed },
+ { nameof(Rgba32.Indigo), Rgba32.Indigo },
+ { nameof(Rgba32.Ivory), Rgba32.Ivory },
+ { nameof(Rgba32.Khaki), Rgba32.Khaki },
+ { nameof(Rgba32.Lavender), Rgba32.Lavender },
+ { nameof(Rgba32.LavenderBlush), Rgba32.LavenderBlush },
+ { nameof(Rgba32.LawnGreen), Rgba32.LawnGreen },
+ { nameof(Rgba32.LemonChiffon), Rgba32.LemonChiffon },
+ { nameof(Rgba32.LightBlue), Rgba32.LightBlue },
+ { nameof(Rgba32.LightCoral), Rgba32.LightCoral },
+ { nameof(Rgba32.LightCyan), Rgba32.LightCyan },
+ { nameof(Rgba32.LightGoldenrodYellow), Rgba32.LightGoldenrodYellow },
+ { nameof(Rgba32.LightGray), Rgba32.LightGray },
+ { nameof(Rgba32.LightGreen), Rgba32.LightGreen },
+ { nameof(Rgba32.LightGrey), Rgba32.LightGrey },
+ { nameof(Rgba32.LightPink), Rgba32.LightPink },
+ { nameof(Rgba32.LightSalmon), Rgba32.LightSalmon },
+ { nameof(Rgba32.LightSeaGreen), Rgba32.LightSeaGreen },
+ { nameof(Rgba32.LightSkyBlue), Rgba32.LightSkyBlue },
+ { nameof(Rgba32.LightSlateGray), Rgba32.LightSlateGray },
+ { nameof(Rgba32.LightSlateGrey), Rgba32.LightSlateGrey },
+ { nameof(Rgba32.LightSteelBlue), Rgba32.LightSteelBlue },
+ { nameof(Rgba32.LightYellow), Rgba32.LightYellow },
+ { nameof(Rgba32.Lime), Rgba32.Lime },
+ { nameof(Rgba32.LimeGreen), Rgba32.LimeGreen },
+ { nameof(Rgba32.Linen), Rgba32.Linen },
+ { nameof(Rgba32.Magenta), Rgba32.Magenta },
+ { nameof(Rgba32.Maroon), Rgba32.Maroon },
+ { nameof(Rgba32.MediumAquamarine), Rgba32.MediumAquamarine },
+ { nameof(Rgba32.MediumBlue), Rgba32.MediumBlue },
+ { nameof(Rgba32.MediumOrchid), Rgba32.MediumOrchid },
+ { nameof(Rgba32.MediumPurple), Rgba32.MediumPurple },
+ { nameof(Rgba32.MediumSeaGreen), Rgba32.MediumSeaGreen },
+ { nameof(Rgba32.MediumSlateBlue), Rgba32.MediumSlateBlue },
+ { nameof(Rgba32.MediumSpringGreen), Rgba32.MediumSpringGreen },
+ { nameof(Rgba32.MediumTurquoise), Rgba32.MediumTurquoise },
+ { nameof(Rgba32.MediumVioletRed), Rgba32.MediumVioletRed },
+ { nameof(Rgba32.MidnightBlue), Rgba32.MidnightBlue },
+ { nameof(Rgba32.MintCream), Rgba32.MintCream },
+ { nameof(Rgba32.MistyRose), Rgba32.MistyRose },
+ { nameof(Rgba32.Moccasin), Rgba32.Moccasin },
+ { nameof(Rgba32.NavajoWhite), Rgba32.NavajoWhite },
+ { nameof(Rgba32.Navy), Rgba32.Navy },
+ { nameof(Rgba32.OldLace), Rgba32.OldLace },
+ { nameof(Rgba32.Olive), Rgba32.Olive },
+ { nameof(Rgba32.OliveDrab), Rgba32.OliveDrab },
+ { nameof(Rgba32.Orange), Rgba32.Orange },
+ { nameof(Rgba32.OrangeRed), Rgba32.OrangeRed },
+ { nameof(Rgba32.Orchid), Rgba32.Orchid },
+ { nameof(Rgba32.PaleGoldenrod), Rgba32.PaleGoldenrod },
+ { nameof(Rgba32.PaleGreen), Rgba32.PaleGreen },
+ { nameof(Rgba32.PaleTurquoise), Rgba32.PaleTurquoise },
+ { nameof(Rgba32.PaleVioletRed), Rgba32.PaleVioletRed },
+ { nameof(Rgba32.PapayaWhip), Rgba32.PapayaWhip },
+ { nameof(Rgba32.PeachPuff), Rgba32.PeachPuff },
+ { nameof(Rgba32.Peru), Rgba32.Peru },
+ { nameof(Rgba32.Pink), Rgba32.Pink },
+ { nameof(Rgba32.Plum), Rgba32.Plum },
+ { nameof(Rgba32.PowderBlue), Rgba32.PowderBlue },
+ { nameof(Rgba32.Purple), Rgba32.Purple },
+ { nameof(Rgba32.RebeccaPurple), Rgba32.RebeccaPurple },
+ { nameof(Rgba32.Red), Rgba32.Red },
+ { nameof(Rgba32.RosyBrown), Rgba32.RosyBrown },
+ { nameof(Rgba32.RoyalBlue), Rgba32.RoyalBlue },
+ { nameof(Rgba32.SaddleBrown), Rgba32.SaddleBrown },
+ { nameof(Rgba32.Salmon), Rgba32.Salmon },
+ { nameof(Rgba32.SandyBrown), Rgba32.SandyBrown },
+ { nameof(Rgba32.SeaGreen), Rgba32.SeaGreen },
+ { nameof(Rgba32.SeaShell), Rgba32.SeaShell },
+ { nameof(Rgba32.Sienna), Rgba32.Sienna },
+ { nameof(Rgba32.Silver), Rgba32.Silver },
+ { nameof(Rgba32.SkyBlue), Rgba32.SkyBlue },
+ { nameof(Rgba32.SlateBlue), Rgba32.SlateBlue },
+ { nameof(Rgba32.SlateGray), Rgba32.SlateGray },
+ { nameof(Rgba32.SlateGrey), Rgba32.SlateGrey },
+ { nameof(Rgba32.Snow), Rgba32.Snow },
+ { nameof(Rgba32.SpringGreen), Rgba32.SpringGreen },
+ { nameof(Rgba32.SteelBlue), Rgba32.SteelBlue },
+ { nameof(Rgba32.Tan), Rgba32.Tan },
+ { nameof(Rgba32.Teal), Rgba32.Teal },
+ { nameof(Rgba32.Thistle), Rgba32.Thistle },
+ { nameof(Rgba32.Tomato), Rgba32.Tomato },
+ { nameof(Rgba32.Transparent), Rgba32.Transparent },
+ { nameof(Rgba32.Turquoise), Rgba32.Turquoise },
+ { nameof(Rgba32.Violet), Rgba32.Violet },
+ { nameof(Rgba32.Wheat), Rgba32.Wheat },
+ { nameof(Rgba32.White), Rgba32.White },
+ { nameof(Rgba32.WhiteSmoke), Rgba32.WhiteSmoke },
+ { nameof(Rgba32.Yellow), Rgba32.Yellow },
+ { nameof(Rgba32.YellowGreen), Rgba32.YellowGreen }
+ };
}
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs
index a242dba41a..6656ba19c2 100644
--- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs
@@ -21,10 +21,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{
var color1 = new Rgba32(0, 0, 0);
var color2 = new Rgba32(0, 0, 0, 1F);
- var color3 = Rgba32.FromHex("#000");
- var color4 = Rgba32.FromHex("#000F");
- var color5 = Rgba32.FromHex("#000000");
- var color6 = Rgba32.FromHex("#000000FF");
+ var color3 = Rgba32.ParseHex("#000");
+ var color4 = Rgba32.ParseHex("#000F");
+ var color5 = Rgba32.ParseHex("#000000");
+ var color6 = Rgba32.ParseHex("#000000FF");
Assert.Equal(color1, color2);
Assert.Equal(color1, color3);
@@ -41,9 +41,9 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{
var color1 = new Rgba32(255, 0, 0, 255);
var color2 = new Rgba32(0, 0, 0, 255);
- var color3 = Rgba32.FromHex("#000");
- var color4 = Rgba32.FromHex("#000000");
- var color5 = Rgba32.FromHex("#FF000000");
+ var color3 = Rgba32.ParseHex("#000");
+ var color4 = Rgba32.ParseHex("#000000");
+ var color5 = Rgba32.ParseHex("#FF000000");
Assert.NotEqual(color1, color2);
Assert.NotEqual(color1, color3);
@@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void FromAndToHex()
{
// 8 digit hex matches css4 spec. RRGGBBAA
- var color = Rgba32.FromHex("#AABBCCDD"); // 170, 187, 204, 221
+ var color = Rgba32.ParseHex("#AABBCCDD"); // 170, 187, 204, 221
Assert.Equal(170, color.R);
Assert.Equal(187, color.G);
Assert.Equal(204, color.B);
diff --git a/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs
index bd8c647421..162775a25f 100644
--- a/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs
@@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
[Fact]
public void Color_Types_From_Hex_Produce_Equal_Scaled_Component_OutPut()
{
- var color = Rgba32.FromHex("183060C0");
+ var color = Rgba32.ParseHex("183060C0");
var colorVector = RgbaVector.FromHex("183060C0");
Assert.Equal(color.R, (byte)(colorVector.R * 255));