Socket
Socket
Sign inDemoInstall

onecolor

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onecolor - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

2

lib/one/color-namedColors.js

@@ -1,2 +0,2 @@

one.color.namedColors = {
ONECOLOR.namedColors = {
aliceblue: '#f0f8ff',

@@ -3,0 +3,0 @@ antiquewhite: '#faebd7',

@@ -22,3 +22,3 @@ // This file is purely for the build system

if (typeof module !== 'undefined') {
module.exports = one.color;
module.exports = ONECOLOR;
}

@@ -6,3 +6,3 @@ // This file is purely for the build system

if (typeof module !== 'undefined') {
module.exports = one.color;
module.exports = ONECOLOR;
}

@@ -155,5 +155,5 @@ /*global one*/

one.color.installColorSpace('CMYK', ['cyan', 'magenta', 'yellow', 'black', 'alpha'], {
ONECOLOR.installColorSpace('CMYK', ['cyan', 'magenta', 'yellow', 'black', 'alpha'], {
rgb: function () {
return new one.color.RGB((1 - this._cyan * (1 - this._black) - this._black),
return new ONECOLOR.RGB((1 - this._cyan * (1 - this._black) - this._black),
(1 - this._magenta * (1 - this._black) - this._black),

@@ -181,4 +181,4 @@ (1 - this._yellow * (1 - this._black) - this._black),

}
return new one.color.CMYK(cyan, magenta, yellow, black, this._alpha);
return new ONECOLOR.CMYK(cyan, magenta, yellow, black, this._alpha);
}
});

@@ -37,3 +37,3 @@ /*global one*/

one.color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {
ONECOLOR.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {
hsv: function () {

@@ -52,3 +52,3 @@ // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts

return new one.color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);
return new ONECOLOR.HSV(this._hue, saturation, (l + s) / 2, this._alpha);
},

@@ -55,0 +55,0 @@

@@ -140,96 +140,92 @@ /*global one*/

*/
(function () {
var MATH = Math,
ONECOLOR = one.color;
ONECOLOR.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {
rgb: function () {
var hue = this._hue,
saturation = this._saturation,
value = this._value,
i = MATH.min(5, MATH.floor(hue * 6)),
f = hue * 6 - i,
p = value * (1 - saturation),
q = value * (1 - f * saturation),
t = value * (1 - (1 - f) * saturation),
red,
green,
blue;
switch (i) {
case 0:
red = value;
green = t;
blue = p;
ONECOLOR.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {
rgb: function () {
var hue = this._hue,
saturation = this._saturation,
value = this._value,
i = Math.min(5, Math.floor(hue * 6)),
f = hue * 6 - i,
p = value * (1 - saturation),
q = value * (1 - f * saturation),
t = value * (1 - (1 - f) * saturation),
red,
green,
blue;
switch (i) {
case 0:
red = value;
green = t;
blue = p;
break;
case 1:
red = q;
green = value;
blue = p;
break;
case 2:
red = p;
green = value;
blue = t;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
}
return new ONECOLOR.RGB(red, green, blue, this._alpha);
},
hsl: function () {
var l = (2 - this._saturation) * this._value,
sv = this._saturation * this._value,
svDivisor = l <= 1 ? l : (2 - l),
saturation;
// Avoid division by zero when lightness approaches zero:
if (svDivisor < 1e-9) {
saturation = 0;
} else {
saturation = sv / svDivisor;
}
return new ONECOLOR.HSL(this._hue, saturation, l / 2, this._alpha);
},
fromRgb: function () { // Becomes one.color.RGB.prototype.hsv
var red = this._red,
green = this._green,
blue = this._blue,
max = Math.max(red, green, blue),
min = Math.min(red, green, blue),
delta = max - min,
hue,
saturation = (max === 0) ? 0 : (delta / max),
value = max;
if (delta === 0) {
hue = 0;
} else {
switch (max) {
case red:
hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);
break;
case 1:
red = q;
green = value;
blue = p;
case green:
hue = (blue - red) / delta / 6 + 1 / 3;
break;
case 2:
red = p;
green = value;
blue = t;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
}
return new ONECOLOR.RGB(red, green, blue, this._alpha);
},
hsl: function () {
var l = (2 - this._saturation) * this._value,
sv = this._saturation * this._value,
svDivisor = l <= 1 ? l : (2 - l),
saturation;
// Avoid division by zero when lightness approaches zero:
if (svDivisor < 1e-9) {
saturation = 0;
} else {
saturation = sv / svDivisor;
}
return new ONECOLOR.HSL(this._hue, saturation, l / 2, this._alpha);
},
fromRgb: function () { // Becomes one.color.RGB.prototype.hsv
var red = this._red,
green = this._green,
blue = this._blue,
max = MATH.max(red, green, blue),
min = MATH.min(red, green, blue),
delta = max - min,
hue,
saturation = (max === 0) ? 0 : (delta / max),
value = max;
if (delta === 0) {
hue = 0;
} else {
switch (max) {
case red:
hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);
break;
case green:
hue = (blue - red) / delta / 6 + 1 / 3;
break;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
break;
}
}
return new ONECOLOR.HSV(hue, saturation, value, this._alpha);
}
});
}());
return new ONECOLOR.HSV(hue, saturation, value, this._alpha);
}
});

@@ -8,4 +8,4 @@ /*global one*/

one.color.Interpolator = function (startColor, endColor, minValue, maxValue) {
startColor = one.color.parse(startColor).toRGB();
endColor = one.color.parse(endColor).toRGB();
startColor = one.color.parse(startColor).rgb();
endColor = one.color.parse(endColor).rgb();
if (maxValue === minValue) {

@@ -16,9 +16,13 @@ return function () {

}
var deltaR = endColor.r - startColor.r,
deltaG = endColor.g - startColor.g,
deltaB = endColor.b - startColor.b;
var deltaR = endColor._red - startColor._red,
deltaG = endColor._green - startColor._green,
deltaB = endColor._blue - startColor._blue;
return function (value) {
var intensity = (value - minValue) / (maxValue - minValue);
return new one.color.RGB(startColor.r + deltaR * intensity, startColor.g + deltaG * intensity, startColor.b + deltaB * intensity);
return new one.color.RGB(
startColor._red + deltaR * intensity,
startColor._green + deltaG * intensity,
startColor._blue + deltaB * intensity
);
};
};

@@ -505,97 +505,93 @@ /*global one*/

*/
(function () {
var MATH = Math,
ONECOLOR = one.color;
ONECOLOR.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {
rgb: function () {
var hue = this._hue,
saturation = this._saturation,
value = this._value,
i = MATH.min(5, MATH.floor(hue * 6)),
f = hue * 6 - i,
p = value * (1 - saturation),
q = value * (1 - f * saturation),
t = value * (1 - (1 - f) * saturation),
red,
green,
blue;
switch (i) {
case 0:
red = value;
green = t;
blue = p;
ONECOLOR.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {
rgb: function () {
var hue = this._hue,
saturation = this._saturation,
value = this._value,
i = Math.min(5, Math.floor(hue * 6)),
f = hue * 6 - i,
p = value * (1 - saturation),
q = value * (1 - f * saturation),
t = value * (1 - (1 - f) * saturation),
red,
green,
blue;
switch (i) {
case 0:
red = value;
green = t;
blue = p;
break;
case 1:
red = q;
green = value;
blue = p;
break;
case 2:
red = p;
green = value;
blue = t;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
}
return new ONECOLOR.RGB(red, green, blue, this._alpha);
},
hsl: function () {
var l = (2 - this._saturation) * this._value,
sv = this._saturation * this._value,
svDivisor = l <= 1 ? l : (2 - l),
saturation;
// Avoid division by zero when lightness approaches zero:
if (svDivisor < 1e-9) {
saturation = 0;
} else {
saturation = sv / svDivisor;
}
return new ONECOLOR.HSL(this._hue, saturation, l / 2, this._alpha);
},
fromRgb: function () { // Becomes one.color.RGB.prototype.hsv
var red = this._red,
green = this._green,
blue = this._blue,
max = Math.max(red, green, blue),
min = Math.min(red, green, blue),
delta = max - min,
hue,
saturation = (max === 0) ? 0 : (delta / max),
value = max;
if (delta === 0) {
hue = 0;
} else {
switch (max) {
case red:
hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);
break;
case 1:
red = q;
green = value;
blue = p;
case green:
hue = (blue - red) / delta / 6 + 1 / 3;
break;
case 2:
red = p;
green = value;
blue = t;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
}
return new ONECOLOR.RGB(red, green, blue, this._alpha);
},
hsl: function () {
var l = (2 - this._saturation) * this._value,
sv = this._saturation * this._value,
svDivisor = l <= 1 ? l : (2 - l),
saturation;
// Avoid division by zero when lightness approaches zero:
if (svDivisor < 1e-9) {
saturation = 0;
} else {
saturation = sv / svDivisor;
}
return new ONECOLOR.HSL(this._hue, saturation, l / 2, this._alpha);
},
fromRgb: function () { // Becomes one.color.RGB.prototype.hsv
var red = this._red,
green = this._green,
blue = this._blue,
max = MATH.max(red, green, blue),
min = MATH.min(red, green, blue),
delta = max - min,
hue,
saturation = (max === 0) ? 0 : (delta / max),
value = max;
if (delta === 0) {
hue = 0;
} else {
switch (max) {
case red:
hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);
break;
case green:
hue = (blue - red) / delta / 6 + 1 / 3;
break;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
break;
}
}
return new ONECOLOR.HSV(hue, saturation, value, this._alpha);
}
});
}());
return new ONECOLOR.HSV(hue, saturation, value, this._alpha);
}
});

@@ -634,3 +630,3 @@ /*global one*/

one.color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {
ONECOLOR.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {
hsv: function () {

@@ -649,3 +645,3 @@ // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts

return new one.color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);
return new ONECOLOR.HSV(this._hue, saturation, (l + s) / 2, this._alpha);
},

@@ -919,5 +915,5 @@

one.color.installColorSpace('CMYK', ['cyan', 'magenta', 'yellow', 'black', 'alpha'], {
ONECOLOR.installColorSpace('CMYK', ['cyan', 'magenta', 'yellow', 'black', 'alpha'], {
rgb: function () {
return new one.color.RGB((1 - this._cyan * (1 - this._black) - this._black),
return new ONECOLOR.RGB((1 - this._cyan * (1 - this._black) - this._black),
(1 - this._magenta * (1 - this._black) - this._black),

@@ -945,7 +941,7 @@ (1 - this._yellow * (1 - this._black) - this._black),

}
return new one.color.CMYK(cyan, magenta, yellow, black, this._alpha);
return new ONECOLOR.CMYK(cyan, magenta, yellow, black, this._alpha);
}
});
one.color.namedColors = {
ONECOLOR.namedColors = {
aliceblue: '#f0f8ff',

@@ -1225,4 +1221,4 @@ antiquewhite: '#faebd7',

if (typeof module !== 'undefined') {
module.exports = one.color;
module.exports = ONECOLOR;
}

@@ -1,1 +0,1 @@

(function(a,b,c,d,e,f,g){function m(){var a=this.rgb(),b=a._red*.3+a._green*.59+a._blue*.11;return new l.RGB(b,b,b,this._alpha)}typeof one=="undefined"&&(one={include:function(){}});var h=[],i=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,j=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,k=new RegExp("^(rgb|hsl|hsv)a?\\("+i.source+","+i.source+","+i.source+"(?:,"+j.source+")?"+"\\)$","i"),l=one.color=function(d){if(Object.prototype.toString.apply(d)==="[object Array]")return d[0].length===4?new l.RGB(d[0]/255,d[1]/255,d[2]/255,d[3]/255):new l[d[0]](d.slice(1,d.length));if(d.charCodeAt){if(l.namedColors){var e=d.toLowerCase();l.namedColors[e]&&(d=l.namedColors[e])}var f=d.match(k);if(f){var g=f[1].toUpperCase(),h=typeof f[8]=="undefined"?f[8]:b(f[8]),i=g[0]==="H",j=f[3]?100:i?360:255,m=f[5]||i?100:255,n=f[7]||i?100:255;if(typeof l[g]=="undefined")throw new Error("one.color."+g+" is not installed.");return new l[g](b(f[2])/j,b(f[4])/m,b(f[6])/n,h)}d.length<6&&(d=d.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var o=d.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(o)return new l.RGB(c(o[1],16)/255,c(o[2],16)/255,c(o[3],16)/255)}else{if(typeof d=="object"&&d.isColor)return d;if(!a(d))return new l.RGB((d&255)/255,((d&65280)>>8)/255,((d&16711680)>>16)/255)}return!1};l.installColorSpace=function(a,b,c){function j(a,b){var c={};c[b.toLowerCase()]=new d("return this.rgb()."+b.toLowerCase()+"();"),l[b].propertyNames.forEach(function(a,e){c[a]=new d("value","isDelta","return this."+b.toLowerCase()+"()."+a+"(value, isDelta);")});for(var e in c)c.hasOwnProperty(e)&&l[a].prototype[e]===undefined&&(l[a].prototype[e]=c[e])}l[a]=new d(b.join(","),"if (Object.prototype.toString.apply("+b[0]+") === '[object Array]') {"+b.map(function(a,c){return a+"="+b[0]+"["+c+"];"}).reverse().join("")+"}"+"if ("+b.filter(function(a){return a!=="alpha"}).map(function(a){return"isNaN("+a+")"}).join("||")+"){"+'throw new Error("[one.color.'+a+']: Invalid color: ("+'+b.join('+","+')+'+")");}'+b.map(function(a){return a==="hue"?"this._hue=hue<0?hue-Math.floor(hue):hue%1":a==="alpha"?"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);":"this._"+a+"="+a+"<0?0:("+a+">1?1:"+a+")"}).join(";")+";"),l[a].propertyNames=b;var f=l[a].prototype;["valueOf","hex","css","cssa"].forEach(function(b){f[b]=f[b]||(a==="RGB"?f.hex:new d("return this.rgb()."+b+"();"))}),f.isColor=!0,f.equals=function(c,d){typeof d=="undefined"&&(d=1e-10),c=c[a.toLowerCase()]();for(var f=0;f<b.length;f+=1)if(e.abs(this["_"+b[f]]-c["_"+b[f]])>d)return!1;return!0},f.toJSON=new d("return ['"+a+"', "+b.map(function(a){return"this._"+a},this).join(", ")+"];");for(var g in c)if(c.hasOwnProperty(g)){var i=g.match(/^from(.*)$/);i?l[i[1].toUpperCase()].prototype[a.toLowerCase()]=c[g]:f[g]=c[g]}f[a.toLowerCase()]=function(){return this},f.toString=new d('return "[one.color.'+a+':"+'+b.map(function(a,c){return'" '+b[c]+'="+this._'+a}).join("+")+'+"]";'),b.forEach(function(a,c){f[a]=new d("value","isDelta","if (typeof value === 'undefined') {return this._"+a+";"+"}"+"if (isDelta) {"+"return new this.constructor("+b.map(function(b,c){return"this._"+b+(a===b?"+value":"")}).join(", ")+");"+"}"+"return new this.constructor("+b.map(function(b,c){return a===b?"value":"this._"+b}).join(", ")+");")}),h.forEach(function(b){j(a,b),j(b,a)}),h.push(a)},l.installMethod=function(a,b){h.forEach(function(c){l[c].prototype[a]=b})},l.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var a=(f(255*this._red)*65536+f(255*this._green)*256+f(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-a.length)+a},css:function(){return"rgb("+f(255*this._red)+","+f(255*this._green)+","+f(255*this._blue)+")"},cssa:function(){return"rgba("+f(255*this._red)+","+f(255*this._green)+","+f(255*this._blue)+","+this._alpha+")"}}),function(){var a=e,b=one.color;b.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var c=this._hue,d=this._saturation,e=this._value,f=a.min(5,a.floor(c*6)),g=c*6-f,h=e*(1-d),i=e*(1-g*d),j=e*(1-(1-g)*d),k,l,m;switch(f){case 0:k=e,l=j,m=h;break;case 1:k=i,l=e,m=h;break;case 2:k=h,l=e,m=j;break;case 3:k=h,l=i,m=e;break;case 4:k=j,l=h,m=e;break;case 5:k=e,l=h,m=i}return new b.RGB(k,l,m,this._alpha)},hsl:function(){var a=(2-this._saturation)*this._value,c=this._saturation*this._value,d=a<=1?a:2-a,e;return d<1e-9?e=0:e=c/d,new b.HSL(this._hue,e,a/2,this._alpha)},fromRgb:function(){var c=this._red,d=this._green,e=this._blue,f=a.max(c,d,e),g=a.min(c,d,e),h=f-g,i,j=f===0?0:h/f,k=f;if(h===0)i=0;else switch(f){case c:i=(d-e)/h/6+(d<e?1:0);break;case d:i=(e-c)/h/6+1/3;break;case e:i=(c-d)/h/6+2/3}return new b.HSV(i,j,k,this._alpha)}})}(),one.color.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*(a<=1?a:2-a),c;return a+b<1e-9?c=0:c=2*b/(a+b),new one.color.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}}),one.color.installColorSpace("CMYK",["cyan","magenta","yellow","black","alpha"],{rgb:function(){return new one.color.RGB(1-this._cyan*(1-this._black)-this._black,1-this._magenta*(1-this._black)-this._black,1-this._yellow*(1-this._black)-this._black,this._alpha)},fromRgb:function(){var a=this._red,b=this._green,c=this._blue,d=1-a,e=1-b,f=1-c,h=1;return a||b||c?(h=g(d,g(e,f)),d=(d-h)/(1-h),e=(e-h)/(1-h),f=(f-h)/(1-h)):h=1,new one.color.CMYK(d,e,f,h,this._alpha)}}),one.color.namedColors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},l.installMethod("clearer",function(b){return b=a(b)?.1:b,this.alpha(-b,!0)}),l.installMethod("darken",function(b){return b=a(b)?.1:b,this.lightness(-b,!0)}),l.installMethod("saturate",function(b){return b=a(b)?.1:b,this.saturation(-b,!0)}),l.installMethod("greyscale",m),l.installMethod("grayscale",m),l.installMethod("lighten",function(b){return b=a(b)?.1:b,this.lightness(b,!0)}),l.installMethod("mix",function(a,b){var a=l(a),b=1-(b||.5),c=b*2-1,d=this._alpha-a._alpha,e=((c*d==-1?c:(c+d)/(1+c*d))+1)/2,f=1-e,g=this.rgb(),a=a.rgb();return new l.RGB(this._red*e+a._red*f,this._green*e+a._green*f,this._blue*e+a._blue*f,this._alpha*b+a._alpha*(1-b))}),l.installMethod("negate",function(){var a=this.rgb();return new l.RGB(1-a._red,1-a._green,1-a._blue,this._alpha)}),l.installMethod("opaquer",function(b){return b=a(b)?.1:b,this.alpha(b,!0)}),l.installMethod("rotate",function(a){return amount=(a||0)/360,this.hue(amount,!0)}),l.installMethod("saturate",function(b){return b=a(b)?.1:b,this.saturation(b,!0)}),l.installMethod("toAlpha",function(a){var b=this.rgb(),c=l(a).rgb(),d=1e-10,e=new l.RGB(0,0,0,b._alpha),f=["_red","_green","_blue"];return f.forEach(function(a){b[a]<d?e[a]=b[a]:b[a]>c[a]?e[a]=(b[a]-c[a])/(1-c[a]):b[a]>c[a]?e[a]=(c[a]-b[a])/c[a]:e[a]=0}),e._red>e._green?e._red>e._blue?b._alpha=e._red:b._alpha=e._blue:e._green>e._blue?b._alpha=e._green:b._alpha=e._blue,b._alpha<d?b:(f.foreach(function(a){b[a]=(b[a]-c[a])/b._alpha+c[a]}),b._alpha*=e._alpha,b)}),typeof module!="undefined"&&(module.exports=one.color)})(isNaN,parseFloat,parseInt,Function,Math,Math.round,Math.min)
(function(a,b,c,d,e,f,g){function m(){var a=this.rgb(),b=a._red*.3+a._green*.59+a._blue*.11;return new l.RGB(b,b,b,this._alpha)}typeof one=="undefined"&&(one={include:function(){}});var h=[],i=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,j=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,k=new RegExp("^(rgb|hsl|hsv)a?\\("+i.source+","+i.source+","+i.source+"(?:,"+j.source+")?"+"\\)$","i"),l=one.color=function(a){if(Object.prototype.toString.apply(a)==="[object Array]")return a[0].length===4?new l.RGB(a[0]/255,a[1]/255,a[2]/255,a[3]/255):new l[a[0]](a.slice(1,a.length));if(a.charCodeAt){if(l.namedColors){var e=a.toLowerCase();l.namedColors[e]&&(a=l.namedColors[e])}var f=a.match(k);if(f){var g=f[1].toUpperCase(),h=typeof f[8]=="undefined"?f[8]:b(f[8]),i=g[0]==="H",j=f[3]?100:i?360:255,m=f[5]||i?100:255,n=f[7]||i?100:255;if(typeof l[g]=="undefined")throw new Error("one.color."+g+" is not installed.");return new l[g](b(f[2])/j,b(f[4])/m,b(f[6])/n,h)}a.length<6&&(a=a.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var o=a.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(o)return new l.RGB(c(o[1],16)/255,c(o[2],16)/255,c(o[3],16)/255)}else{if(typeof a=="object"&&a.isColor)return a;if(!d(a))return new l.RGB((a&255)/255,((a&65280)>>8)/255,((a&16711680)>>16)/255)}return!1};l.installColorSpace=function(b,c,d){function j(b,c){var d={};d[c.toLowerCase()]=new a("return this.rgb()."+c.toLowerCase()+"();"),l[c].propertyNames.forEach(function(b,e){d[b]=new a("value","isDelta","return this."+c.toLowerCase()+"()."+b+"(value, isDelta);")});for(var e in d)d.hasOwnProperty(e)&&l[b].prototype[e]===undefined&&(l[b].prototype[e]=d[e])}l[b]=new a(c.join(","),"if (Object.prototype.toString.apply("+c[0]+") === '[object Array]') {"+c.map(function(a,b){return a+"="+c[0]+"["+b+"];"}).reverse().join("")+"}"+"if ("+c.filter(function(a){return a!=="alpha"}).map(function(a){return"isNaN("+a+")"}).join("||")+"){"+'throw new Error("[one.color.'+b+']: Invalid color: ("+'+c.join('+","+')+'+")");}'+c.map(function(a){return a==="hue"?"this._hue=hue<0?hue-Math.floor(hue):hue%1":a==="alpha"?"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);":"this._"+a+"="+a+"<0?0:("+a+">1?1:"+a+")"}).join(";")+";"),l[b].propertyNames=c;var f=l[b].prototype;["valueOf","hex","css","cssa"].forEach(function(c){f[c]=f[c]||(b==="RGB"?f.hex:new a("return this.rgb()."+c+"();"))}),f.isColor=!0,f.equals=function(a,d){typeof d=="undefined"&&(d=1e-10),a=a[b.toLowerCase()]();for(var f=0;f<c.length;f+=1)if(e.abs(this["_"+c[f]]-a["_"+c[f]])>d)return!1;return!0},f.toJSON=new a("return ['"+b+"', "+c.map(function(a){return"this._"+a},this).join(", ")+"];");for(var g in d)if(d.hasOwnProperty(g)){var i=g.match(/^from(.*)$/);i?l[i[1].toUpperCase()].prototype[b.toLowerCase()]=d[g]:f[g]=d[g]}f[b.toLowerCase()]=function(){return this},f.toString=new a('return "[one.color.'+b+':"+'+c.map(function(a,b){return'" '+c[b]+'="+this._'+a}).join("+")+'+"]";'),c.forEach(function(b,d){f[b]=new a("value","isDelta","if (typeof value === 'undefined') {return this._"+b+";"+"}"+"if (isDelta) {"+"return new this.constructor("+c.map(function(a,c){return"this._"+a+(b===a?"+value":"")}).join(", ")+");"+"}"+"return new this.constructor("+c.map(function(a,c){return b===a?"value":"this._"+a}).join(", ")+");")}),h.forEach(function(a){j(b,a),j(a,b)}),h.push(b)},l.installMethod=function(a,b){h.forEach(function(c){l[c].prototype[a]=b})},l.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var a=(f(255*this._red)*65536+f(255*this._green)*256+f(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-a.length)+a},css:function(){return"rgb("+f(255*this._red)+","+f(255*this._green)+","+f(255*this._blue)+")"},cssa:function(){return"rgba("+f(255*this._red)+","+f(255*this._green)+","+f(255*this._blue)+","+this._alpha+")"}}),l.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var a=this._hue,b=this._saturation,c=this._value,d=g(5,e.floor(a*6)),f=a*6-d,h=c*(1-b),i=c*(1-f*b),j=c*(1-(1-f)*b),k,m,n;switch(d){case 0:k=c,m=j,n=h;break;case 1:k=i,m=c,n=h;break;case 2:k=h,m=c,n=j;break;case 3:k=h,m=i,n=c;break;case 4:k=j,m=h,n=c;break;case 5:k=c,m=h,n=i}return new l.RGB(k,m,n,this._alpha)},hsl:function(){var a=(2-this._saturation)*this._value,b=this._saturation*this._value,c=a<=1?a:2-a,d;return c<1e-9?d=0:d=b/c,new l.HSL(this._hue,d,a/2,this._alpha)},fromRgb:function(){var a=this._red,b=this._green,c=this._blue,d=e.max(a,b,c),f=g(a,b,c),h=d-f,i,j=d===0?0:h/d,k=d;if(h===0)i=0;else switch(d){case a:i=(b-c)/h/6+(b<c?1:0);break;case b:i=(c-a)/h/6+1/3;break;case c:i=(a-b)/h/6+2/3}return new l.HSV(i,j,k,this._alpha)}}),l.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*(a<=1?a:2-a),c;return a+b<1e-9?c=0:c=2*b/(a+b),new l.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}}),l.installColorSpace("CMYK",["cyan","magenta","yellow","black","alpha"],{rgb:function(){return new l.RGB(1-this._cyan*(1-this._black)-this._black,1-this._magenta*(1-this._black)-this._black,1-this._yellow*(1-this._black)-this._black,this._alpha)},fromRgb:function(){var a=this._red,b=this._green,c=this._blue,d=1-a,e=1-b,f=1-c,h=1;return a||b||c?(h=g(d,g(e,f)),d=(d-h)/(1-h),e=(e-h)/(1-h),f=(f-h)/(1-h)):h=1,new l.CMYK(d,e,f,h,this._alpha)}}),l.namedColors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},l.installMethod("clearer",function(a){return a=d(a)?.1:a,this.alpha(-a,!0)}),l.installMethod("darken",function(a){return a=d(a)?.1:a,this.lightness(-a,!0)}),l.installMethod("saturate",function(a){return a=d(a)?.1:a,this.saturation(-a,!0)}),l.installMethod("greyscale",m),l.installMethod("grayscale",m),l.installMethod("lighten",function(a){return a=d(a)?.1:a,this.lightness(a,!0)}),l.installMethod("mix",function(a,b){var a=l(a),b=1-(b||.5),c=b*2-1,d=this._alpha-a._alpha,e=((c*d==-1?c:(c+d)/(1+c*d))+1)/2,f=1-e,g=this.rgb(),a=a.rgb();return new l.RGB(this._red*e+a._red*f,this._green*e+a._green*f,this._blue*e+a._blue*f,this._alpha*b+a._alpha*(1-b))}),l.installMethod("negate",function(){var a=this.rgb();return new l.RGB(1-a._red,1-a._green,1-a._blue,this._alpha)}),l.installMethod("opaquer",function(a){return a=d(a)?.1:a,this.alpha(a,!0)}),l.installMethod("rotate",function(a){return amount=(a||0)/360,this.hue(amount,!0)}),l.installMethod("saturate",function(a){return a=d(a)?.1:a,this.saturation(a,!0)}),l.installMethod("toAlpha",function(a){var b=this.rgb(),c=l(a).rgb(),d=1e-10,e=new l.RGB(0,0,0,b._alpha),f=["_red","_green","_blue"];return f.forEach(function(a){b[a]<d?e[a]=b[a]:b[a]>c[a]?e[a]=(b[a]-c[a])/(1-c[a]):b[a]>c[a]?e[a]=(c[a]-b[a])/c[a]:e[a]=0}),e._red>e._green?e._red>e._blue?b._alpha=e._red:b._alpha=e._blue:e._green>e._blue?b._alpha=e._green:b._alpha=e._blue,b._alpha<d?b:(f.foreach(function(a){b[a]=(b[a]-c[a])/b._alpha+c[a]}),b._alpha*=e._alpha,b)}),typeof module!="undefined"&&(module.exports=l)})(Function,parseFloat,parseInt,isNaN,Math,Math.round,Math.min)

