-
Notifications
You must be signed in to change notification settings - Fork 265
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
color.whiten() not working #166
Comments
I am seeing another issue where |
Same issue here! @Qix- could you please look at https://github.com/Qix-/color/pull/167 ? |
This has been my feedback for a number of "not working" issues, but I guess I'll re-form it here for the folks using the HWB color model and the associated methods ( Let me make it abundantly clear that HWB is a color model similar to HSV (the "H" means Hue, which is identical between the two cylindrical color models) with "whiten" and "blacken" channels. Basically, it takes a fully-saturated color ( Keep in mind, The problem here isn't with implementation, but with the intent of the API -
If you check the source code, this is exactly what's happening. It is mathematically and academically correct behavior. This is also why
If you print out the output from the OP, you'll see the White (W) channel of the color is These two methods are working entirely as intended. Now, that's not to say something can't be improved here. I fully agree that the API methods are not intuitive to most people who do not care about the color theory behind the library (why else would you use this library instead of using However, the issue then becomes about the API naming conventions, not about the correctness of the mathematical methods. I'm very much open to having a discussion about the naming conventions used here because I fully understand there is some confusion with what this library does and what users are trying to do. Please also keep in mind I'm not the original author of this library, and that even if I were, designing an API that is intuitive, just as powerful, mathematically sound and useful to a whole range of people (designers all the way to academics) is very, very difficult. It has been a problem with this library for a while and it's a problem I've been racking my brain on how to solve for years. Any input is appreciated. As-is, this is a won't-fix. I know that's not the response you want to hear. The two methods I would suggest looking into are |
@Qix- Thanks for answer. let color = Color('rgb(255, 0, 0)');
color.lightness(); // 50
console.log(color.lightness(90).rgb().toString()) // rgb(255, 204, 204) |
If your definition of "brightness" is the lightness channel in the HSL color model, then yes :) other people might think "brightness" means saturation. Perhaps I should add a guide of common transformations to the readme. |
Some more examples that demonstrate this were added to the readme. You are indeed looking for lightness in this case. I'd also, again, recommend |
When I use color.whiten in-browser, I get no change to the color object. My test code below:
import Color from 'color';
let color = Color("#0099cc")
console.log(color.hwb())
let newColor = Color(color).whiten(0.5)
console.log(newColor.hwb())
let newColor2 = Color(color).blacken(0.5)
console.log(newColor2.hwb())
The text was updated successfully, but these errors were encountered: