From 0b4d1250ca34fe41636acacdd02023df44c95cef Mon Sep 17 00:00:00 2001 From: facelessuser Date: Wed, 17 Mar 2021 14:25:20 -0600 Subject: [PATCH] Address two divide by zero cases that were missed --- coloraide/__meta__.py | 2 +- coloraide/colors/hsl.py | 2 +- docs/src/markdown/about/changelog.md | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/coloraide/__meta__.py b/coloraide/__meta__.py index 4ea283877..aecf663b2 100644 --- a/coloraide/__meta__.py +++ b/coloraide/__meta__.py @@ -188,5 +188,5 @@ def parse_version(ver): return Version(major, minor, micro, release, pre, post, dev) -__version_info__ = Version(0, 1, 0, "alpha", 9) +__version_info__ = Version(0, 1, 0, "alpha", 10) __version__ = __version_info__._get_canonical() diff --git a/coloraide/colors/hsl.py b/coloraide/colors/hsl.py index 2e860372b..b64b0e2a1 100644 --- a/coloraide/colors/hsl.py +++ b/coloraide/colors/hsl.py @@ -28,7 +28,7 @@ def srgb_to_hsl(rgb): h = (b - r) / c + 2.0 else: h = (r - g) / c + 4.0 - s = c / (1.0 - abs(2.0 * l - 1)) + s = 0 if l == 0 or l == 1 else c / (1.0 - abs(2.0 * l - 1)) h *= 60.0 return HSL._constrain_hue(h), s * 100.0, l * 100.0 diff --git a/docs/src/markdown/about/changelog.md b/docs/src/markdown/about/changelog.md index b3b0a5817..4d3b24da5 100644 --- a/docs/src/markdown/about/changelog.md +++ b/docs/src/markdown/about/changelog.md @@ -1,5 +1,10 @@ # Changelog +## 0.10a10 + +- **FIX**: Address two divide by zero cases in HSL algorithm. Was missing some special cases when luminance equals `1` + or `0`. + ## 0.1.0a9 - **FIX**: Ensure all cases of hue handling, in regards to gamut mapping, are done the same.