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

HSL to RGB forces rounding even with rgb(false) #333

Closed
KeyboardDanni opened this issue Apr 4, 2024 · 1 comment · Fixed by #344
Closed

HSL to RGB forces rounding even with rgb(false) #333

KeyboardDanni opened this issue Apr 4, 2024 · 1 comment · Fixed by #344
Labels

Comments

@KeyboardDanni
Copy link

KeyboardDanni commented Apr 4, 2024

The code in hsl2rgb.js is forcing the RGB components to be rounded to the nearest integer:

[r,g,b] = [round(c[0]*255),round(c[1]*255),round(c[2]*255)];

This means that even if you pass false to rgb(), the resulting color gets rounded. The issue does not occur with HSV.

Minimal reproduction:

import chroma from "chroma-js";

let color = chroma.hsv(260, 0.5, 0.5);
let colorRgb = color.rgb(false); // [ 84.99999999999999, 63.75, 127.5 ]

color = chroma.hsl(260, 0.3333333333333333, 0.375);
colorRgb = color.rgb(false); // [ 85, 64, 128 ]
@gka gka added the bug label Jul 28, 2024
@gka
Copy link
Owner

gka commented Jul 28, 2024

Interesting, thanks for the bug report. I'll marked this as bug to remind myself to fix it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants