Skip to content

Commit 2ff6c34

Browse files
committed
Fix a divide by zero error in Scenic.Color
1 parent db4d76d commit 2ff6c34

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/scenic/color.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ defmodule Scenic.Color do
535535

536536
s =
537537
case delta do
538-
0 -> 0
538+
0.0 -> 0.0
539539
d -> d / (1 - abs(2 * l - 1))
540540
end
541541

test/scenic/color_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ defmodule Scenic.ColorTest do
175175
assert Color.to_hsl({:color_hsl, {1.1, 1.2, 1.3}}) == {:color_hsl, {1.1, 1.2, 1.3}}
176176
end
177177

178+
test "white hsl to hsv to rgb" do
179+
assert Color.to_hsv(:white)
180+
|> Color.to_hsl()
181+
|> Color.to_rgb() == {:color_rgb, {255, 255, 255}}
182+
end
183+
178184
test "named looks right" do
179185
Color.named()
180186
|> Enum.each(fn {n, {r, g, b}} ->

0 commit comments

Comments
 (0)