Created
October 30, 2016 05:27
-
-
Save SoftwareDevPro/9248ae04e8695ea08a66400ea33eaecb to your computer and use it in GitHub Desktop.
Takes a HSL (hue saturation, light) value and returns the RGB equivalent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filed under: color, convert, hsl, rgb | |
# Converts hue-saturation-lightness to red-green-blue color value. | |
### | |
@param a hue | |
@param b saturation | |
@param c lightness | |
### | |
hsl2rgb = (a, b, c) -> | |
a *= 6 | |
b = [ | |
(if c += b *= c < .5 then c else 1 - c), | |
c - a % 1 * b * 2, | |
c -= b *= 2, | |
c, | |
c + a % 1 * b, | |
c + b | |
] | |
red = b[~~a % 6] | |
green = b[(a|16) % 6] | |
blue = b[(a|8) % 6] | |
[red, green, blue] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment