Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the parsing of hsl colours. #1418

Merged
merged 2 commits into from
Jun 23, 2021
Merged

Correct the parsing of hsl colours. #1418

merged 2 commits into from
Jun 23, 2021

Conversation

seanparsons
Copy link
Contributor

Fixes #1216

Problem:
Previously when parsing hsl(...) colours, the wrong range was used when invoking the conversion function in Chroma.

Fix:
Reduced the range of saturation and lightness values when passing them to Chroma.

Commit Details:

- Fixes #1216.
- When invoking the `Chroma.hsl` function, reduce the saturation
  and lightness values down to the range `[0..1]`.
@github-actions
Copy link
Contributor

Link to test editor
Scroll Canvas: 39.1ms (30.7-75.7ms) | Resize: 74.4ms (23.5-178.4ms) | Selection: 283.6ms (227.5-603ms) | Calc Pi: 36ms (36-65ms) | Empty Dispatch: 46ms (43.4-142.1ms) | (Chart)

@@ -2055,7 +2055,7 @@ export function cssColorToChromaColor(c: CSSColor): Either<string, Chroma.Color>
} else if (isHex(c)) {
return right(Chroma.hex(c.hex))
} else if (isHSL(c)) {
return right((Chroma.hsl as any)(c.h, c.s, c.l, c.a))
return right((Chroma.hsl as any)(c.h, c.s / 100.0, c.l / 100.0, c.a))
Copy link
Contributor

Choose a reason for hiding this comment

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

is this c.s / 100.0 different from c.s / 100 in javascript?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, they're apparently equal, it just seemed like the right thing to do given that it's going to be double-like.

@seanparsons seanparsons merged commit ea60f09 into master Jun 23, 2021
@seanparsons seanparsons deleted the fix/hsl-parsing branch June 23, 2021 13:14
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.

Inspector does not show correct background colour
4 participants