-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Hcl seems to be broken #14
Comments
Hi, thanks for the great report with example code and picture, and sorry for the long delay in answering! This is actually Working As Intended™. The reason is that most of the colors you are trying to compute here don't actually exist. When you're asking to generate a color of hue, say 190° and both chroma and luminosity of 1.0, the corresponding RGB values would be -8.25590, 1.17914, 1.12230, meaning such a color is not representable in the RGB system (and a computer screen). If you go for less extreme values of luminance and chroma, you will see more and more of the gradient appear. For some values, such as (0.35,0.65), the full gradient exists, and you'll get a nice picture like this: If you really, really want to have a gradient of higher perceived chroma or luminance, though, there's an ugly workaround that you can do: clamp these non-representable colors to the closes representable one. This will not be entirely correct (converting the gradient to grayscale will show variations in brightness), but depending on your application, it is Good Enough™. I have actually specifically implemented the So with that, simply change your code from |
@lucasb-eyer thank you for this detailed answer, the behavior makes sense. |
Good idea, thanks. Done! |
Hi and thanks for this libary, it looks pretty useful! I generated a gradient over the hues 0 to 360 with the
Hcl
function, and the output looks wrong. Using theHsl
orHsv
functions causes no problems. Here is my rainbow gradient:The code I used to produce this image using a HTML file that I opened in my browser:
The text was updated successfully, but these errors were encountered: