-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
feat: Add Color::from_hsl
✨
#772
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #772 +/- ##
======================================
Coverage 92.3% 92.4%
======================================
Files 61 57 -4
Lines 16010 15028 -982
======================================
- Hits 14789 13891 -898
+ Misses 1221 1137 -84 ☔ View full report in Codecov by Sentry. |
Can we import an optional library for this functionality instead? |
I think the logic/conversion is pretty simple and it does not pose a huge maintenance burden (and it is not going to change anytime soon - |
If we import a library like https://crates.io/crates/palette we can convert from any color space to RGB and it would be worth it in my opinion. HSLuv is the main one that people recommend for perceptually uniform color spaces. https://www.hsluv.org/comparison/ If we are only going to stick to HSL, I agree with @orhun, this implementation is standard and there's little maintenance cost imo |
Are we just going to stick with HSL? Why that over HSV or some other approach? |
My guess for why HSL is more popular than HSB/HSV is that in HSB, 100% Brightness/Value gives you the white color only when the Saturation is 0. But in HSL, 100% Lightness will give you white independent of the value of Saturation. So HSL is more intuitive, since you can increase Lightness to get closer to white and decrease Lightness to get closer to black. With HSB/HSV you have to change two things, and in opposite directions. |
I guess my point is that there are already so many versions of this sort of function in various crates:
No problem with merging this as-is though. |
|
I don't see people needing to use cmyk (because it is primarily used for print and not digital). Also, for terminals, the imo only |
Makes sense. |
This PR adds
Color::from_hsl
that returns a validColor::Rgb
.HSL stands for Hue (0-360 deg), Saturation (0-100%), and Lightness (0-100%) and working with HSL the values can be more intuitive. For example, if you want to make a red color more orange, you can change the Hue closer toward yellow on the color wheel (i.e. increase the Hue).
Related #763