-
Notifications
You must be signed in to change notification settings - Fork 231
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
HSL color incorrectly translates to RGB color #786
Comments
I'm not sure I would call it "incorrectly". Just a different rounding to what you're expecting. |
Maybe "incorrectly" is not a right word, but still usvg selects not a closest rgb color, and that can be improved. |
I can make a PR if you show me a place where this transformation is happening. |
+/-1 difference is perfectly normal. But Chrome seems to be rounding up, so should we. |
The current float to integer cast truncates the hues when converting from HSL to RGB. This PR rounds to the nearest integer before the cast. See linebender/resvg#786 for discussion. Modifies tests with `hsl(120, 100%, 75%, 0.5)` to match with `rgb(128, 255, 128)` and adds one new test case. Chrome developer tools: <img width="485" alt="Screenshot 2024-12-02 at 11 00 54 PM" src="https://github.com/user-attachments/assets/bddba238-3ed5-4b76-bbc6-d3823e205d57"> Safari developer tools: <img width="659" alt="Screenshot 2024-12-02 at 11 06 15 PM" src="https://github.com/user-attachments/assets/32055547-0c12-4bd8-a917-20574dcb1ac2">
The current float to integer cast truncates the hues when converting from HSL to RGB. This PR rounds to the nearest integer before the cast. See linebender/resvg#786 for discussion. Modifies tests with `hsl(120, 100%, 75%, 0.5)` to match with `rgb(128, 255, 128)` and adds one new test case. Chrome developer tools: <img width="485" alt="Screenshot 2024-12-02 at 11 00 54 PM" src="https://github.com/user-attachments/assets/bddba238-3ed5-4b76-bbc6-d3823e205d57"> Safari developer tools: <img width="659" alt="Screenshot 2024-12-02 at 11 06 15 PM" src="https://github.com/user-attachments/assets/32055547-0c12-4bd8-a917-20574dcb1ac2">
For example,
hsl(230, 57%, 54%)
should be translated to#475dcd
, but usvg returns#465dcc
.r component value is 70.839, so it should be rounded to 71 (0x47).
The text was updated successfully, but these errors were encountered: