Sometimes when comparing colors you would expect them to be equal but they aren't. This can happen when two colors have the same hexadecimal value, but the floating point values might be slightly different. The Color Pro package provides two other ways to determine color equality through the static class Equality.

🔬 Rounded Comparison

To avoid floating point precision errors, you can round the component values before comparing:

// Rounded to the nearest thousand
bool equals = color1.Equals(color2, 1000);

// Ignoring alpha components
bool equals = color1.Equals(color2, 1000, false);

#️⃣ Comparing Hex

To compare the hexadecimal representation of two colors:

bool equals = color1.EqualsHex(color2);