Skip to content

Commit

Permalink
Apply proper negative lightness handling in DIN99o
Browse files Browse the repository at this point in the history
We really shouldn't try to be clever here by trying to mirroring the
behavior for negative lightness. Instead, just let the algorithm as
specified handle it, and when it it breaks down (somewhere past -200)
we can just return NaN for now. In most cases, this will be more than
sufficient. Anyone hitting this limit is pushing the space well pass
reasonable limits.
  • Loading branch information
facelessuser committed Nov 30, 2023
1 parent 56d7637 commit 2ea1df3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coloraide/spaces/din99o.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def lab_to_din99o(lab: Vector) -> Vector:
"""XYZ to DIN99o."""

l, a, b = lab
val = 1 + abs(C2 * l)
l99o = C1 * math.copysign(1, l) * math.log(val) / KE
val = 1 + C2 * l
l99o = C1 * math.log(val) / KE if val >= 0 else math.nan

if a == 0 and b == 0:
a99o = b99o = 0.0
Expand Down
1 change: 1 addition & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- **FIX**: Much more accurate ICtCp matrices.
- **FIX**: Fix typing of deeply nested arrays in `algebra`.
- **FIX**: Fix issue with HCT undefined channel resolver.
- **FIX**: Proper handling of negative lightness for DIN99o.

## 2.13.1

Expand Down

0 comments on commit 2ea1df3

Please sign in to comment.