Skip to content

clamp HSL format#101

Merged
mbostock merged 1 commit intomainfrom
mbostock/clamp-hsl-format
Mar 28, 2022
Merged

clamp HSL format#101
mbostock merged 1 commit intomainfrom
mbostock/clamp-hsl-format

Conversation

@mbostock
Copy link
Copy Markdown
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