diff --git a/src/ImageSharp/Colors/Spaces/CieLab.cs b/src/ImageSharp/Colors/Spaces/CieLab.cs
index faa6c2472..dd72a966f 100644
--- a/src/ImageSharp/Colors/Spaces/CieLab.cs
+++ b/src/ImageSharp/Colors/Spaces/CieLab.cs
@@ -8,6 +8,7 @@ namespace ImageSharp.Colors.Spaces
using System;
using System.ComponentModel;
using System.Numerics;
+ using Common;
///
/// Represents an CIE LAB 1976 color.
@@ -20,11 +21,6 @@ namespace ImageSharp.Colors.Spaces
///
public static readonly CieLab Empty = default(CieLab);
- ///
- /// The epsilon for comparing floating point numbers.
- ///
- private const float Epsilon = 0.001f;
-
///
/// The backing vector for SIMD support.
///
@@ -166,7 +162,7 @@ namespace ImageSharp.Colors.Spaces
///
public bool Equals(CieLab other)
{
- return this.AlmostEquals(other, Epsilon);
+ return this.AlmostEquals(other, Constants.Epsilon);
}
///
diff --git a/src/ImageSharp/Colors/Spaces/CieXyz.cs b/src/ImageSharp/Colors/Spaces/CieXyz.cs
index 9deffe066..33b763f2b 100644
--- a/src/ImageSharp/Colors/Spaces/CieXyz.cs
+++ b/src/ImageSharp/Colors/Spaces/CieXyz.cs
@@ -8,6 +8,7 @@ namespace ImageSharp.Colors.Spaces
using System;
using System.ComponentModel;
using System.Numerics;
+ using Common;
///
/// Represents an CIE 1931 color
@@ -20,11 +21,6 @@ namespace ImageSharp.Colors.Spaces
///
public static readonly CieXyz Empty = default(CieXyz);
- ///
- /// The epsilon for comparing floating point numbers.
- ///
- private const float Epsilon = 0.001f;
-
///
/// The backing vector for SIMD support.
///
@@ -157,7 +153,7 @@ namespace ImageSharp.Colors.Spaces
///
public bool Equals(CieXyz other)
{
- return this.AlmostEquals(other, Epsilon);
+ return this.AlmostEquals(other, Constants.Epsilon);
}
///
diff --git a/src/ImageSharp/Colors/Spaces/Cmyk.cs b/src/ImageSharp/Colors/Spaces/Cmyk.cs
index e8f2a41f5..41e88ca8f 100644
--- a/src/ImageSharp/Colors/Spaces/Cmyk.cs
+++ b/src/ImageSharp/Colors/Spaces/Cmyk.cs
@@ -8,6 +8,7 @@ namespace ImageSharp.Colors.Spaces
using System;
using System.ComponentModel;
using System.Numerics;
+ using Common;
///
/// Represents an CMYK (cyan, magenta, yellow, keyline) color.
@@ -19,11 +20,6 @@ namespace ImageSharp.Colors.Spaces
///
public static readonly Cmyk Empty = default(Cmyk);
- ///
- /// The epsilon for comparing floating point numbers.
- ///
- private const float Epsilon = 0.001f;
-
///
/// The backing vector for SIMD support.
///
@@ -90,7 +86,7 @@ namespace ImageSharp.Colors.Spaces
float k = Math.Min(c, Math.Min(m, y));
- if (Math.Abs(k - 1.0f) <= Epsilon)
+ if (Math.Abs(k - 1.0f) <= Constants.Epsilon)
{
return new Cmyk(0, 0, 0, 1);
}
@@ -167,7 +163,7 @@ namespace ImageSharp.Colors.Spaces
///
public bool Equals(Cmyk other)
{
- return this.AlmostEquals(other, Epsilon);
+ return this.AlmostEquals(other, Constants.Epsilon);
}
///
diff --git a/src/ImageSharp/Colors/Spaces/Hsl.cs b/src/ImageSharp/Colors/Spaces/Hsl.cs
index 5c478ecf1..a57c15981 100644
--- a/src/ImageSharp/Colors/Spaces/Hsl.cs
+++ b/src/ImageSharp/Colors/Spaces/Hsl.cs
@@ -8,6 +8,7 @@ namespace ImageSharp.Colors.Spaces
using System;
using System.ComponentModel;
using System.Numerics;
+ using Common;
///
/// Represents a Hsl (hue, saturation, lightness) color.
@@ -19,11 +20,6 @@ namespace ImageSharp.Colors.Spaces
///
public static readonly Hsl Empty = default(Hsl);
- ///
- /// The epsilon for comparing floating point numbers.
- ///
- private const float Epsilon = 0.001F;
-
///
/// The backing vector for SIMD support.
///
@@ -85,20 +81,20 @@ namespace ImageSharp.Colors.Spaces
float s = 0;
float l = (max + min) / 2;
- if (Math.Abs(chroma) < Epsilon)
+ if (Math.Abs(chroma) < Constants.Epsilon)
{
return new Hsl(0, s, l);
}
- if (Math.Abs(r - max) < Epsilon)
+ if (Math.Abs(r - max) < Constants.Epsilon)
{
h = (g - b) / chroma;
}
- else if (Math.Abs(g - max) < Epsilon)
+ else if (Math.Abs(g - max) < Constants.Epsilon)
{
h = 2 + ((b - r) / chroma);
}
- else if (Math.Abs(b - max) < Epsilon)
+ else if (Math.Abs(b - max) < Constants.Epsilon)
{
h = 4 + ((r - g) / chroma);
}
@@ -186,7 +182,7 @@ namespace ImageSharp.Colors.Spaces
///
public bool Equals(Hsl other)
{
- return this.AlmostEquals(other, Epsilon);
+ return this.AlmostEquals(other, Constants.Epsilon);
}
///
diff --git a/src/ImageSharp/Colors/Spaces/Hsv.cs b/src/ImageSharp/Colors/Spaces/Hsv.cs
index 9df16a27b..28c1e1259 100644
--- a/src/ImageSharp/Colors/Spaces/Hsv.cs
+++ b/src/ImageSharp/Colors/Spaces/Hsv.cs
@@ -8,6 +8,7 @@ namespace ImageSharp.Colors.Spaces
using System;
using System.ComponentModel;
using System.Numerics;
+ using Common;
///
/// Represents a HSV (hue, saturation, value) color. Also known as HSB (hue, saturation, brightness).
@@ -19,11 +20,6 @@ namespace ImageSharp.Colors.Spaces
///
public static readonly Hsv Empty = default(Hsv);
- ///
- /// The epsilon for comparing floating point numbers.
- ///
- private const float Epsilon = 0.001F;
-
///
/// The backing vector for SIMD support.
///
@@ -85,20 +81,20 @@ namespace ImageSharp.Colors.Spaces
float s = 0;
float v = max;
- if (Math.Abs(chroma) < Epsilon)
+ if (Math.Abs(chroma) < Constants.Epsilon)
{
return new Hsv(0, s, v);
}
- if (Math.Abs(r - max) < Epsilon)
+ if (Math.Abs(r - max) < Constants.Epsilon)
{
h = (g - b) / chroma;
}
- else if (Math.Abs(g - max) < Epsilon)
+ else if (Math.Abs(g - max) < Constants.Epsilon)
{
h = 2 + ((b - r) / chroma);
}
- else if (Math.Abs(b - max) < Epsilon)
+ else if (Math.Abs(b - max) < Constants.Epsilon)
{
h = 4 + ((r - g) / chroma);
}
@@ -179,7 +175,7 @@ namespace ImageSharp.Colors.Spaces
///
public bool Equals(Hsv other)
{
- return this.AlmostEquals(other, Epsilon);
+ return this.AlmostEquals(other, Constants.Epsilon);
}
///