@@ -505,97 +505,93 @@ /*global one*/

*/
(function () {
var MATH = Math,
ONECOLOR = one.color;
ONECOLOR.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {
rgb: function () {
var hue = this._hue,
saturation = this._saturation,
value = this._value,
i = MATH.min(5, MATH.floor(hue * 6)),
f = hue * 6 - i,
p = value * (1 - saturation),
q = value * (1 - f * saturation),
t = value * (1 - (1 - f) * saturation),
red,
green,
blue;
switch (i) {
case 0:
red = value;
green = t;
blue = p;
ONECOLOR.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {
rgb: function () {
var hue = this._hue,
saturation = this._saturation,
value = this._value,
i = Math.min(5, Math.floor(hue * 6)),
f = hue * 6 - i,
p = value * (1 - saturation),
q = value * (1 - f * saturation),
t = value * (1 - (1 - f) * saturation),
red,
green,
blue;
switch (i) {
case 0:
red = value;
green = t;
blue = p;
break;
case 1:
red = q;
green = value;
blue = p;
break;
case 2:
red = p;
green = value;
blue = t;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
}
return new ONECOLOR.RGB(red, green, blue, this._alpha);
},
hsl: function () {
var l = (2 - this._saturation) * this._value,
sv = this._saturation * this._value,
svDivisor = l <= 1 ? l : (2 - l),
saturation;
// Avoid division by zero when lightness approaches zero:
if (svDivisor < 1e-9) {
saturation = 0;
} else {
saturation = sv / svDivisor;
}
return new ONECOLOR.HSL(this._hue, saturation, l / 2, this._alpha);
},
fromRgb: function () { // Becomes one.color.RGB.prototype.hsv
var red = this._red,
green = this._green,
blue = this._blue,
max = Math.max(red, green, blue),
min = Math.min(red, green, blue),
delta = max - min,
hue,
saturation = (max === 0) ? 0 : (delta / max),
value = max;
if (delta === 0) {
hue = 0;
} else {
switch (max) {
case red:
hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);
break;
case 1:
red = q;
green = value;
blue = p;
case green:
hue = (blue - red) / delta / 6 + 1 / 3;
break;
case 2:
red = p;
green = value;
blue = t;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
}
return new ONECOLOR.RGB(red, green, blue, this._alpha);
},
hsl: function () {
var l = (2 - this._saturation) * this._value,
sv = this._saturation * this._value,
svDivisor = l <= 1 ? l : (2 - l),
saturation;
// Avoid division by zero when lightness approaches zero:
if (svDivisor < 1e-9) {
saturation = 0;
} else {
saturation = sv / svDivisor;
}
return new ONECOLOR.HSL(this._hue, saturation, l / 2, this._alpha);
},
fromRgb: function () { // Becomes one.color.RGB.prototype.hsv
var red = this._red,
green = this._green,
blue = this._blue,
max = MATH.max(red, green, blue),
min = MATH.min(red, green, blue),
delta = max - min,
hue,
saturation = (max === 0) ? 0 : (delta / max),
value = max;
if (delta === 0) {
hue = 0;
} else {
switch (max) {
case red:
hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);
break;
case green:
hue = (blue - red) / delta / 6 + 1 / 3;
break;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
break;
}
}
return new ONECOLOR.HSV(hue, saturation, value, this._alpha);
}
});
}());
return new ONECOLOR.HSV(hue, saturation, value, this._alpha);
}
});

