Sha256: 9c776e461584cedf322e3f40bacd53dd028a518d137756335dcd72fd8ffda2d3

Contents?: true

Size: 1.39 KB

Versions: 25

Compression:

Stored size: 1.39 KB

Contents

d3.hsl = function(h, s, l) {
  return arguments.length === 1
      ? (h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l)
      : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl))
      : d3_hsl(+h, +s, +l);
};

function d3_hsl(h, s, l) {
  return new d3_Hsl(h, s, l);
}

function d3_Hsl(h, s, l) {
  this.h = h;
  this.s = s;
  this.l = l;
}

d3_Hsl.prototype.brighter = function(k) {
  k = Math.pow(0.7, arguments.length ? k : 1);
  return d3_hsl(this.h, this.s, this.l / k);
};

d3_Hsl.prototype.darker = function(k) {
  k = Math.pow(0.7, arguments.length ? k : 1);
  return d3_hsl(this.h, this.s, k * this.l);
};

d3_Hsl.prototype.rgb = function() {
  return d3_hsl_rgb(this.h, this.s, this.l);
};

d3_Hsl.prototype.toString = function() {
  return this.rgb().toString();
};

function d3_hsl_rgb(h, s, l) {
  var m1,
      m2;

  /* Some simple corrections for h, s and l. */
  h = h % 360; if (h < 0) h += 360;
  s = s < 0 ? 0 : s > 1 ? 1 : s;
  l = l < 0 ? 0 : l > 1 ? 1 : l;

  /* From FvD 13.37, CSS Color Module Level 3 */
  m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
  m1 = 2 * l - m2;

  function v(h) {
    if (h > 360) h -= 360;
    else if (h < 0) h += 360;
    if (h < 60) return m1 + (m2 - m1) * h / 60;
    if (h < 180) return m2;
    if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
    return m1;
  }

  function vv(h) {
    return Math.round(v(h) * 255);
  }

  return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/src/core/hsl.js