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

Increase HSL precision by default #130

Open
BaliBalo opened this issue Nov 11, 2024 · 0 comments
Open

Increase HSL precision by default #130

BaliBalo opened this issue Nov 11, 2024 · 0 comments

Comments

@BaliBalo
Copy link

Somewhat related to #82, but I believe a change in defaults should be considered rather than an option ; at least in the color.minify function, which is used by default in tools like cssnano (this was reported in cssnano/cssnano#1515).

Conversions to HSL currently round all values to the nearest integer. This leaves it with less precision than the standard 8bit rgb format, used to store the color internally. This means some colors cannot be represented uniquely and get the same hsl values as nearby colors, and therefore the minification is not lossless (which seems to be the intent).
For example, rgb(14 14 14 / 50%) is converted to hsl(0, 0%, 5%, .5), which when converted back is rgb(13 13 13 / 50%).
I believe rounding HSL values to 1 digit precision would solve this.

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

No branches or pull requests

1 participant