@@ -634,3 +630,3 @@ /*global one*/

one.color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {
ONECOLOR.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {
hsv: function () {

@@ -649,3 +645,3 @@ // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts

return new one.color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);
return new ONECOLOR.HSV(this._hue, saturation, (l + s) / 2, this._alpha);
},

@@ -771,4 +767,4 @@

if (typeof module !== 'undefined') {
module.exports = one.color;
module.exports = ONECOLOR;
}

@@ -1,1 +0,1 @@

(function(a,b,c,d,e){typeof one=="undefined"&&(one={include:function(){}});var f=[],g=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,h=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,i=new RegExp("^(rgb|hsl|hsv)a?\\("+g.source+","+g.source+","+g.source+"(?:,"+h.source+")?"+"\\)$","i"),j=one.color=function(c){if(Object.prototype.toString.apply(c)==="[object Array]")return c[0].length===4?new j.RGB(c[0]/255,c[1]/255,c[2]/255,c[3]/255):new j[c[0]](c.slice(1,c.length));if(c.charCodeAt){if(j.namedColors){var d=c.toLowerCase();j.namedColors[d]&&(c=j.namedColors[d])}var e=c.match(i);if(e){var f=e[1].toUpperCase(),g=typeof e[8]=="undefined"?e[8]:a(e[8]),h=f[0]==="H",k=e[3]?100:h?360:255,l=e[5]||h?100:255,m=e[7]||h?100:255;if(typeof j[f]=="undefined")throw new Error("one.color."+f+" is not installed.");return new j[f](a(e[2])/k,a(e[4])/l,a(e[6])/m,g)}c.length<6&&(c=c.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var n=c.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(n)return new j.RGB(b(n[1],16)/255,b(n[2],16)/255,b(n[3],16)/255)}else{if(typeof c=="object"&&c.isColor)return c;if(!isNaN(c))return new j.RGB((c&255)/255,((c&65280)>>8)/255,((c&16711680)>>16)/255)}return!1};j.installColorSpace=function(a,b,e){function k(a,b){var d={};d[b.toLowerCase()]=new c("return this.rgb()."+b.toLowerCase()+"();"),j[b].propertyNames.forEach(function(a,e){d[a]=new c("value","isDelta","return this."+b.toLowerCase()+"()."+a+"(value, isDelta);")});for(var e in d)d.hasOwnProperty(e)&&j[a].prototype[e]===undefined&&(j[a].prototype[e]=d[e])}j[a]=new c(b.join(","),"if (Object.prototype.toString.apply("+b[0]+") === '[object Array]') {"+b.map(function(a,c){return a+"="+b[0]+"["+c+"];"}).reverse().join("")+"}"+"if ("+b.filter(function(a){return a!=="alpha"}).map(function(a){return"isNaN("+a+")"}).join("||")+"){"+'throw new Error("[one.color.'+a+']: Invalid color: ("+'+b.join('+","+')+'+")");}'+b.map(function(a){return a==="hue"?"this._hue=hue<0?hue-Math.floor(hue):hue%1":a==="alpha"?"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);":"this._"+a+"="+a+"<0?0:("+a+">1?1:"+a+")"}).join(";")+";"),j[a].propertyNames=b;var g=j[a].prototype;["valueOf","hex","css","cssa"].forEach(function(b){g[b]=g[b]||(a==="RGB"?g.hex:new c("return this.rgb()."+b+"();"))}),g.isColor=!0,g.equals=function(c,e){typeof e=="undefined"&&(e=1e-10),c=c[a.toLowerCase()]();for(var f=0;f<b.length;f+=1)if(d.abs(this["_"+b[f]]-c["_"+b[f]])>e)return!1;return!0},g.toJSON=new c("return ['"+a+"', "+b.map(function(a){return"this._"+a},this).join(", ")+"];");for(var h in e)if(e.hasOwnProperty(h)){var i=h.match(/^from(.*)$/);i?j[i[1].toUpperCase()].prototype[a.toLowerCase()]=e[h]:g[h]=e[h]}g[a.toLowerCase()]=function(){return this},g.toString=new c('return "[one.color.'+a+':"+'+b.map(function(a,c){return'" '+b[c]+'="+this._'+a}).join("+")+'+"]";'),b.forEach(function(a,d){g[a]=new c("value","isDelta","if (typeof value === 'undefined') {return this._"+a+";"+"}"+"if (isDelta) {"+"return new this.constructor("+b.map(function(b,c){return"this._"+b+(a===b?"+value":"")}).join(", ")+");"+"}"+"return new this.constructor("+b.map(function(b,c){return a===b?"value":"this._"+b}).join(", ")+");")}),f.forEach(function(b){k(a,b),k(b,a)}),f.push(a)},j.installMethod=function(a,b){f.forEach(function(c){j[c].prototype[a]=b})},j.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var a=(e(255*this._red)*65536+e(255*this._green)*256+e(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-a.length)+a},css:function(){return"rgb("+e(255*this._red)+","+e(255*this._green)+","+e(255*this._blue)+")"},cssa:function(){return"rgba("+e(255*this._red)+","+e(255*this._green)+","+e(255*this._blue)+","+this._alpha+")"}}),function(){var a=d,b=one.color;b.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var c=this._hue,d=this._saturation,e=this._value,f=a.min(5,a.floor(c*6)),g=c*6-f,h=e*(1-d),i=e*(1-g*d),j=e*(1-(1-g)*d),k,l,m;switch(f){case 0:k=e,l=j,m=h;break;case 1:k=i,l=e,m=h;break;case 2:k=h,l=e,m=j;break;case 3:k=h,l=i,m=e;break;case 4:k=j,l=h,m=e;break;case 5:k=e,l=h,m=i}return new b.RGB(k,l,m,this._alpha)},hsl:function(){var a=(2-this._saturation)*this._value,c=this._saturation*this._value,d=a<=1?a:2-a,e;return d<1e-9?e=0:e=c/d,new b.HSL(this._hue,e,a/2,this._alpha)},fromRgb:function(){var c=this._red,d=this._green,e=this._blue,f=a.max(c,d,e),g=a.min(c,d,e),h=f-g,i,j=f===0?0:h/f,k=f;if(h===0)i=0;else switch(f){case c:i=(d-e)/h/6+(d<e?1:0);break;case d:i=(e-c)/h/6+1/3;break;case e:i=(c-d)/h/6+2/3}return new b.HSV(i,j,k,this._alpha)}})}(),one.color.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*(a<=1?a:2-a),c;return a+b<1e-9?c=0:c=2*b/(a+b),new one.color.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}}),typeof module!="undefined"&&(module.exports=one.color)})(parseFloat,parseInt,Function,Math,Math.round)
(function(a,b,c,d,e,f){typeof one=="undefined"&&(one={include:function(){}});var g=[],h=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,i=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,j=new RegExp("^(rgb|hsl|hsv)a?\\("+h.source+","+h.source+","+h.source+"(?:,"+i.source+")?"+"\\)$","i"),k=one.color=function(a){if(Object.prototype.toString.apply(a)==="[object Array]")return a[0].length===4?new k.RGB(a[0]/255,a[1]/255,a[2]/255,a[3]/255):new k[a[0]](a.slice(1,a.length));if(a.charCodeAt){if(k.namedColors){var d=a.toLowerCase();k.namedColors[d]&&(a=k.namedColors[d])}var e=a.match(j);if(e){var f=e[1].toUpperCase(),g=typeof e[8]=="undefined"?e[8]:b(e[8]),h=f[0]==="H",i=e[3]?100:h?360:255,l=e[5]||h?100:255,m=e[7]||h?100:255;if(typeof k[f]=="undefined")throw new Error("one.color."+f+" is not installed.");return new k[f](b(e[2])/i,b(e[4])/l,b(e[6])/m,g)}a.length<6&&(a=a.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var n=a.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(n)return new k.RGB(c(n[1],16)/255,c(n[2],16)/255,c(n[3],16)/255)}else{if(typeof a=="object"&&a.isColor)return a;if(!isNaN(a))return new k.RGB((a&255)/255,((a&65280)>>8)/255,((a&16711680)>>16)/255)}return!1};k.installColorSpace=function(b,c,e){function j(b,c){var d={};d[c.toLowerCase()]=new a("return this.rgb()."+c.toLowerCase()+"();"),k[c].propertyNames.forEach(function(b,e){d[b]=new a("value","isDelta","return this."+c.toLowerCase()+"()."+b+"(value, isDelta);")});for(var e in d)d.hasOwnProperty(e)&&k[b].prototype[e]===undefined&&(k[b].prototype[e]=d[e])}k[b]=new a(c.join(","),"if (Object.prototype.toString.apply("+c[0]+") === '[object Array]') {"+c.map(function(a,b){return a+"="+c[0]+"["+b+"];"}).reverse().join("")+"}"+"if ("+c.filter(function(a){return a!=="alpha"}).map(function(a){return"isNaN("+a+")"}).join("||")+"){"+'throw new Error("[one.color.'+b+']: Invalid color: ("+'+c.join('+","+')+'+")");}'+c.map(function(a){return a==="hue"?"this._hue=hue<0?hue-Math.floor(hue):hue%1":a==="alpha"?"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);":"this._"+a+"="+a+"<0?0:("+a+">1?1:"+a+")"}).join(";")+";"),k[b].propertyNames=c;var f=k[b].prototype;["valueOf","hex","css","cssa"].forEach(function(c){f[c]=f[c]||(b==="RGB"?f.hex:new a("return this.rgb()."+c+"();"))}),f.isColor=!0,f.equals=function(a,e){typeof e=="undefined"&&(e=1e-10),a=a[b.toLowerCase()]();for(var f=0;f<c.length;f+=1)if(d.abs(this["_"+c[f]]-a["_"+c[f]])>e)return!1;return!0},f.toJSON=new a("return ['"+b+"', "+c.map(function(a){return"this._"+a},this).join(", ")+"];");for(var h in e)if(e.hasOwnProperty(h)){var i=h.match(/^from(.*)$/);i?k[i[1].toUpperCase()].prototype[b.toLowerCase()]=e[h]:f[h]=e[h]}f[b.toLowerCase()]=function(){return this},f.toString=new a('return "[one.color.'+b+':"+'+c.map(function(a,b){return'" '+c[b]+'="+this._'+a}).join("+")+'+"]";'),c.forEach(function(b,d){f[b]=new a("value","isDelta","if (typeof value === 'undefined') {return this._"+b+";"+"}"+"if (isDelta) {"+"return new this.constructor("+c.map(function(a,c){return"this._"+a+(b===a?"+value":"")}).join(", ")+");"+"}"+"return new this.constructor("+c.map(function(a,c){return b===a?"value":"this._"+a}).join(", ")+");")}),g.forEach(function(a){j(b,a),j(a,b)}),g.push(b)},k.installMethod=function(a,b){g.forEach(function(c){k[c].prototype[a]=b})},k.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var a=(e(255*this._red)*65536+e(255*this._green)*256+e(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-a.length)+a},css:function(){return"rgb("+e(255*this._red)+","+e(255*this._green)+","+e(255*this._blue)+")"},cssa:function(){return"rgba("+e(255*this._red)+","+e(255*this._green)+","+e(255*this._blue)+","+this._alpha+")"}}),k.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var a=this._hue,b=this._saturation,c=this._value,e=f(5,d.floor(a*6)),g=a*6-e,h=c*(1-b),i=c*(1-g*b),j=c*(1-(1-g)*b),l,m,n;switch(e){case 0:l=c,m=j,n=h;break;case 1:l=i,m=c,n=h;break;case 2:l=h,m=c,n=j;break;case 3:l=h,m=i,n=c;break;case 4:l=j,m=h,n=c;break;case 5:l=c,m=h,n=i}return new k.RGB(l,m,n,this._alpha)},hsl:function(){var a=(2-this._saturation)*this._value,b=this._saturation*this._value,c=a<=1?a:2-a,d;return c<1e-9?d=0:d=b/c,new k.HSL(this._hue,d,a/2,this._alpha)},fromRgb:function(){var a=this._red,b=this._green,c=this._blue,e=d.max(a,b,c),g=f(a,b,c),h=e-g,i,j=e===0?0:h/e,l=e;if(h===0)i=0;else switch(e){case a:i=(b-c)/h/6+(b<c?1:0);break;case b:i=(c-a)/h/6+1/3;break;case c:i=(a-b)/h/6+2/3}return new k.HSV(i,j,l,this._alpha)}}),k.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*(a<=1?a:2-a),c;return a+b<1e-9?c=0:c=2*b/(a+b),new k.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}}),typeof module!="undefined"&&(module.exports=k)})(Function,parseFloat,parseInt,Math,Math.round,Math.min)

@@ -5,3 +5,3 @@ {

"repository": "git@github.com:One-com/one-color.git",
"version": "2.2.1",
"version": "2.2.2",
"keywords": ["ender", "color", "colour"],

@@ -8,0 +8,0 @@ "maintainers": [

@@ -6,3 +6,3 @@ one.color

* RGB, HSV, and HSL colorspace support (a CMYK implementation also exists)
* RGB, HSV, HSL, and CMYK colorspace support (experimental implementations of LAB and XYZ)
* Legal values for all channels are 0..1

@@ -101,2 +101,18 @@ * Instances are immutable -- a new object is created for each manipulation

Comparing color objects
-----------------------
If you need to know if two colors represent the same 8 bit color, regardless
of colorspace, compare their `hex()` values:
one.color('#f00').hex() === one.color('#e00').red(1).hex() // true
Use the `equals` method to compare two color instances within a certain
epsilon (defaults to `1e-9`):
one.color('#e00').lightness(.00001, true).equals(one.color('#e00'), 1e-5) // false
one.color('#e00').lightness(.000001, true).equals(one.color('#e00'), 1e-5) // true
API overview

@@ -148,2 +164,6 @@ ============

color.alpha()
color.cyan() // one-color-all.js and node.js only
color.magenta() // one-color-all.js and node.js only
color.yellow() // one-color-all.js and node.js only
color.black() // one-color-all.js and node.js only

@@ -160,2 +180,6 @@ Setters -- return new color instances with one channel changed:

color.alpha(<number>)
color.cyan(<number>) // one-color-all.js and node.js only
color.magenta(<number>) // one-color-all.js and node.js only
color.yellow(<number>) // one-color-all.js and node.js only
color.black(<number>) // one-color-all.js and node.js only

@@ -173,6 +197,10 @@ Adjusters -- return new color instances with the channel adjusted by

color.alpha(<number>, true)
color.cyan(<number>, true) // one-color-all.js and node.js only
color.magenta(<number>, true) // one-color-all.js and node.js only
color.yellow(<number>, true) // one-color-all.js and node.js only
color.black(<number>, true) // one-color-all.js and node.js only
Comparison with other color objects (epsilon defaults to `1e-9`):
Comparison with other color objects, returns `true` or `false` (epsilon defaults to `1e-9`):
color.equals(otherColor, <epsilon>)
color.equals(otherColor[, <epsilon>])

@@ -185,6 +213,10 @@

new one.color.RGB(r, g, b[, a])
new one.color.HSL(h, s, l[, a])
new one.color.HSV(h, s, v[, a])
new one.color.RGB(<red>, <green>, <blue>[, <alpha>])
new one.color.HSL(<hue>, <saturation>, <lightness>[, <alpha>])
new one.color.HSV(<hue>, <saturation>, <value>[, <alpha>])
The `one-color-all.js` build includes CMYK support:
new one.color.CMYK(<cyan>, <magenta>, <yellow>, <black>[, <alpha>])
All color instances have `rgb()`, `hsv()`, and `hsl()` methods for

@@ -208,2 +240,3 @@ explicitly converting to another color space. Like the setter and

rgb: function () {
// ...
return new one.color.RGB(r, g, b, a);

@@ -215,2 +248,3 @@ },

fromRgb: function () {
// ...
return new one.color.MyColorSpace(x, y, z, a);

@@ -217,0 +251,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc