Skip to content

Conversation

iteratee
Copy link

@iteratee iteratee commented Oct 17, 2025

Values were taken from the most recent conversion specification packaged with the css color specification level 4.

Resolves #15

Values were taken from the most recent conversion specification packaged with
the css color specification level 4.
Copy link
Owner

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Thank you for creating this PR!
Could I please also ask you to apply the basic tests that are already implemented in the test suite. You can use the ones defined for CIELab as an example:

Also could you please bump up the version to 0.4.1 and add a changelog entry for this very nice addition?

Comment on lines +120 to +122
!l' = 1.0000000000000000 * ll + 0.3963377773761749 * a + 0.2158037573099136 * b
!m' = 1.0000000000000000 * ll - 0.1055613458156586 * a - 0.0638541728258133 * b
!s' = 1.0000000000000000 * ll - 0.0894841775298119 * a - 1.2914855480194092 * b
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Suggested change
!l' = 1.0000000000000000 * ll + 0.3963377773761749 * a + 0.2158037573099136 * b
!m' = 1.0000000000000000 * ll - 0.1055613458156586 * a - 0.0638541728258133 * b
!s' = 1.0000000000000000 * ll - 0.0894841775298119 * a - 1.2914855480194092 * b
!l' = ll + 0.3963377773761749 * a + 0.2158037573099136 * b
!m' = ll - 0.1055613458156586 * a - 0.0638541728258133 * b
!s' = ll - 0.0894841775298119 * a - 1.2914855480194092 * b

Comment on lines +106 to +108
!l' = 1.0000000000000000 * ll + 0.3963377773761749 * a + 0.2158037573099136 * b
!m' = 1.0000000000000000 * ll - 0.1055613458156586 * a - 0.0638541728258133 * b
!s' = 1.0000000000000000 * ll - 0.0894841775298119 * a - 1.2914855480194092 * b
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiplication by 1 is superfluous.

Suggested change
!l' = 1.0000000000000000 * ll + 0.3963377773761749 * a + 0.2158037573099136 * b
!m' = 1.0000000000000000 * ll - 0.1055613458156586 * a - 0.0638541728258133 * b
!s' = 1.0000000000000000 * ll - 0.0894841775298119 * a - 1.2914855480194092 * b
!l' = ll + 0.3963377773761749 * a + 0.2158037573099136 * b
!m' = ll - 0.1055613458156586 * a - 0.0638541728258133 * b
!s' = ll - 0.0894841775298119 * a - 1.2914855480194092 * b

The only reason why multiplication by 1 is done in the css color spec, is because they define the matrix and then use matrix multiplication functionality.

if x < 0
then -((-x) ** (1 / 3))
else x ** (1 / 3)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important to inline such function, otherwise it will destroy the performance if GHC fails to inline it.

Suggested change
{-# INLINE signedCubeRoot #-}

--------------

-- | [OK L*a*b*](https://bottosson.github.io/posts/oklab/) color space
data OKLAB
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data OKLAB
--
-- Values for matrices used in conversion to and from @CIEXYZ@ where taken from [W3 CSS specification](https://www.w3.org/TR/css-color-4/#color-conversion-code) instead of the original blogpost about the OKLab color space.
data OKLAB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding support for Oklab and Oklch

2 participants