I am looking for a tool or the algorithm to convert between HSL color to RGB. It seems to me that HSL is not very widely used so I am not having much luck searching for a converter.
相关问题
- DBGrid - How to set an individual background color
- How to display an image represented by three matri
- How to delete a certain part of an Image?
- draw polylines with different colors on v2 maps
- How do I change the color of the navigation bar ic
相关文章
- Emacs/xterm color annoyance on Linux
- matplotlib bwr-colormap, always centered on zero
- MeshLab: How to import XYZRGB file
- How to add RGB values into setColor() in Java?
- ChartJS. Change axis line color
- set foreground color in FrameLayout in android pro
- Changing background color for a text annotation to
- Keras: Visualize ImageDataGenerator Output
Here's a fast, super-simple, branchless version in GLSL:
Doesn't get much shorter than that ~
Link to the original proof-of-concept: https://www.shadertoy.com/view/XljGzV
(Disclaimer: not my code!)
For all who said that Garry Tan solution converting incorrect from RGB to HSL and back. It because he left out fraction part of number in his code. I corrected his code (javascript). Sorry for link on russian languadge, but on english absent - HSL-wiki
Garry Tan posted a Javascript solution on his blog (which he attributes to a now defunct mjijackson.com, but is archived here and the original author has a gist - thanks to user2441511).
The code is re-posted below:
HSL to RGB:
RGB to HSL:
Found the easiest way, python to the rescue :D
The article for HSL and HSV on wikipedia contains some formulas. The calculations are a bit tricky, so it might be useful to take a look at existing implementations.
C# Code from Mohsen's answer.
Here is the code from Mohsen's answer in C# if anyone else wants it. Note:
Color
is a custom class andVector4
is from OpenTK. Both are easy to replace with something else of your choosing.Hsl To Rgba
Rgba To Hsl