hsl2rgb - 140byt.es

by schrodingers

HTML

<div id="output"></div>
<a href="https://gist.github.com/1325937">Source Code</a>

CSS

span {
      display: inline-block;
      width: 8px;
      height: 8px;
  }
  #output div {
      height: 8px;
  }
  #output {
      margin-bottom: 1em;
  }

JavaScript

var hsl = function (a, b, c, d, e) {
    for (d in e = [b = c + b * (c > .5 ? 1 - c : c), b -= c += c - b, a *= 6]) e[d] = c + b * ((d = (a + 2 + 4 * d) % 6) < 1 ? d : d < 3 || d < 4 && 4 - d);
    return e
}

var html = "",
    h, s, l, rgb;

for (h = 0; h <= 1; h += 0.1) {

    html += "<div>";

    for (s = 0; s <= 1; s += 0.3) {
        for (l = 0; l <= 1; l += 0.1) {
            rgb = hsl(h, s, l);

            rgb = [~~ (rgb[0] * 255), ~~ (rgb[1] * 255), ~~ (rgb[2] * 255)].join(",")

            html += "<span style='background:rgb(" + rgb + ")'></span>"
        }
    }

    html += "</div>";
}

document.getElementById("output").innerHTML = html;