Created
September 21, 2013 14:33
-
-
Save sudodoki/6651214 to your computer and use it in GitHub Desktop.
function to convert hsl values into rgb
This file contains hidden or 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
| /** | |
| * function to convert hue, saturation, lightness in browser | |
| * @param {integer} h in range of 0..360 | |
| * @param {saturation} s in range of 0..100 (percents) | |
| * @param {lightness} l in range of 0..100 (percents) | |
| * @return {array} array [r, g, b] of integers (0..255) representing each part | |
| */ | |
| hsl2rgb = function (h, s, l) { | |
| var transmitter = document.createElement("div"); | |
| hsl2rgb = function () { | |
| transmitter.style.backgroundColor = "hsl(" + h + ", " + s + "%, " + l + "%)"; | |
| return transmitter.style.backgroundColor | |
| .slice(4, - 1) | |
| .split(', ') | |
| .map(function(x){return parseInt(x)}); | |
| } | |
| return hsl2rgb(h,s,l); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment