Sha256: 10bb21e2813ce243911ef85c9c36c6a647e436604b67496cfb8cb4e8c73ee06f
Contents?: true
Size: 849 Bytes
Versions: 2
Compression:
Stored size: 849 Bytes
Contents
/*global one*/ INCLUDE('lib:color.js'); INCLUDE('lib:color/HSV.js'); installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], { hsv: function () { // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts var l = this._lightness * 2, s = this._saturation * ((l <= 1) ? l : 2 - l), saturation; // Avoid division by zero when l + s is very small (approaching black): if (l + s < 1e-9) { saturation = 0; } else { saturation = (2 * s) / (l + s); } return new ONECOLOR.HSV(this._hue, saturation, (l + s) / 2, this._alpha); }, rgb: function () { return this.hsv().rgb(); }, fromRgb: function () { // Becomes one.color.RGB.prototype.hsv return this.hsv().hsl(); } });
Version data entries
2 entries across 2 versions & 1 rubygems