Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/Graphics/src/Graphics/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,11 @@ public override int GetHashCode()
public override bool Equals(object obj)
{
if (obj is Color other)
return NearlyEqual(Red, other.Red)
&& NearlyEqual(Green, other.Green)
&& NearlyEqual(Blue, other.Blue)
&& NearlyEqual(Alpha, other.Alpha);
return ToInt() == other.ToInt();

return base.Equals(obj);
}

static bool NearlyEqual(float f1, float f2, float epsilon = 0.01f)
=> Math.Abs(f1 - f2) < epsilon;

[Obsolete("Use ToArgbHex instead.")]
public string ToHex(bool includeAlpha)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Graphics/tests/Graphics.Tests/ColorTypeConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public static IEnumerable<object[]> ColorConvertData()
new object[] { "hsva(0,0,0,1)", new Color() },
new object[] { "hsva(0,0,0,0)", Colors.Transparent },

new object[] { "hsl(253,66,50)", Color.FromArgb("#512BD4") },
new object[] { "hsv(253,80,83)", Color.FromArgb("#512BD4") },
new object[] { "hsl(253,66,50)", Color.FromArgb("#4F2BD3") },
new object[] { "hsv(253,80,83)", Color.FromArgb("#4F2AD3") },
new object[] { "rgb(81,43,212)", Color.FromArgb("#512BD4") },
};

Expand Down