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.0.4 to 2.0.5

slides/3rdparty/CSSS/boilerplate.html

126

lib/one/color.js

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

*/
(function () {
(function (nameSpace, fn, parseint, parsefloat, round) {
var installedColorSpaces = [],

@@ -36,10 +36,10 @@ channelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,

function color(obj) {
nameSpace = function(obj) {
if (Object.prototype.toString.apply(obj) === '[object Array]') {
if (obj[0].length === 4) {
// Assumed 4 element int RGB array from canvas with all channels [0;255]
return new color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
return new nameSpace.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
} else {
// Assumed destringified array from one.color.JSON()
return new color[obj[0]](obj.slice(1, obj.length));
return new nameSpace[obj[0]](obj.slice(1, obj.length));
}

@@ -51,3 +51,3 @@ } else if (obj.charCodeAt) {

var colorSpaceName = matchCssSyntax[1].toUpperCase(),
alpha = typeof matchCssSyntax[8] === 'undefined' ? matchCssSyntax[8] : parseFloat(matchCssSyntax[8]),
alpha = typeof matchCssSyntax[8] === 'undefined' ? matchCssSyntax[8] : parsefloat(matchCssSyntax[8]),
hasHue = colorSpaceName[0] === 'H',

@@ -57,9 +57,9 @@ firstChannelDivisor = matchCssSyntax[3] ? 100 : (hasHue ? 360 : 255),

thirdChannelDivisor = (matchCssSyntax[7] || hasHue) ? 100 : 255;
if (typeof color[colorSpaceName] === 'undefined') {
if (typeof nameSpace[colorSpaceName] === 'undefined') {
throw new Error("one.color." + colorSpaceName + " is not installed.");
}
return new color[colorSpaceName](
parseFloat(matchCssSyntax[2]) / firstChannelDivisor,
parseFloat(matchCssSyntax[4]) / secondChannelDivisor,
parseFloat(matchCssSyntax[6]) / thirdChannelDivisor,
return new nameSpace[colorSpaceName](
parsefloat(matchCssSyntax[2]) / firstChannelDivisor,
parsefloat(matchCssSyntax[4]) / secondChannelDivisor,
parsefloat(matchCssSyntax[6]) / thirdChannelDivisor,
alpha

@@ -76,6 +76,6 @@ );

if (hexMatch) {
return new color.RGB(
parseInt(hexMatch[1], 16) / 255,
parseInt(hexMatch[2], 16) / 255,
parseInt(hexMatch[3], 16) / 255
return new nameSpace.RGB(
parseint(hexMatch[1], 16) / 255,
parseint(hexMatch[2], 16) / 255,
parseint(hexMatch[3], 16) / 255
);

@@ -87,3 +87,3 @@ }

// Strange integer representation sometimes returned by document.queryCommandValue in some browser...
return new color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
return new nameSpace.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
}

@@ -94,4 +94,4 @@ return false;

/*jslint evil:true*/
color.installColorSpace = function (colorSpaceName, propertyNames, config) {
color[colorSpaceName] = new Function(propertyNames.join(","),
nameSpace.installColorSpace = function (colorSpaceName, propertyNames, config) {
nameSpace[colorSpaceName] = new fn(propertyNames.join(","),
// Allow passing an array to the constructor:

@@ -118,8 +118,8 @@ "if (Object.prototype.toString.apply(" + propertyNames[0] + ") === '[object Array]') {" +

);
color[colorSpaceName].propertyNames = propertyNames;
nameSpace[colorSpaceName].propertyNames = propertyNames;
var prototype = color[colorSpaceName].prototype;
var prototype = nameSpace[colorSpaceName].prototype;
['valueOf', 'hex', 'css', 'cssa'].forEach(function (methodName) {
prototype[methodName] = prototype[methodName] || (colorSpaceName === 'RGB' ? prototype.hex : new Function("return this.rgb()." + methodName + "();"));
prototype[methodName] = prototype[methodName] || (colorSpaceName === 'RGB' ? prototype.hex : new fn("return this.rgb()." + methodName + "();"));
});

@@ -145,3 +145,3 @@

prototype.toJSON = new Function(
prototype.toJSON = new fn(
"return ['" + colorSpaceName + "', " +

@@ -158,3 +158,3 @@ propertyNames.map(function (propertyName) {

if (matchFromColorSpace) {
color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
nameSpace[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
} else {

@@ -170,3 +170,3 @@ prototype[propertyName] = config[propertyName];

};
prototype.toString = new Function("return \"[one.color." + colorSpaceName + ":\"+" + propertyNames.map(function (propertyName, i) {
prototype.toString = new fn("return \"[one.color." + colorSpaceName + ":\"+" + propertyNames.map(function (propertyName, i) {
return "\" " + propertyNames[i] + "=\"+this._" + propertyName;

@@ -177,3 +177,3 @@ }).join("+") + "+\"]\";");

propertyNames.forEach(function (propertyName, i) {
prototype[propertyName] = new Function("value", "isDelta",
prototype[propertyName] = new fn("value", "isDelta",
// Simple getter mode: color.red()

@@ -197,9 +197,9 @@ "if (typeof value === 'undefined') {" +

var obj = {};
obj[sourceColorSpaceName.toLowerCase()] = new Function("return this.rgb()." + sourceColorSpaceName.toLowerCase() + "();"); // Fallback
color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
obj[propertyName] = new Function("value", "isDelta", "return this." + sourceColorSpaceName.toLowerCase() + "()." + propertyName + "(value, isDelta);");
obj[sourceColorSpaceName.toLowerCase()] = new fn("return this.rgb()." + sourceColorSpaceName.toLowerCase() + "();"); // Fallback
nameSpace[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
obj[propertyName] = new fn("value", "isDelta", "return this." + sourceColorSpaceName.toLowerCase() + "()." + propertyName + "(value, isDelta);");
});
for (var prop in obj) {
if (obj.hasOwnProperty(prop) && color[targetColorSpaceName].prototype[prop] === undefined) {
color[targetColorSpaceName].prototype[prop] = obj[prop];
if (obj.hasOwnProperty(prop) && nameSpace[targetColorSpaceName].prototype[prop] === undefined) {
nameSpace[targetColorSpaceName].prototype[prop] = obj[prop];
}

@@ -217,39 +217,33 @@ }

one.color = color;
}());
/**
* @name one.color.RGB
* @class
* <p>A color in the RGB colorspace with an optional alpha value.</p>
* <p>one.color.(RGB|HSL|HSV|CMYK) objects are designed to be
* immutable; all the conversion, set, and adjust methods return new
* objects.</p>
* <p>one.color.(RGB|HSL|HSV|CMYK) objects automatically get the set
* and adjust methods from all other installed colorspaces, so
* although you can use the explicit conversion methods ({@link
* one.color.RGB#hsl}, {@link one.color.RGB#cmyk}...), the below
* will work just fine:</p><pre><code>
one.include('jslib:one/color.js');
one.include('jslib:one/color/HSL.js');
/**
* @name one.color.RGB
* @class
* <p>A color in the RGB colorspace with an optional alpha value.</p>
* <p>one.color.(RGB|HSL|HSV|CMYK) objects are designed to be
* immutable; all the conversion, set, and adjust methods return new
* objects.</p>
* <p>one.color.(RGB|HSL|HSV|CMYK) objects automatically get the set
* and adjust methods from all other installed colorspaces, so
* although you can use the explicit conversion methods ({@link
* one.color.RGB#hsl}, {@link one.color.RGB#cmyk}...), the below
* will work just fine:</p><pre><code>
one.include('jslib:one/color.js');
one.include('jslib:one/color/HSL.js');
new one.color.RGB(.4, .3, .9).
lightness(+.2, true). // Implicit conversion to HSL
red(-.1). // Implicit conversion back to RGB
hex(); // "#00a6f2"
</code></pre>
*
* @constructor
* Create a new one.color.RGB object. Values outside the supported
* range, [0..1], will be adjusted automatically.
* @param {Number} red The red component, range: [0..1]
* @param {Number} green The green component, range: [0..1]
* @param {Number} blue The blue component, range: [0..1]
* @param {Number} [alpha] The alpha value, range: [0..1],
* defaults to 1
*/
(function () {
var round = Math.round;
one.color.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], {
new one.color.RGB(.4, .3, .9).
lightness(+.2, true). // Implicit conversion to HSL
red(-.1). // Implicit conversion back to RGB
hex(); // "#00a6f2"
</code></pre>
*
* @constructor
* Create a new one.color.RGB object. Values outside the supported
* range, [0..1], will be adjusted automatically.
* @param {Number} red The red component, range: [0..1]
* @param {Number} green The green component, range: [0..1]
* @param {Number} blue The blue component, range: [0..1]
* @param {Number} [alpha] The alpha value, range: [0..1],
* defaults to 1
*/
nameSpace.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], {
/**

@@ -282,3 +276,3 @@ * Get the standard RGB hex representation of the color.

});
}());
}(one.color, Function, parseInt, parseFloat, Math.round));

@@ -285,0 +279,0 @@ /**

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

*/
one.color.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 one.color.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 one.color.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);
(function (nameSpace, math) {
nameSpace.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 green:
hue = (blue - red) / delta / 6 + 1 / 3;
case 1:
red = q;
green = value;
blue = p;
break;
case blue:
hue = (red - green) / delta / 6 + 2 / 3;
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 nameSpace.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 nameSpace.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 nameSpace.HSV(hue, saturation, value, this._alpha);
}
return new one.color.HSV(hue, saturation, value, this._alpha);
}
});
});
}(one.color, Math));

@@ -1,14 +0,15 @@

/*global one*/
/*global window*/
/**
* @namespace one One.com global JavaScript namespace.
* @exports one
* @exports window.one as one
*/
if (typeof one === 'undefined') {
one = {
include: function () {}
};
if (typeof window !== 'undefined') {
window.one = window.one || {};
} else {
var one = {};
}
one.include = one.exclude = function () {}; // Ignore these in development mode
/*global one*/

@@ -47,10 +48,10 @@

function color(obj) {
one.color = function (obj) {
if (Object.prototype.toString.apply(obj) === '[object Array]') {
if (obj[0].length === 4) {
// Assumed 4 element int RGB array from canvas with all channels [0;255]
return new color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
return new one.color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
} else {
// Assumed destringified array from one.color.JSON()
return new color[obj[0]](obj.slice(1, obj.length));
return new one.color[obj[0]](obj.slice(1, obj.length));
}

@@ -67,6 +68,6 @@ } else if (obj.charCodeAt) {

thirdChannelDivisor = (matchCssSyntax[7] || hasHue) ? 100 : 255;
if (typeof color[colorSpaceName] === 'undefined') {
if (!(colorSpaceName in one.color)) {
throw new Error("one.color." + colorSpaceName + " is not installed.");
}
return new color[colorSpaceName](
return new one.color[colorSpaceName](
parseFloat(matchCssSyntax[2]) / firstChannelDivisor,

@@ -86,3 +87,3 @@ parseFloat(matchCssSyntax[4]) / secondChannelDivisor,

if (hexMatch) {
return new color.RGB(
return new one.color.RGB(
parseInt(hexMatch[1], 16) / 255,

@@ -97,10 +98,10 @@ parseInt(hexMatch[2], 16) / 255,

// Strange integer representation sometimes returned by document.queryCommandValue in some browser...
return new color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
return new one.color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
}
return false;
}
};
/*jslint evil:true*/
color.installColorSpace = function (colorSpaceName, propertyNames, config) {
color[colorSpaceName] = new Function(propertyNames.join(","),
one.color.installColorSpace = function (colorSpaceName, propertyNames, config) {
one.color[colorSpaceName] = new Function(propertyNames.join(","),
// Allow passing an array to the constructor:

@@ -127,5 +128,5 @@ "if (Object.prototype.toString.apply(" + propertyNames[0] + ") === '[object Array]') {" +

);
color[colorSpaceName].propertyNames = propertyNames;
one.color[colorSpaceName].propertyNames = propertyNames;
var prototype = color[colorSpaceName].prototype;
var prototype = one.color[colorSpaceName].prototype;

@@ -166,3 +167,3 @@ ['valueOf', 'hex', 'css', 'cssa'].forEach(function (methodName) {

if (matchFromColorSpace) {
color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
one.color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
} else {

@@ -204,8 +205,8 @@ prototype[propertyName] = config[propertyName];

obj[sourceColorSpaceName.toLowerCase()] = new Function("return this.rgb()." + sourceColorSpaceName.toLowerCase() + "();"); // Fallback
color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
one.color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
obj[propertyName] = new Function("value", "isDelta", "return this." + sourceColorSpaceName.toLowerCase() + "()." + propertyName + "(value, isDelta);");
});
for (var prop in obj) {
if (obj.hasOwnProperty(prop) && color[targetColorSpaceName].prototype[prop] === undefined) {
color[targetColorSpaceName].prototype[prop] = obj[prop];
if (obj.hasOwnProperty(prop) && one.color[targetColorSpaceName].prototype[prop] === undefined) {
one.color[targetColorSpaceName].prototype[prop] = obj[prop];
}

@@ -222,4 +223,2 @@ }

};
one.color = color;
}());

@@ -226,0 +225,0 @@

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

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

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

"repository": "git@github.com:One-com/one-color.git",
"version": "2.0.4",
"version": "2.0.5",
"maintainers": [

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

"devDependencies": {
"assetgraph-builder": "= 0.2.36"
"assetgraph-builder": "= 0.2.36",
"uglify-js": ">=1.2.0",
"vows": "=0.6.1"
},

@@ -32,4 +34,4 @@ "engines": {

"scripts": {
"prepublish": "make"
"prepublish": "make; vows"
}
}

Sorry, the diff of this file is not supported yet

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