From 84595c0d715fde33dff25f3c9ba64430a63301f0 Mon Sep 17 00:00:00 2001 From: Olivia Date: Wed, 28 Dec 2016 13:07:02 +0200 Subject: [PATCH] Refactoring ColorspaceTransforms to use a const epsilon. --- src/ImageSharp/Colors/ColorspaceTransforms.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Colors/ColorspaceTransforms.cs b/src/ImageSharp/Colors/ColorspaceTransforms.cs index 9785a888f4..578f10e29f 100644 --- a/src/ImageSharp/Colors/ColorspaceTransforms.cs +++ b/src/ImageSharp/Colors/ColorspaceTransforms.cs @@ -8,6 +8,7 @@ namespace ImageSharp using System; using System.Numerics; using Colors.Spaces; + using Common; /// /// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 255. @@ -19,11 +20,6 @@ namespace ImageSharp /// public partial struct Color { - /// - /// The epsilon for comparing floating point numbers. - /// - private const float Epsilon = 0.001F; - /// /// Allows the implicit conversion of an instance of to a /// . @@ -110,12 +106,12 @@ namespace ImageSharp float s = color.S; float v = color.V; - if (Math.Abs(s) < Epsilon) + if (Math.Abs(s) < Constants.Epsilon) { return new Color(v, v, v, 1); } - float h = (Math.Abs(color.H - 360) < Epsilon) ? 0 : color.H / 60; + float h = (Math.Abs(color.H - 360) < Constants.Epsilon) ? 0 : color.H / 60; int i = (int)Math.Truncate(h); float f = h - i; @@ -183,9 +179,9 @@ namespace ImageSharp float s = color.S; float l = color.L; - if (Math.Abs(l) > Epsilon) + if (Math.Abs(l) > Constants.Epsilon) { - if (Math.Abs(s) < Epsilon) + if (Math.Abs(s) < Constants.Epsilon) { r = g = b = l; }