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

clamp HSL format #101

Merged
merged 1 commit into from
Mar 28, 2022
Merged

clamp HSL format #101

merged 1 commit into from
Mar 28, 2022

Conversation

mbostock
Copy link
Member

Fixes #83.

Note that you don’t get an equivalent color with formatHsl and formatRgb, though, because they clamp in the HSL and RGB colorspaces, respectively. If you want to clamp in RGB colorspace and format in HSL, you have to first format as RGB, then re-parse, then format as HSL:

d3.color(color.formatRgb()).formatHsl()

It’d probably be nice if we had an explicit color.clamp option for RGB and HSL so that you could avoid reparsing. Then you could say:

color.rgb().clamp().formatHsl()

@mbostock mbostock requested a review from Fil March 28, 2022 16:29
@mbostock mbostock mentioned this pull request Mar 28, 2022
@Fil

This comment was marked as off-topic.

@mbostock mbostock merged commit 70e3a04 into main Mar 28, 2022
@mbostock mbostock deleted the mbostock/clamp-hsl-format branch March 28, 2022 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected conversion to HSL
2 participants