We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ff6c34 commit b22c070Copy full SHA for b22c070
lib/scenic/color.ex
@@ -224,6 +224,10 @@ defmodule Scenic.Color do
224
@hsv :color_hsv
225
@hsl :color_hsl
226
227
+ # Epsilon value from JS
228
+ # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON
229
+ @epsilon 2.22044e-16
230
+
231
@type implicit ::
232
atom
233
| {name :: atom, a :: integer}
@@ -534,9 +538,9 @@ defmodule Scenic.Color do
534
538
l = (max + min) / 2
535
539
536
540
s =
537
- case delta do
- 0.0 -> 0.0
- d -> d / (1 - abs(2 * l - 1))
541
+ cond do
542
+ delta < @epsilon -> 0.0
543
+ true -> delta / (1 - abs(2 * l - 1))
544
end
545
546
{h, s * 100, l * 100}
0 commit comments