diff --git a/.editorconfig b/.editorconfig index 63bd83c..68c9a74 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,7 +16,7 @@ insert_final_newline = true ; Indentation indent_style = space -indent_size = 4 +indent_size = 2 [Makefile] indent_style = tab diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..0d0e877 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +/node_modules/ +/demo/ +/slides/ +/one-color-all.js +/one-color.js +/coverage/ diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..dc577f8 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,12 @@ +{ + "extends": ["standard", "prettier", "prettier/standard"], + "plugins": ["import", "mocha"], + "env": { + "mocha": true + }, + "rules": { + "mocha/no-exclusive-tests": "error", + "mocha/no-nested-tests": "error", + "mocha/no-identical-title": "error" + } +} diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index 3df53d5..0000000 --- a/.jshintignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -demo -slides -one-color-all.js -one-color.js -coverage diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index a74fe2b..0000000 --- a/.jshintrc +++ /dev/null @@ -1,78 +0,0 @@ -{ - // JSHint Default Configuration File (as on JSHint website) - // See http://jshint.com/docs/ for more details - - "maxerr" : 50, // {int} Maximum error before stopping - - // Enforcing - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : true, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : 2, // {int} Number of spaces to use for indentation - "latedef" : true, // true: Require variables/functions to be defined before being used - "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : true, // true: Prohibit use of `++` & `--` - "quotmark" : "single", // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used - "strict" : "implied", // true: Requires all functions run in ES5 Strict Mode - "trailing" : true, // true: Prohibit trailing whitespaces - "maxparams" : false, // {int} Max number of formal params allowed per function - "maxdepth" : false, // {int} Max depth of nested blocks (within functions) - "maxstatements" : false, // {int} Max number statements per function - "maxcomplexity" : false, // {int} Max cyclomatic complexity per function - "maxlen" : false, // {int} Max number of characters per line - - // Relaxing - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : false, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : false, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements" - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : false, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function - - // Environments - "browser" : false, // Web Browser (window, document, etc) - "devel" : false, // Development/debugging (alert, confirm, etc) - "mocha" : true, // Mocha - "node" : true, // Node.js - "nonstandard" : true, // Widely adopted globals (escape, unescape, etc) - - // Legacy - "nomen" : false, // true: Prohibit dangling `_` in variables - "onevar" : false, // true: Allow only one `var` statement per function - "passfail" : false, // true: Stop on first error - "white" : true, // true: Check against strict whitespace and indentation rules - - // Custom Globals - "predef" : [ // additional predefined global variables - ] -} diff --git a/.npmrc b/.npmrc index cffe8cd..c1ca392 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -save-exact=true +package-lock = false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..0d0e877 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +/node_modules/ +/demo/ +/slides/ +/one-color-all.js +/one-color.js +/coverage/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..544138b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/.travis.yml b/.travis.yml index 1296a46..04db955 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,14 +3,28 @@ services: language: node_js cache: directories: - - node_modules + - node_modules node_js: - - "0.10" - - "0.12" - - "1" - - "2" - - "3" - - "4" + - '0.12' + - '1' + - '2' + - '3' + - '4' + - '6' + - '8' + - '10' + - '12' + - '14' + - node -script: "npm run-script travis" -after_success: "one-color.js to one-color-all.js to gain named color support): ```html - + ``` -In node.js (after `npm install onecolor`): +In the browser, the parser is exposed as a global named `onecolor`. +In node.js, it is returned directly with a require of the module +(after `npm install onecolor`): ```javascript var color = require('onecolor'); -console.warn(color('rgba(100%, 0%, 0%, .5)').alpha(.4).cssa()); // 'rgba(255,0,0,0.4)' +console.warn(color('rgba(100%, 0%, 0%, .5)').alpha(0.4).cssa()); +``` + +```output +rgba(255,0,0,0.4) ``` -`one.color` is the parser. All of the above return color instances in -the relevant color space with the channel values (0..1) as instance -variables: +All of the above return color instances in the relevant color space +with the channel values (0..1) as instance variables: ```javascript -var myColor = one.color('#a9d91d'); -myColor instanceof one.color.RGB; // true -myColor.red() // 0.6627450980392157 +var myColor = color('#a9d91d'); +myColor instanceof color.RGB; // true +myColor.red(); // 0.6627450980392157 ``` You can also parse named CSS colors (works out of the box in node.js, @@ -63,15 +76,15 @@ but the requires the slightly bigger one-color-all.js build adds support for the standard suite of named CSS colors: ```javascript -one.color('maroon') -one.color('darkolivegreen') +color('maroon'); +color('darkolivegreen'); ``` -Existing one.color instances pass through unchanged, which is useful +Existing onecolor instances pass through unchanged, which is useful in APIs where you want to accept either a string or a color instance: ```javascript -one.color(one.color('#fff')) // Same as one.color('#fff') +color(color('#fff')); // Same as color('#fff') ``` Serialization methods: ```javascript -color.hex() // 6-digit hex string: '#bda65b' -color.css() // CSS rgb syntax: 'rgb(10,128,220)' -color.cssa() // CSS rgba syntax: 'rgba(10,128,220,0.8)' -color.toString() // For debugging: '[one.color.RGB: Red=0.3 Green=0.8 Blue=0 Alpha=1]' -color.toJSON() // ["RGB"|"HSV"|"HSL", , , , ] +var myColor = color('#bda65b'); + +myColor.hex(); // 6-digit hex string: '#bda65b' +myColor.css(); // CSS rgb syntax: 'rgb(10,128,220)' +myColor.cssa(); // CSS rgba syntax: 'rgba(10,128,220,0.8)' +myColor.toString(); // For debugging: '[onecolor.RGB: Red=0.3 Green=0.8 Blue=0 Alpha=1]' +myColor.toJSON(); // ["RGB"|"HSV"|"HSL", , , , ] ``` Getters -- return the value of the channel (converts to other colorspaces as needed): ```javascript -color.red() -color.green() -color.blue() -color.hue() -color.saturation() -color.value() -color.lightness() -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 +var myColor = color('#bda65b'); + +myColor.red(); +myColor.green(); +myColor.blue(); +myColor.hue(); +myColor.saturation(); +myColor.value(); +myColor.lightness(); +myColor.alpha(); +myColor.cyan(); // one-color-all.js and node.js only +myColor.magenta(); // one-color-all.js and node.js only +myColor.yellow(); // one-color-all.js and node.js only +myColor.black(); // one-color-all.js and node.js only ``` Setters -- return new color instances with one channel changed: + + ```javascript color.red() color.green() @@ -237,6 +250,8 @@ color.black() // one-color-all.js and node.js only Adjusters -- return new color instances with the channel adjusted by the specified delta (0..1): + + ```javascript color.red(, true) color.green(, true) @@ -251,26 +266,29 @@ color.magenta(, true) // one-color-all.js and node.js only color.yellow(, true) // one-color-all.js and node.js only color.black(, true) // one-color-all.js and node.js only ``` + Comparison with other color objects, returns `true` or `false` (epsilon defaults to `1e-9`): + + ```javascript color.equals(otherColor[, ]) ``` -Mostly for internal (and plugin) use: -------------------------------------- +## Mostly for internal (and plugin) use: "Low level" constructors, accept 3 or 4 numerical arguments (0..1): ```javascript -new one.color.RGB(, , [, ]) -new one.color.HSL(, , [, ]) -new one.color.HSV(, , [, ]) +new onecolor.RGB(, , [, ]) +new onecolor.HSL(, , [, ]) +new onecolor.HSV(, , [, ]) ``` + The one-color-all.js build includes CMYK support: ```javascript -new one.color.CMYK(, , , [, ]) +new onecolor.CMYK(, , , [, ]) ``` All color instances have `rgb()`, `hsv()`, and `hsl()` methods for @@ -283,13 +301,18 @@ specific colorspace, do an explicit conversion first to cut down on the number of implicit conversions: ```javascript -var myColor = one.color('#0620ff').lightness(+.3).rgb(); -// Alerts '0 0.06265060240963878 0.5999999999999999': -alert(myColor.red() + ' ' + myColor.green() + ' ' + myColor.blue()); +var myColor = color('#0620ff') + .lightness(+0.3) + .rgb(); + +console.log(myColor.red() + ' ' + myColor.green() + ' ' + myColor.blue()); +``` + +```output +0 0.06265060240963878 0.5999999999999999 ``` -Building -======== +# Building ``` git clone https://github.com/One-com/one-color.git @@ -301,10 +324,9 @@ npm run build If you aren't up for a complete installation, there are pre-built packages in the repository as well as the npm package: -* Basic library: one-color.js -* Full library including named color support: one-color-all.js +- Basic library: one-color.js +- Full library including named color support: one-color-all.js -License -======= +# License -one.color is licensed under a standard 2-clause BSD license -- see the `LICENSE` file for details. +onecolor is licensed under a standard 2-clause BSD license -- see the `LICENSE` file for details. diff --git a/index.js b/index.js index 54446a1..41ae8e6 100644 --- a/index.js +++ b/index.js @@ -1,20 +1,24 @@ module.exports = require('./lib/color') - .use(require('./lib/XYZ')) - .use(require('./lib/LAB')) - .use(require('./lib/HSV')) - .use(require('./lib/HSL')) - .use(require('./lib/CMYK')) + .use(require('./lib/XYZ')) + .use(require('./lib/LAB')) + .use(require('./lib/HSV')) + .use(require('./lib/HSL')) + .use(require('./lib/CMYK')) - // Convenience functions - .use(require('./lib/plugins/namedColors')) - .use(require('./lib/plugins/clearer.js')) - .use(require('./lib/plugins/darken.js')) - .use(require('./lib/plugins/desaturate.js')) - .use(require('./lib/plugins/grayscale.js')) - .use(require('./lib/plugins/lighten.js')) - .use(require('./lib/plugins/mix.js')) - .use(require('./lib/plugins/negate.js')) - .use(require('./lib/plugins/opaquer.js')) - .use(require('./lib/plugins/rotate.js')) - .use(require('./lib/plugins/saturate.js')) - .use(require('./lib/plugins/toAlpha.js')); + // Convenience functions + .use(require('./lib/plugins/namedColors')) + .use(require('./lib/plugins/clearer.js')) + .use(require('./lib/plugins/contrast.js')) + .use(require('./lib/plugins/darken.js')) + .use(require('./lib/plugins/desaturate.js')) + .use(require('./lib/plugins/grayscale.js')) + .use(require('./lib/plugins/isDark.js')) + .use(require('./lib/plugins/isLight.js')) + .use(require('./lib/plugins/lighten.js')) + .use(require('./lib/plugins/luminance.js')) + .use(require('./lib/plugins/mix.js')) + .use(require('./lib/plugins/negate.js')) + .use(require('./lib/plugins/opaquer.js')) + .use(require('./lib/plugins/rotate.js')) + .use(require('./lib/plugins/saturate.js')) + .use(require('./lib/plugins/toAlpha.js')); diff --git a/lib/CMYK.js b/lib/CMYK.js index 8d97461..9fbfba4 100644 --- a/lib/CMYK.js +++ b/lib/CMYK.js @@ -1,30 +1,37 @@ module.exports = function CMYK(color) { - color.installColorSpace('CMYK', ['cyan', 'magenta', 'yellow', 'black', 'alpha'], { - rgb: function () { - return new 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); - }, + color.installColorSpace( + 'CMYK', + ['cyan', 'magenta', 'yellow', 'black', 'alpha'], + { + rgb: function () { + return new 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 () { // Becomes one.color.RGB.prototype.cmyk - // Adapted from http://www.javascripter.net/faq/rgb2cmyk.htm - var red = this._red, - green = this._green, - blue = this._blue, - cyan = 1 - red, - magenta = 1 - green, - yellow = 1 - blue, - black = 1; - if (red || green || blue) { - black = Math.min(cyan, Math.min(magenta, yellow)); - cyan = (cyan - black) / (1 - black); - magenta = (magenta - black) / (1 - black); - yellow = (yellow - black) / (1 - black); - } else { - black = 1; - } - return new color.CMYK(cyan, magenta, yellow, black, this._alpha); + fromRgb: function () { + // Becomes one.color.RGB.prototype.cmyk + // Adapted from http://www.javascripter.net/faq/rgb2cmyk.htm + var red = this._red; + var green = this._green; + var blue = this._blue; + var cyan = 1 - red; + var magenta = 1 - green; + var yellow = 1 - blue; + var black = 1; + if (red || green || blue) { + black = Math.min(cyan, Math.min(magenta, yellow)); + cyan = (cyan - black) / (1 - black); + magenta = (magenta - black) / (1 - black); + yellow = (yellow - black) / (1 - black); + } else { + black = 1; } - }); + return new color.CMYK(cyan, magenta, yellow, black, this._alpha); + }, + } + ); }; diff --git a/lib/HSL.js b/lib/HSL.js index 60f8d18..cfea9d1 100644 --- a/lib/HSL.js +++ b/lib/HSL.js @@ -1,29 +1,30 @@ module.exports = function HSL(color) { - color.use(require('./HSV')); + color.use(require('./HSV')); - color.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; + color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], { + hsv: function () { + // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts + var l = this._lightness * 2; + var s = this._saturation * (l <= 1 ? l : 2 - l); + var 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); - } + // 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 color.HSV(this._hue, saturation, (l + s) / 2, this._alpha); - }, + return new color.HSV(this._hue, saturation, (l + s) / 2, this._alpha); + }, - rgb: function () { - return this.hsv().rgb(); - }, + rgb: function () { + return this.hsv().rgb(); + }, - fromRgb: function () { // Becomes one.color.RGB.prototype.hsv - return this.hsv().hsl(); - } - }); + fromRgb: function () { + // Becomes one.color.RGB.prototype.hsv + return this.hsv().hsl(); + }, + }); }; diff --git a/lib/HSV.js b/lib/HSV.js index 246a498..d29c100 100644 --- a/lib/HSV.js +++ b/lib/HSV.js @@ -1,93 +1,94 @@ module.exports = function HSV(color) { - 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 color.RGB(red, green, blue, this._alpha); - }, + color.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], { + rgb: function () { + var hue = this._hue; + var saturation = this._saturation; + var value = this._value; + var i = Math.min(5, Math.floor(hue * 6)); + var f = hue * 6 - i; + var p = value * (1 - saturation); + var q = value * (1 - f * saturation); + var t = value * (1 - (1 - f) * saturation); + var red; + var green; + var 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 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; + hsl: function () { + var l = (2 - this._saturation) * this._value; + var sv = this._saturation * this._value; + var svDivisor = l <= 1 ? l : 2 - l; + var saturation; - // Avoid division by zero when lightness approaches zero: - if (svDivisor < 1e-9) { - saturation = 0; - } else { - saturation = sv / svDivisor; - } - return new color.HSL(this._hue, saturation, l / 2, this._alpha); - }, + // Avoid division by zero when lightness approaches zero: + if (svDivisor < 1e-9) { + saturation = 0; + } else { + saturation = sv / svDivisor; + } + return new 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); - break; - case green: - hue = (blue - red) / delta / 6 + 1 / 3; - break; - case blue: - hue = (red - green) / delta / 6 + 2 / 3; - break; - } - } - return new color.HSV(hue, saturation, value, this._alpha); + fromRgb: function () { + // Becomes one.color.RGB.prototype.hsv + var red = this._red; + var green = this._green; + var blue = this._blue; + var max = Math.max(red, green, blue); + var min = Math.min(red, green, blue); + var delta = max - min; + var hue; + var saturation = max === 0 ? 0 : delta / max; + var 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 color.HSV(hue, saturation, value, this._alpha); + }, + }); }; diff --git a/lib/LAB.js b/lib/LAB.js index 1b91813..9400517 100644 --- a/lib/LAB.js +++ b/lib/LAB.js @@ -1,33 +1,31 @@ module.exports = function LAB(color) { - color.use(require('./XYZ.js')); + color.use(require('./XYZ.js')); - color.installColorSpace('LAB', ['l', 'a', 'b', 'alpha'], { - fromRgb: function () { - return this.xyz().lab(); - }, + color.installColorSpace('LAB', ['l', 'a', 'b', 'alpha'], { + fromRgb: function () { + return this.xyz().lab(); + }, - rgb: function () { - return this.xyz().rgb(); - }, + rgb: function () { + return this.xyz().rgb(); + }, - xyz: function () { - // http://www.easyrgb.com/index.php?X=MATH&H=08#text8 - var convert = function (channel) { - var pow = Math.pow(channel, 3); - return pow > 0.008856 ? - pow : - (channel - 16 / 116) / 7.87; - }, - y = (this._l + 16) / 116, - x = this._a / 500 + y, - z = y - this._b / 200; + xyz: function () { + // http://www.easyrgb.com/index.php?X=MATH&H=08#text8 + var convert = function (channel) { + var pow = Math.pow(channel, 3); + return pow > 0.008856 ? pow : (channel - 16 / 116) / 7.87; + }; + var y = (this._l + 16) / 116; + var x = this._a / 500 + y; + var z = y - this._b / 200; - return new color.XYZ( - convert(x) * 95.047, - convert(y) * 100.000, - convert(z) * 108.883, - this._alpha - ); - } - }); + return new color.XYZ( + convert(x) * 95.047, + convert(y) * 100.0, + convert(z) * 108.883, + this._alpha + ); + }, + }); }; diff --git a/lib/XYZ.js b/lib/XYZ.js index 504f0c8..aabc891 100644 --- a/lib/XYZ.js +++ b/lib/XYZ.js @@ -1,64 +1,64 @@ module.exports = function XYZ(color) { - color.installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], { - fromRgb: function () { - // http://www.easyrgb.com/index.php?X=MATH&H=02#text2 - var convert = function (channel) { - return channel > 0.04045 ? - Math.pow((channel + 0.055) / 1.055, 2.4) : - channel / 12.92; - }, - r = convert(this._red), - g = convert(this._green), - b = convert(this._blue); + color.installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], { + fromRgb: function () { + // http://www.easyrgb.com/index.php?X=MATH&H=02#text2 + var convert = function (channel) { + return channel > 0.04045 + ? Math.pow((channel + 0.055) / 1.055, 2.4) + : channel / 12.92; + }; + var r = convert(this._red); + var g = convert(this._green); + var b = convert(this._blue); - // Reference white point sRGB D65: - // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - return new color.XYZ( - r * 0.4124564 + g * 0.3575761 + b * 0.1804375, - r * 0.2126729 + g * 0.7151522 + b * 0.0721750, - r * 0.0193339 + g * 0.1191920 + b * 0.9503041, - this._alpha - ); - }, + // Reference white point sRGB D65: + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + return new color.XYZ( + r * 0.4124564 + g * 0.3575761 + b * 0.1804375, + r * 0.2126729 + g * 0.7151522 + b * 0.072175, + r * 0.0193339 + g * 0.119192 + b * 0.9503041, + this._alpha + ); + }, - rgb: function () { - // http://www.easyrgb.com/index.php?X=MATH&H=01#text1 - var x = this._x, - y = this._y, - z = this._z, - convert = function (channel) { - return channel > 0.0031308 ? - 1.055 * Math.pow(channel, 1 / 2.4) - 0.055 : - 12.92 * channel; - }; + rgb: function () { + // http://www.easyrgb.com/index.php?X=MATH&H=01#text1 + var x = this._x; + var y = this._y; + var z = this._z; + var convert = function (channel) { + return channel > 0.0031308 + ? 1.055 * Math.pow(channel, 1 / 2.4) - 0.055 + : 12.92 * channel; + }; - // Reference white point sRGB D65: - // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - return new color.RGB( - convert(x * 3.2404542 + y * -1.5371385 + z * -0.4985314), - convert(x * -0.9692660 + y * 1.8760108 + z * 0.0415560), - convert(x * 0.0556434 + y * -0.2040259 + z * 1.0572252), - this._alpha - ); - }, + // Reference white point sRGB D65: + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + return new color.RGB( + convert(x * 3.2404542 + y * -1.5371385 + z * -0.4985314), + convert(x * -0.969266 + y * 1.8760108 + z * 0.041556), + convert(x * 0.0556434 + y * -0.2040259 + z * 1.0572252), + this._alpha + ); + }, - lab: function () { - // http://www.easyrgb.com/index.php?X=MATH&H=07#text7 - var convert = function (channel) { - return channel > 0.008856 ? - Math.pow(channel, 1 / 3) : - 7.787037 * channel + 4 / 29; - }, - x = convert(this._x / 95.047), - y = convert(this._y / 100.000), - z = convert(this._z / 108.883); + lab: function () { + // http://www.easyrgb.com/index.php?X=MATH&H=07#text7 + var convert = function (channel) { + return channel > 0.008856 + ? Math.pow(channel, 1 / 3) + : 7.787037 * channel + 4 / 29; + }; + var x = convert(this._x / 95.047); + var y = convert(this._y / 100.0); + var z = convert(this._z / 108.883); - return new color.LAB( - (116 * y) - 16, - 500 * (x - y), - 200 * (y - z), - this._alpha - ); - } - }); + return new color.LAB( + 116 * y - 16, + 500 * (x - y), + 200 * (y - z), + this._alpha + ); + }, + }); }; diff --git a/lib/color.js b/lib/color.js index a8bfa55..0944b50 100644 --- a/lib/color.js +++ b/lib/color.js @@ -1,260 +1,364 @@ -var installedColorSpaces = [], - undef = function (obj) { - return typeof obj === 'undefined'; - }, - channelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)(%|deg)?\s*/, - percentageChannelRegExp = /\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/, - cssColorRegExp = new RegExp( - '^(rgb|hsl|hsv)a?' + - '\\(' + - channelRegExp.source + '[, ]' + - channelRegExp.source + '[, ]' + - channelRegExp.source + - '(?:[,/]' + channelRegExp.source + ')?' + - '\\)$', 'i'); +var installedColorSpaces = []; +var undef = function (obj) { + return typeof obj === 'undefined'; +}; +var channelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)(%|deg)?\s*/; +var percentageChannelRegExp = /\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/; +var cssColorRegExp = new RegExp( + '^(rgb|hsl|hsv)a?' + + '\\(' + + channelRegExp.source + + '[, ]' + + channelRegExp.source + + '[, ]' + + channelRegExp.source + + '(?:[,/]' + + channelRegExp.source + + ')?' + + '\\)$', + 'i' +); function divisor(unit, channelNumber, hasHue) { - if (unit === '%') { - return 100; - } else if (unit === 'deg' || (hasHue && channelNumber === 0)) { - return 360; - } else if (!unit) { - return 255; - } + if (unit === '%') { + return 100; + } else if (unit === 'deg' || (hasHue && channelNumber === 0)) { + return 360; + } else if (!unit) { + return 255; + } } function color(obj) { - if (Array.isArray(obj)) { - if (typeof obj[0] === 'string' && typeof color[obj[0]] === 'function') { - // Assumed array from .toJSON() - return new color[obj[0]](obj.slice(1, obj.length)); - } else if (obj.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); - } - } else if (typeof obj === 'string') { - var lowerCased = obj.toLowerCase(); - if (color.namedColors[lowerCased]) { - obj = '#' + color.namedColors[lowerCased]; - } - if (lowerCased === 'transparent') { - obj = 'rgba(0,0,0,0)'; - } - // Test for CSS rgb(....) string - var matchCssSyntax = obj.match(cssColorRegExp); - if (matchCssSyntax) { - var colorSpaceName = matchCssSyntax[1].toUpperCase(), - hasHue = colorSpaceName[0] === 'H'; - if (undef(color[colorSpaceName])) { - throw new Error('color.' + colorSpaceName + ' is not installed.'); - } - return new color[colorSpaceName]( - parseFloat(matchCssSyntax[2]) / divisor(matchCssSyntax[3], 0, hasHue), - parseFloat(matchCssSyntax[4]) / divisor(matchCssSyntax[5], 1, hasHue), - parseFloat(matchCssSyntax[6]) / divisor(matchCssSyntax[7], 2, hasHue), - undef(matchCssSyntax[8]) ? matchCssSyntax[8] : parseFloat(matchCssSyntax[8]) / (matchCssSyntax[9] ? 100 : 255) - ); - } - // Assume hex syntax - if (obj.length < 6) { - // Allow CSS shorthand - obj = obj.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i, '$1$1$2$2$3$3$4$4'); - } - // Split obj into red, green, and blue components - var hexMatch = obj.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])?$/i); - if (hexMatch) { - return new color.RGB( - parseInt(hexMatch[1], 16) / 255, - parseInt(hexMatch[2], 16) / 255, - parseInt(hexMatch[3], 16) / 255, - hexMatch[4] ? parseInt(hexMatch[4], 16) / 255 : 1 - ); - } + if (Array.isArray(obj)) { + if (typeof obj[0] === 'string' && typeof color[obj[0]] === 'function') { + // Assumed array from .toJSON() + return new color[obj[0]](obj.slice(1, obj.length)); + } else if (obj.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 + ); + } + } else if (typeof obj === 'string') { + var lowerCased = obj.toLowerCase(); + if (color.namedColors[lowerCased]) { + obj = '#' + color.namedColors[lowerCased]; + } + if (lowerCased === 'transparent') { + obj = 'rgba(0,0,0,0)'; + } + // Test for CSS rgb(....) string + var matchCssSyntax = obj.match(cssColorRegExp); + if (matchCssSyntax) { + var colorSpaceName = matchCssSyntax[1].toUpperCase(); + var hasHue = colorSpaceName[0] === 'H'; + if (undef(color[colorSpaceName])) { + throw new Error('color.' + colorSpaceName + ' is not installed.'); + } + return new color[colorSpaceName]( + parseFloat(matchCssSyntax[2]) / divisor(matchCssSyntax[3], 0, hasHue), + parseFloat(matchCssSyntax[4]) / divisor(matchCssSyntax[5], 1, hasHue), + parseFloat(matchCssSyntax[6]) / divisor(matchCssSyntax[7], 2, hasHue), + undef(matchCssSyntax[8]) + ? matchCssSyntax[8] + : parseFloat(matchCssSyntax[8]) / (matchCssSyntax[9] ? 100 : 255) + ); + } + // Assume hex syntax + if (obj.length < 6) { + // Allow CSS shorthand + obj = obj.replace( + /^#?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i, + '$1$1$2$2$3$3$4$4' + ); + } + // Split obj into the red, green, blue, and optionally alpha component + var hexMatch = obj.match( + /^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])?$/i + ); - // No match so far. Lets try the less likely ones - if (color.CMYK) { - var cmykMatch = obj.match(new RegExp( - '^cmyk' + - '\\(' + - percentageChannelRegExp.source + ',' + - percentageChannelRegExp.source + ',' + - percentageChannelRegExp.source + ',' + - percentageChannelRegExp.source + - '\\)$', 'i')); - if (cmykMatch) { - return new color.CMYK( - parseFloat(cmykMatch[1]) / 100, - parseFloat(cmykMatch[2]) / 100, - parseFloat(cmykMatch[3]) / 100, - parseFloat(cmykMatch[4]) / 100 - ); - } - } - } else if (typeof obj === 'object' && obj.isColor) { - return obj; + if (hexMatch) { + return new color.RGB( + parseInt(hexMatch[1], 16) / 255, + parseInt(hexMatch[2], 16) / 255, + parseInt(hexMatch[3], 16) / 255, + hexMatch[4] ? parseInt(hexMatch[4], 16) / 255 : 1 + ); } - return false; + + // No match so far. Lets try the less likely ones + if (color.CMYK) { + var cmykMatch = obj.match( + new RegExp( + '^cmyk' + + '\\(' + + percentageChannelRegExp.source + + ',' + + percentageChannelRegExp.source + + ',' + + percentageChannelRegExp.source + + ',' + + percentageChannelRegExp.source + + '\\)$', + 'i' + ) + ); + if (cmykMatch) { + return new color.CMYK( + parseFloat(cmykMatch[1]) / 100, + parseFloat(cmykMatch[2]) / 100, + parseFloat(cmykMatch[3]) / 100, + parseFloat(cmykMatch[4]) / 100 + ); + } + } + } else if (typeof obj === 'object' && obj.isColor) { + return obj; + } + return false; } color.namedColors = {}; color.installColorSpace = function (colorSpaceName, propertyNames, config) { - color[colorSpaceName] = function (a1) { // ... - var args = Array.isArray(a1) ? a1 : arguments; - propertyNames.forEach(function (propertyName, i) { - var propertyValue = args[i]; - if (propertyName === 'alpha') { - this._alpha = (isNaN(propertyValue) || propertyValue > 1) ? 1 : (propertyValue < 0 ? 0 : propertyValue); - } else { - if (isNaN(propertyValue)) { - throw new Error('[' + colorSpaceName + ']: Invalid color: (' + propertyNames.join(',') + ')'); - } - if (propertyName === 'hue') { - this._hue = propertyValue < 0 ? propertyValue - Math.floor(propertyValue) : propertyValue % 1; - } else { - this['_' + propertyName] = propertyValue < 0 ? 0 : (propertyValue > 1 ? 1 : propertyValue); - } - } - }, this); - }; - color[colorSpaceName].propertyNames = propertyNames; + color[colorSpaceName] = function (a1) { + // ... + var args = Array.isArray(a1) ? a1 : arguments; + propertyNames.forEach(function (propertyName, i) { + var propertyValue = args[i]; + if (propertyName === 'alpha') { + this._alpha = + isNaN(propertyValue) || propertyValue > 1 + ? 1 + : propertyValue < 0 + ? 0 + : propertyValue; + } else { + if (isNaN(propertyValue)) { + throw new Error( + '[' + + colorSpaceName + + ']: Invalid color: (' + + propertyNames.join(',') + + ')' + ); + } + if (propertyName === 'hue') { + this._hue = + propertyValue < 0 + ? propertyValue - Math.floor(propertyValue) + : propertyValue % 1; + } else { + this['_' + propertyName] = + propertyValue < 0 ? 0 : propertyValue > 1 ? 1 : propertyValue; + } + } + }, this); + }; + color[colorSpaceName].propertyNames = propertyNames; - var prototype = color[colorSpaceName].prototype; + var prototype = color[colorSpaceName].prototype; - ['valueOf', 'hex', 'hexa', 'css', 'cssa'].forEach(function (methodName) { - prototype[methodName] = prototype[methodName] || (colorSpaceName === 'RGB' ? prototype.hex : function () { + ['valueOf', 'hex', 'hexa', 'css', 'cssa'].forEach(function (methodName) { + prototype[methodName] = + prototype[methodName] || + (colorSpaceName === 'RGB' + ? prototype.hex + : function () { return this.rgb()[methodName](); - }); - }); + }); + }); - prototype.isColor = true; + prototype.isColor = true; - prototype.equals = function (otherColor, epsilon) { - if (undef(epsilon)) { - epsilon = 1e-10; - } + prototype.equals = function (otherColor, epsilon) { + if (undef(epsilon)) { + epsilon = 1e-10; + } - otherColor = otherColor[colorSpaceName.toLowerCase()](); + otherColor = otherColor[colorSpaceName.toLowerCase()](); - for (var i = 0; i < propertyNames.length; i = i + 1) { - if (Math.abs(this['_' + propertyNames[i]] - otherColor['_' + propertyNames[i]]) > epsilon) { - return false; - } - } + for (var i = 0; i < propertyNames.length; i = i + 1) { + if ( + Math.abs( + this['_' + propertyNames[i]] - otherColor['_' + propertyNames[i]] + ) > epsilon + ) { + return false; + } + } - return true; - }; + return true; + }; - prototype.toJSON = function () { - return [colorSpaceName].concat(propertyNames.map(function (propertyName) { - return this['_' + propertyName]; - }, this)); - }; + prototype.toJSON = function () { + return [colorSpaceName].concat( + propertyNames.map(function (propertyName) { + return this['_' + propertyName]; + }, this) + ); + }; - for (var propertyName in config) { - if (config.hasOwnProperty(propertyName)) { - var matchFromColorSpace = propertyName.match(/^from(.*)$/); - if (matchFromColorSpace) { - color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName]; - } else { - prototype[propertyName] = config[propertyName]; - } - } + for (var propertyName in config) { + if (Object.prototype.hasOwnProperty.call(config, propertyName)) { + var matchFromColorSpace = propertyName.match(/^from(.*)$/); + if (matchFromColorSpace) { + color[matchFromColorSpace[1].toUpperCase()].prototype[ + colorSpaceName.toLowerCase() + ] = config[propertyName]; + } else { + prototype[propertyName] = config[propertyName]; + } } + } - // It is pretty easy to implement the conversion to the same color space: - prototype[colorSpaceName.toLowerCase()] = function () { - return this; - }; - prototype.toString = function () { - return '[' + colorSpaceName + ' ' + propertyNames.map(function (propertyName) { - return this['_' + propertyName]; - }).join(', ') + ']'; + // It is pretty easy to implement the conversion to the same color space: + prototype[colorSpaceName.toLowerCase()] = function () { + return this; + }; + prototype.toString = function () { + return ( + '[' + + colorSpaceName + + ' ' + + propertyNames + .map(function (propertyName) { + return this['_' + propertyName]; + }, this) + .join(', ') + + ']' + ); + }; + + // Generate getters and setters + propertyNames.forEach(function (propertyName) { + var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0); + prototype[propertyName] = prototype[shortName] = function (value, isDelta) { + // Simple getter mode: color.red() + if (typeof value === 'undefined') { + return this['_' + propertyName]; + } else if (isDelta) { + // Adjuster: color.red(+.2, true) + return new this.constructor( + propertyNames.map(function (otherPropertyName) { + return ( + this['_' + otherPropertyName] + + (propertyName === otherPropertyName ? value : 0) + ); + }, this) + ); + } else { + // Setter: color.red(.2); + return new this.constructor( + propertyNames.map(function (otherPropertyName) { + return propertyName === otherPropertyName + ? value + : this['_' + otherPropertyName]; + }, this) + ); + } }; + }); - // Generate getters and setters - propertyNames.forEach(function (propertyName) { - var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0); - prototype[propertyName] = prototype[shortName] = function (value, isDelta) { - // Simple getter mode: color.red() - if (typeof value === 'undefined') { - return this['_' + propertyName]; - } else if (isDelta) { - // Adjuster: color.red(+.2, true) - return new this.constructor(propertyNames.map(function (otherPropertyName) { - return this['_' + otherPropertyName] + (propertyName === otherPropertyName ? value : 0); - }, this)); - } else { - // Setter: color.red(.2); - return new this.constructor(propertyNames.map(function (otherPropertyName) { - return (propertyName === otherPropertyName) ? value : this['_' + otherPropertyName]; - }, this)); - } - }; + function installForeignMethods(targetColorSpaceName, sourceColorSpaceName) { + var obj = {}; + obj[sourceColorSpaceName.toLowerCase()] = function () { + return this.rgb()[sourceColorSpaceName.toLowerCase()](); + }; + color[sourceColorSpaceName].propertyNames.forEach(function (propertyName) { + var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0); + obj[propertyName] = obj[shortName] = function (value, isDelta) { + return this[sourceColorSpaceName.toLowerCase()]()[propertyName]( + value, + isDelta + ); + }; }); - - function installForeignMethods(targetColorSpaceName, sourceColorSpaceName) { - var obj = {}; - obj[sourceColorSpaceName.toLowerCase()] = function () { - return this.rgb()[sourceColorSpaceName.toLowerCase()](); - }; - color[sourceColorSpaceName].propertyNames.forEach(function (propertyName) { - var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0); - obj[propertyName] = obj[shortName] = 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]; - } - } + for (var prop in obj) { + if ( + Object.prototype.hasOwnProperty.call(obj, prop) && + color[targetColorSpaceName].prototype[prop] === undefined + ) { + color[targetColorSpaceName].prototype[prop] = obj[prop]; + } } + } - installedColorSpaces.forEach(function (otherColorSpaceName) { - installForeignMethods(colorSpaceName, otherColorSpaceName); - installForeignMethods(otherColorSpaceName, colorSpaceName); - }); + installedColorSpaces.forEach(function (otherColorSpaceName) { + installForeignMethods(colorSpaceName, otherColorSpaceName); + installForeignMethods(otherColorSpaceName, colorSpaceName); + }); - installedColorSpaces.push(colorSpaceName); - return color; + installedColorSpaces.push(colorSpaceName); + return color; }; color.pluginList = []; color.use = function (plugin) { - if (color.pluginList.indexOf(plugin) === -1) { - this.pluginList.push(plugin); - plugin(color); - } - return color; + if (color.pluginList.indexOf(plugin) === -1) { + this.pluginList.push(plugin); + plugin(color); + } + return color; }; color.installMethod = function (name, fn) { - installedColorSpaces.forEach(function (colorSpace) { - color[colorSpace].prototype[name] = fn; - }); - return this; + installedColorSpaces.forEach(function (colorSpace) { + color[colorSpace].prototype[name] = fn; + }); + return this; }; color.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], { - hex: function () { - var hexString = (Math.round(255 * this._red) * 0x10000 + Math.round(255 * this._green) * 0x100 + Math.round(255 * this._blue)).toString(16); - return '#' + ('00000'.substr(0, 6 - hexString.length)) + hexString; - }, + hex: function () { + var hexString = ( + Math.round(255 * this._red) * 0x10000 + + Math.round(255 * this._green) * 0x100 + + Math.round(255 * this._blue) + ).toString(16); + return '#' + '00000'.substr(0, 6 - hexString.length) + hexString; + }, - hexa: function () { - var alphaString = Math.round(this._alpha * 255).toString(16); - return '#' + '00'.substr(0, 2 - alphaString.length) + alphaString + this.hex().substr(1, 6); - }, + hexa: function () { + var alphaString = Math.round(this._alpha * 255).toString(16); + return ( + '#' + + '00'.substr(0, 2 - alphaString.length) + + alphaString + + this.hex().substr(1, 6) + ); + }, - css: function () { - return 'rgb(' + Math.round(255 * this._red) + ',' + Math.round(255 * this._green) + ',' + Math.round(255 * this._blue) + ')'; - }, + css: function () { + return ( + 'rgb(' + + Math.round(255 * this._red) + + ',' + + Math.round(255 * this._green) + + ',' + + Math.round(255 * this._blue) + + ')' + ); + }, - cssa: function () { - return 'rgba(' + Math.round(255 * this._red) + ',' + Math.round(255 * this._green) + ',' + Math.round(255 * this._blue) + ',' + this._alpha + ')'; - } + cssa: function () { + return ( + 'rgba(' + + Math.round(255 * this._red) + + ',' + + Math.round(255 * this._green) + + ',' + + Math.round(255 * this._blue) + + ',' + + this._alpha + + ')' + ); + }, }); module.exports = color; diff --git a/lib/plugins/clearer.js b/lib/plugins/clearer.js index e2b571a..294a2cf 100644 --- a/lib/plugins/clearer.js +++ b/lib/plugins/clearer.js @@ -1,5 +1,5 @@ module.exports = function clearer(color) { - color.installMethod('clearer', function (amount) { - return this.alpha(isNaN(amount) ? -0.1 : -amount, true); - }); + color.installMethod('clearer', function (amount) { + return this.alpha(isNaN(amount) ? -0.1 : -amount, true); + }); }; diff --git a/lib/plugins/contrast.js b/lib/plugins/contrast.js new file mode 100644 index 0000000..e1e210d --- /dev/null +++ b/lib/plugins/contrast.js @@ -0,0 +1,15 @@ +module.exports = function contrast(color) { + // http://www.w3.org/TR/WCAG20/#contrast-ratiodef + + color.use(require('./luminance')); + + color.installMethod('contrast', function (color2) { + var lum1 = this.luminance(); + var lum2 = color2.luminance(); + if (lum1 > lum2) { + return (lum1 + 0.05) / (lum2 + 0.05); + } + + return (lum2 + 0.05) / (lum1 + 0.05); + }); +}; diff --git a/lib/plugins/darken.js b/lib/plugins/darken.js index f0acfd3..5cbc10d 100644 --- a/lib/plugins/darken.js +++ b/lib/plugins/darken.js @@ -1,7 +1,7 @@ module.exports = function darken(color) { - color.use(require('../HSL')); + color.use(require('../HSL')); - color.installMethod('darken', function (amount) { - return this.lightness(isNaN(amount) ? -0.1 : -amount, true); - }); + color.installMethod('darken', function (amount) { + return this.lightness(isNaN(amount) ? -0.1 : -amount, true); + }); }; diff --git a/lib/plugins/desaturate.js b/lib/plugins/desaturate.js index 80ac649..79bb2bb 100644 --- a/lib/plugins/desaturate.js +++ b/lib/plugins/desaturate.js @@ -1,7 +1,7 @@ module.exports = function desaturate(color) { - color.use(require('../HSL')); + color.use(require('../HSL')); - color.installMethod('desaturate', function (amount) { - return this.saturation(isNaN(amount) ? -0.1 : -amount, true); - }); + color.installMethod('desaturate', function (amount) { + return this.saturation(isNaN(amount) ? -0.1 : -amount, true); + }); }; diff --git a/lib/plugins/grayscale.js b/lib/plugins/grayscale.js index 4df44bd..5ac31ee 100644 --- a/lib/plugins/grayscale.js +++ b/lib/plugins/grayscale.js @@ -1,11 +1,11 @@ module.exports = function grayscale(color) { - function gs () { - /*jslint strict:false*/ - var rgb = this.rgb(), - val = rgb._red * 0.3 + rgb._green * 0.59 + rgb._blue * 0.11; + function gs() { + /* jslint strict:false */ + var rgb = this.rgb(); + var val = rgb._red * 0.3 + rgb._green * 0.59 + rgb._blue * 0.11; - return new color.RGB(val, val, val, rgb._alpha); - } + return new color.RGB(val, val, val, rgb._alpha); + } - color.installMethod('greyscale', gs).installMethod('grayscale', gs); + color.installMethod('greyscale', gs).installMethod('grayscale', gs); }; diff --git a/lib/plugins/isDark.js b/lib/plugins/isDark.js new file mode 100644 index 0000000..ed679c5 --- /dev/null +++ b/lib/plugins/isDark.js @@ -0,0 +1,11 @@ +module.exports = function isDark(color) { + color.installMethod('isDark', function () { + var rgb = this.rgb(); + + // YIQ equation from http://24ways.org/2010/calculating-color-contrast + var yiq = + (rgb._red * 255 * 299 + rgb._green * 255 * 587 + rgb._blue * 255 * 114) / + 1000; + return yiq < 128; + }); +}; diff --git a/lib/plugins/isLight.js b/lib/plugins/isLight.js new file mode 100644 index 0000000..3da1c32 --- /dev/null +++ b/lib/plugins/isLight.js @@ -0,0 +1,7 @@ +module.exports = function isLight(color) { + color.use(require('./isDark')); + + color.installMethod('isLight', function () { + return !this.isDark(); + }); +}; diff --git a/lib/plugins/lighten.js b/lib/plugins/lighten.js index cddcab4..3ccc80d 100644 --- a/lib/plugins/lighten.js +++ b/lib/plugins/lighten.js @@ -1,7 +1,7 @@ module.exports = function lighten(color) { - color.use(require('../HSL')); + color.use(require('../HSL')); - color.installMethod('lighten', function (amount) { - return this.lightness(isNaN(amount) ? 0.1 : amount, true); - }); + color.installMethod('lighten', function (amount) { + return this.lightness(isNaN(amount) ? 0.1 : amount, true); + }); }; diff --git a/lib/plugins/luminance.js b/lib/plugins/luminance.js new file mode 100644 index 0000000..4890f7c --- /dev/null +++ b/lib/plugins/luminance.js @@ -0,0 +1,18 @@ +module.exports = function luminance(color) { + // http://www.w3.org/TR/WCAG20/#relativeluminancedef + + function channelLuminance(value) { + return value <= 0.03928 + ? value / 12.92 + : Math.pow((value + 0.055) / 1.055, 2.4); + } + + color.installMethod('luminance', function () { + var rgb = this.rgb(); + return ( + 0.2126 * channelLuminance(rgb._red) + + 0.7152 * channelLuminance(rgb._green) + + 0.0722 * channelLuminance(rgb._blue) + ); + }); +}; diff --git a/lib/plugins/mix.js b/lib/plugins/mix.js index 7011658..0caaad3 100644 --- a/lib/plugins/mix.js +++ b/lib/plugins/mix.js @@ -1,19 +1,19 @@ module.exports = function mix(color) { - color.installMethod('mix', function (otherColor, weight) { - otherColor = color(otherColor).rgb(); - weight = 1 - (isNaN(weight) ? 0.5 : weight); + color.installMethod('mix', function (otherColor, weight) { + otherColor = color(otherColor).rgb(); + weight = 1 - (isNaN(weight) ? 0.5 : weight); - var w = weight * 2 - 1, - a = this._alpha - otherColor._alpha, - weight1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2, - weight2 = 1 - weight1, - rgb = this.rgb(); + var w = weight * 2 - 1; + var a = this._alpha - otherColor._alpha; + var weight1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2; + var weight2 = 1 - weight1; + var rgb = this.rgb(); - return new color.RGB( - rgb._red * weight1 + otherColor._red * weight2, - rgb._green * weight1 + otherColor._green * weight2, - rgb._blue * weight1 + otherColor._blue * weight2, - rgb._alpha * weight + otherColor._alpha * (1 - weight) - ); - }); + return new color.RGB( + rgb._red * weight1 + otherColor._red * weight2, + rgb._green * weight1 + otherColor._green * weight2, + rgb._blue * weight1 + otherColor._blue * weight2, + rgb._alpha * weight + otherColor._alpha * (1 - weight) + ); + }); }; diff --git a/lib/plugins/namedColors.js b/lib/plugins/namedColors.js index 95e1734..88b69bf 100644 --- a/lib/plugins/namedColors.js +++ b/lib/plugins/namedColors.js @@ -1,152 +1,152 @@ module.exports = function namedColors(color) { - color.namedColors = { - aliceblue: 'f0f8ff', - antiquewhite: 'faebd7', - aqua: '0ff', - aquamarine: '7fffd4', - azure: 'f0ffff', - beige: 'f5f5dc', - bisque: 'ffe4c4', - black: '000', - blanchedalmond: 'ffebcd', - blue: '00f', - blueviolet: '8a2be2', - brown: 'a52a2a', - burlywood: 'deb887', - cadetblue: '5f9ea0', - chartreuse: '7fff00', - chocolate: 'd2691e', - coral: 'ff7f50', - cornflowerblue: '6495ed', - cornsilk: 'fff8dc', - crimson: 'dc143c', - cyan: '0ff', - 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: 'f0f', - 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: '789', - lightslategrey: '789', - lightsteelblue: 'b0c4de', - lightyellow: 'ffffe0', - lime: '0f0', - limegreen: '32cd32', - linen: 'faf0e6', - magenta: 'f0f', - 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', - rebeccapurple: '639', - red: 'f00', - 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: 'fff', - whitesmoke: 'f5f5f5', - yellow: 'ff0', - yellowgreen: '9acd32' - }; + color.namedColors = { + aliceblue: 'f0f8ff', + antiquewhite: 'faebd7', + aqua: '0ff', + aquamarine: '7fffd4', + azure: 'f0ffff', + beige: 'f5f5dc', + bisque: 'ffe4c4', + black: '000', + blanchedalmond: 'ffebcd', + blue: '00f', + blueviolet: '8a2be2', + brown: 'a52a2a', + burlywood: 'deb887', + cadetblue: '5f9ea0', + chartreuse: '7fff00', + chocolate: 'd2691e', + coral: 'ff7f50', + cornflowerblue: '6495ed', + cornsilk: 'fff8dc', + crimson: 'dc143c', + cyan: '0ff', + 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: 'f0f', + 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: '789', + lightslategrey: '789', + lightsteelblue: 'b0c4de', + lightyellow: 'ffffe0', + lime: '0f0', + limegreen: '32cd32', + linen: 'faf0e6', + magenta: 'f0f', + 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', + rebeccapurple: '639', + red: 'f00', + 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: 'fff', + whitesmoke: 'f5f5f5', + yellow: 'ff0', + yellowgreen: '9acd32', + }; }; diff --git a/lib/plugins/negate.js b/lib/plugins/negate.js index 8c3eef4..1bdf658 100644 --- a/lib/plugins/negate.js +++ b/lib/plugins/negate.js @@ -1,6 +1,11 @@ module.exports = function negate(color) { - color.installMethod('negate', function () { - var rgb = this.rgb(); - return new color.RGB(1 - rgb._red, 1 - rgb._green, 1 - rgb._blue, this._alpha); - }); + color.installMethod('negate', function () { + var rgb = this.rgb(); + return new color.RGB( + 1 - rgb._red, + 1 - rgb._green, + 1 - rgb._blue, + this._alpha + ); + }); }; diff --git a/lib/plugins/opaquer.js b/lib/plugins/opaquer.js index 1caa8db..d2d4e37 100644 --- a/lib/plugins/opaquer.js +++ b/lib/plugins/opaquer.js @@ -1,5 +1,5 @@ module.exports = function opaquer(color) { - color.installMethod('opaquer', function (amount) { - return this.alpha(isNaN(amount) ? 0.1 : amount, true); - }); + color.installMethod('opaquer', function (amount) { + return this.alpha(isNaN(amount) ? 0.1 : amount, true); + }); }; diff --git a/lib/plugins/rotate.js b/lib/plugins/rotate.js index 2c74a99..543b38c 100644 --- a/lib/plugins/rotate.js +++ b/lib/plugins/rotate.js @@ -1,7 +1,7 @@ module.exports = function rotate(color) { - color.use(require('../HSL')); + color.use(require('../HSL')); - color.installMethod('rotate', function (degrees) { - return this.hue((degrees || 0) / 360, true); - }); + color.installMethod('rotate', function (degrees) { + return this.hue((degrees || 0) / 360, true); + }); }; diff --git a/lib/plugins/saturate.js b/lib/plugins/saturate.js index a9ad5c6..0d2d99f 100644 --- a/lib/plugins/saturate.js +++ b/lib/plugins/saturate.js @@ -1,7 +1,7 @@ module.exports = function saturate(color) { - color.use(require('../HSL')); + color.use(require('../HSL')); - color.installMethod('saturate', function (amount) { - return this.saturation(isNaN(amount) ? 0.1 : amount, true); - }); + color.installMethod('saturate', function (amount) { + return this.saturation(isNaN(amount) ? 0.1 : amount, true); + }); }; diff --git a/lib/plugins/toAlpha.js b/lib/plugins/toAlpha.js index e52047c..f370d1b 100644 --- a/lib/plugins/toAlpha.js +++ b/lib/plugins/toAlpha.js @@ -1,46 +1,46 @@ // Adapted from http://gimp.sourcearchive.com/documentation/2.6.6-1ubuntu1/color-to-alpha_8c-source.html // toAlpha returns a color where the values of the argument have been converted to alpha module.exports = function toAlpha(color) { - color.installMethod('toAlpha', function (color) { - var me = this.rgb(), - other = color(color).rgb(), - epsilon = 1e-10, - a = new color.RGB(0, 0, 0, me._alpha), - channels = ['_red', '_green', '_blue']; + color.installMethod('toAlpha', function (color) { + var me = this.rgb(); + var other = color(color).rgb(); + var epsilon = 1e-10; + var a = new color.RGB(0, 0, 0, me._alpha); + var channels = ['_red', '_green', '_blue']; - channels.forEach(function (channel) { - if (me[channel] < epsilon) { - a[channel] = me[channel]; - } else if (me[channel] > other[channel]) { - a[channel] = (me[channel] - other[channel]) / (1 - other[channel]); - } else if (me[channel] > other[channel]) { - a[channel] = (other[channel] - me[channel]) / other[channel]; - } else { - a[channel] = 0; - } - }); - - if (a._red > a._green) { - if (a._red > a._blue) { - me._alpha = a._red; - } else { - me._alpha = a._blue; - } - } else if (a._green > a._blue) { - me._alpha = a._green; - } else { - me._alpha = a._blue; - } + channels.forEach(function (channel) { + if (me[channel] < epsilon) { + a[channel] = me[channel]; + } else if (me[channel] > other[channel]) { + a[channel] = (me[channel] - other[channel]) / (1 - other[channel]); + } else if (me[channel] > other[channel]) { + a[channel] = (other[channel] - me[channel]) / other[channel]; + } else { + a[channel] = 0; + } + }); - if (me._alpha < epsilon) { - return me; - } + if (a._red > a._green) { + if (a._red > a._blue) { + me._alpha = a._red; + } else { + me._alpha = a._blue; + } + } else if (a._green > a._blue) { + me._alpha = a._green; + } else { + me._alpha = a._blue; + } - channels.forEach(function (channel) { - me[channel] = (me[channel] - other[channel]) / me._alpha + other[channel]; - }); - me._alpha *= a._alpha; + if (me._alpha < epsilon) { + return me; + } - return me; + channels.forEach(function (channel) { + me[channel] = (me[channel] - other[channel]) / me._alpha + other[channel]; }); + me._alpha *= a._alpha; + + return me; + }); }; diff --git a/minimal.js b/minimal.js index dfd8b7a..f3b0226 100644 --- a/minimal.js +++ b/minimal.js @@ -1,3 +1,3 @@ module.exports = require('./lib/color') - .use(require('./lib/HSV')) - .use(require('./lib/HSL')); + .use(require('./lib/HSV')) + .use(require('./lib/HSL')); diff --git a/one-color-all.js b/one-color-all.js index 14fb10f..57d8c27 100644 --- a/one-color-all.js +++ b/one-color-all.js @@ -1,43 +1,2 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.one || (g.one = {})).color = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=n?n:2-n);return s=1e-9>n+h?0:2*h/(n+h),new t.HSV(this._hue,s,(n+h)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}})}; -},{"4":4}],4:[function(require,module,exports){ -module.exports=function(a){a.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var e,t,s,h=this._hue,i=this._saturation,r=this._value,n=Math.min(5,Math.floor(6*h)),u=6*h-n,c=r*(1-i),l=r*(1-u*i),o=r*(1-(1-u)*i);switch(n){case 0:e=r,t=o,s=c;break;case 1:e=l,t=r,s=c;break;case 2:e=c,t=r,s=o;break;case 3:e=c,t=l,s=r;break;case 4:e=o,t=c,s=r;break;case 5:e=r,t=c,s=l}return new a.RGB(e,t,s,this._alpha)},hsl:function(){var e,t=(2-this._saturation)*this._value,s=this._saturation*this._value,h=1>=t?t:2-t;return e=1e-9>h?0:s/h,new a.HSL(this._hue,e,t/2,this._alpha)},fromRgb:function(){var e,t=this._red,s=this._green,h=this._blue,i=Math.max(t,s,h),r=Math.min(t,s,h),n=i-r,u=0===i?0:n/i,c=i;if(0===n)e=0;else switch(i){case t:e=(s-h)/n/6+(h>s?1:0);break;case s:e=(h-t)/n/6+1/3;break;case h:e=(t-s)/n/6+2/3}return new a.HSV(e,u,c,this._alpha)}})}; -},{}],5:[function(require,module,exports){ -module.exports=function(t){t.use(require(6)),t.installColorSpace("LAB",["l","a","b","alpha"],{fromRgb:function(){return this.xyz().lab()},rgb:function(){return this.xyz().rgb()},xyz:function(){var r=function(t){var r=Math.pow(t,3);return r>.008856?r:(t-16/116)/7.87},n=(this._l+16)/116,i=this._a/500+n,a=n-this._b/200;return new t.XYZ(95.047*r(i),100*r(n),108.883*r(a),this._alpha)}})}; -},{"6":6}],6:[function(require,module,exports){ -module.exports=function(t){t.installColorSpace("XYZ",["x","y","z","alpha"],{fromRgb:function(){var n=function(t){return t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92},r=n(this._red),i=n(this._green),h=n(this._blue);return new t.XYZ(.4124564*r+.3575761*i+.1804375*h,.2126729*r+.7151522*i+.072175*h,.0193339*r+.119192*i+.9503041*h,this._alpha)},rgb:function(){var n=this._x,r=this._y,i=this._z,h=function(t){return t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t};return new t.RGB(h(3.2404542*n+-1.5371385*r+i*-.4985314),h(n*-.969266+1.8760108*r+.041556*i),h(.0556434*n+r*-.2040259+1.0572252*i),this._alpha)},lab:function(){var n=function(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29},r=n(this._x/95.047),i=n(this._y/100),h=n(this._z/108.883);return new t.LAB(116*i-16,500*(r-i),200*(i-h),this._alpha)}})}; -},{}],7:[function(require,module,exports){ -function color(r){if(Array.isArray(r)){if("string"==typeof r[0]&&"function"==typeof color[r[0]])return new color[r[0]](r.slice(1,r.length));if(4===r.length)return new color.RGB(r[0]/255,r[1]/255,r[2]/255,r[3]/255)}else if("string"==typeof r){var o=r.toLowerCase();color.namedColors[o]&&(r="#"+color.namedColors[o]),"transparent"===o&&(r="rgba(0,0,0,0)");var e=r.match(cssColorRegExp);if(e){var t=e[1].toUpperCase(),n=undef(e[8])?e[8]:parseFloat(e[8]),a="H"===t[0],s=e[3]?100:a?360:255,i=e[5]||a?100:255,c=e[7]||a?100:255;if(undef(color[t]))throw new Error("color."+t+" is not installed.");return new color[t](parseFloat(e[2])/s,parseFloat(e[4])/i,parseFloat(e[6])/c,n)}r.length<6&&(r=r.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var l=r.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(l)return new color.RGB(parseInt(l[1],16)/255,parseInt(l[2],16)/255,parseInt(l[3],16)/255);if(color.CMYK){var u=r.match(new RegExp("^cmyk\\("+percentageChannelRegExp.source+","+percentageChannelRegExp.source+","+percentageChannelRegExp.source+","+percentageChannelRegExp.source+"\\)$","i"));if(u)return new color.CMYK(parseFloat(u[1])/100,parseFloat(u[2])/100,parseFloat(u[3])/100,parseFloat(u[4])/100)}}else if("object"==typeof r&&r.isColor)return r;return!1}var installedColorSpaces=[],undef=function(r){return"undefined"==typeof r},channelRegExp=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,percentageChannelRegExp=/\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/,alphaChannelRegExp=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,cssColorRegExp=new RegExp("^(rgb|hsl|hsv)a?\\("+channelRegExp.source+","+channelRegExp.source+","+channelRegExp.source+"(?:,"+alphaChannelRegExp.source+")?\\)$","i");color.namedColors={},color.installColorSpace=function(r,o,e){function t(r,o){var e={};e[o.toLowerCase()]=function(){return this.rgb()[o.toLowerCase()]()},color[o].propertyNames.forEach(function(r){var t="black"===r?"k":r.charAt(0);e[r]=e[t]=function(e,t){return this[o.toLowerCase()]()[r](e,t)}});for(var t in e)e.hasOwnProperty(t)&&void 0===color[r].prototype[t]&&(color[r].prototype[t]=e[t])}color[r]=function(e){var t=Array.isArray(e)?e:arguments;o.forEach(function(e,n){var a=t[n];if("alpha"===e)this._alpha=isNaN(a)||a>1?1:0>a?0:a;else{if(isNaN(a))throw new Error("["+r+"]: Invalid color: ("+o.join(",")+")");"hue"===e?this._hue=0>a?a-Math.floor(a):a%1:this["_"+e]=0>a?0:a>1?1:a}},this)},color[r].propertyNames=o;var n=color[r].prototype;["valueOf","hex","hexa","css","cssa"].forEach(function(o){n[o]=n[o]||("RGB"===r?n.hex:function(){return this.rgb()[o]()})}),n.isColor=!0,n.equals=function(e,t){undef(t)&&(t=1e-10),e=e[r.toLowerCase()]();for(var n=0;nt)return!1;return!0},n.toJSON=function(){return[r].concat(o.map(function(r){return this["_"+r]},this))};for(var a in e)if(e.hasOwnProperty(a)){var s=a.match(/^from(.*)$/);s?color[s[1].toUpperCase()].prototype[r.toLowerCase()]=e[a]:n[a]=e[a]}return n[r.toLowerCase()]=function(){return this},n.toString=function(){return"["+r+" "+o.map(function(r){return this["_"+r]}).join(", ")+"]"},o.forEach(function(r){var e="black"===r?"k":r.charAt(0);n[r]=n[e]=function(e,t){return"undefined"==typeof e?this["_"+r]:t?new this.constructor(o.map(function(o){return this["_"+o]+(r===o?e:0)},this)):new this.constructor(o.map(function(o){return r===o?e:this["_"+o]},this))}}),installedColorSpaces.forEach(function(o){t(r,o),t(o,r)}),installedColorSpaces.push(r),color},color.pluginList=[],color.use=function(r){return-1===color.pluginList.indexOf(r)&&(this.pluginList.push(r),r(color)),color},color.installMethod=function(r,o){return installedColorSpaces.forEach(function(e){color[e].prototype[r]=o}),this},color.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var r=(65536*Math.round(255*this._red)+256*Math.round(255*this._green)+Math.round(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-r.length)+r},hexa:function(){var r=Math.round(255*this._alpha).toString(16);return"#"+"00".substr(0,2-r.length)+r+this.hex().substr(1,6)},css:function(){return"rgb("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+")"},cssa:function(){return"rgba("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+","+this._alpha+")"}}),module.exports=color; -},{}],8:[function(require,module,exports){ -module.exports=function(t){t.installMethod("clearer",function(t){return this.alpha(isNaN(t)?-.1:-t,!0)})}; -},{}],9:[function(require,module,exports){ -module.exports=function(e){e.use(require(3)),e.installMethod("darken",function(e){return this.lightness(isNaN(e)?-.1:-e,!0)})}; -},{"3":3}],10:[function(require,module,exports){ -module.exports=function(t){t.use(require(3)),t.installMethod("desaturate",function(t){return this.saturation(isNaN(t)?-.1:-t,!0)})}; -},{"3":3}],11:[function(require,module,exports){ -module.exports=function(e){function l(){var l=this.rgb(),n=.3*l._red+.59*l._green+.11*l._blue;return new e.RGB(n,n,n,l._alpha)}e.installMethod("greyscale",l).installMethod("grayscale",l)}; -},{}],12:[function(require,module,exports){ -module.exports=function(e){e.use(require(3)),e.installMethod("lighten",function(e){return this.lightness(isNaN(e)?.1:e,!0)})}; -},{"3":3}],13:[function(require,module,exports){ -module.exports=function(e){e.installMethod("mix",function(a,r){a=e(a).rgb(),r=1-(isNaN(r)?.5:r);var _=2*r-1,l=this._alpha-a._alpha,n=((_*l===-1?_:(_+l)/(1+_*l))+1)/2,t=1-n,h=this.rgb();return new e.RGB(h._red*n+a._red*t,h._green*n+a._green*t,h._blue*n+a._blue*t,h._alpha*r+a._alpha*(1-r))})}; -},{}],14:[function(require,module,exports){ -module.exports=function(e){e.namedColors={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",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:"f0f",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:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",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",rebeccapurple:"639",red:"f00",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:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"}}; -},{}],15:[function(require,module,exports){ -module.exports=function(e){e.installMethod("negate",function(){var n=this.rgb();return new e.RGB(1-n._red,1-n._green,1-n._blue,this._alpha)})}; -},{}],16:[function(require,module,exports){ -module.exports=function(t){t.installMethod("opaquer",function(t){return this.alpha(isNaN(t)?.1:t,!0)})}; -},{}],17:[function(require,module,exports){ -module.exports=function(e){e.use(require(3)),e.installMethod("rotate",function(e){return this.hue((e||0)/360,!0)})}; -},{"3":3}],18:[function(require,module,exports){ -module.exports=function(t){t.use(require(3)),t.installMethod("saturate",function(t){return this.saturation(isNaN(t)?.1:t,!0)})}; -},{"3":3}],19:[function(require,module,exports){ -module.exports=function(a){a.installMethod("toAlpha",function(a){var e=this.rgb(),_=a(a).rgb(),l=1e-10,r=new a.RGB(0,0,0,e._alpha),n=["_red","_green","_blue"];return n.forEach(function(a){e[a]_[a]?r[a]=(e[a]-_[a])/(1-_[a]):e[a]>_[a]?r[a]=(_[a]-e[a])/_[a]:r[a]=0}),r._red>r._green?r._red>r._blue?e._alpha=r._red:e._alpha=r._blue:r._green>r._blue?e._alpha=r._green:e._alpha=r._blue,e._alpha1?1:i<0?0:i;else{if(isNaN(i))throw new Error("["+a+"]: Invalid color: ("+r.join(",")+")");"hue"===e?this._hue=i<0?i-Math.floor(i):i%1:this["_"+e]=i<0?0:i>1?1:i}}),this)},i[a].propertyNames=r;var o=i[a].prototype;for(var s in["valueOf","hex","hexa","css","cssa"].forEach((function(e){o[e]=o[e]||("RGB"===a?o.hex:function(){return this.rgb()[e]()})})),o.isColor=!0,o.equals=function(e,n){t(n)&&(n=1e-10),e=e[a.toLowerCase()]();for(var i=0;in)return!1;return!0},o.toJSON=function(){return[a].concat(r.map((function(e){return this["_"+e]}),this))},n)if(Object.prototype.hasOwnProperty.call(n,s)){var f=s.match(/^from(.*)$/);f?i[f[1].toUpperCase()].prototype[a.toLowerCase()]=n[s]:o[s]=n[s]}function u(e,t){var a={};for(var r in a[t.toLowerCase()]=function(){return this.rgb()[t.toLowerCase()]()},i[t].propertyNames.forEach((function(e){var r="black"===e?"k":e.charAt(0);a[e]=a[r]=function(a,r){return this[t.toLowerCase()]()[e](a,r)}})),a)Object.prototype.hasOwnProperty.call(a,r)&&void 0===i[e].prototype[r]&&(i[e].prototype[r]=a[r])}return o[a.toLowerCase()]=function(){return this},o.toString=function(){return"["+a+" "+r.map((function(e){return this["_"+e]}),this).join(", ")+"]"},r.forEach((function(e){var t="black"===e?"k":e.charAt(0);o[e]=o[t]=function(t,a){return void 0===t?this["_"+e]:a?new this.constructor(r.map((function(a){return this["_"+a]+(e===a?t:0)}),this)):new this.constructor(r.map((function(a){return e===a?t:this["_"+a]}),this))}})),e.forEach((function(e){u(a,e),u(e,a)})),e.push(a),i},i.pluginList=[],i.use=function(e){return-1===i.pluginList.indexOf(e)&&(this.pluginList.push(e),e(i)),i},i.installMethod=function(t,a){return e.forEach((function(e){i[e].prototype[t]=a})),this},i.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var e=(65536*Math.round(255*this._red)+256*Math.round(255*this._green)+Math.round(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-e.length)+e},hexa:function(){var e=Math.round(255*this._alpha).toString(16);return"#"+"00".substr(0,2-e.length)+e+this.hex().substr(1,6)},css:function(){return"rgb("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+")"},cssa:function(){return"rgba("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+","+this._alpha+")"}});var o=function(e){e.installColorSpace("XYZ",["x","y","z","alpha"],{fromRgb:function(){var t=function(e){return e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92},a=t(this._red),r=t(this._green),n=t(this._blue);return new e.XYZ(.4124564*a+.3575761*r+.1804375*n,.2126729*a+.7151522*r+.072175*n,.0193339*a+.119192*r+.9503041*n,this._alpha)},rgb:function(){var t=this._x,a=this._y,r=this._z,n=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e};return new e.RGB(n(3.2404542*t+-1.5371385*a+-.4985314*r),n(-.969266*t+1.8760108*a+.041556*r),n(.0556434*t+-.2040259*a+1.0572252*r),this._alpha)},lab:function(){var t=function(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29},a=t(this._x/95.047),r=t(this._y/100),n=t(this._z/108.883);return new e.LAB(116*r-16,500*(a-r),200*(r-n),this._alpha)}})},s=function(e){e.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var t,a,r,n=this._hue,i=this._saturation,o=this._value,s=Math.min(5,Math.floor(6*n)),f=6*n-s,u=o*(1-i),l=o*(1-f*i),h=o*(1-(1-f)*i);switch(s){case 0:t=o,a=h,r=u;break;case 1:t=l,a=o,r=u;break;case 2:t=u,a=o,r=h;break;case 3:t=u,a=l,r=o;break;case 4:t=h,a=u,r=o;break;case 5:t=o,a=u,r=l}return new e.RGB(t,a,r,this._alpha)},hsl:function(){var t,a=(2-this._saturation)*this._value,r=this._saturation*this._value,n=a<=1?a:2-a;return t=n<1e-9?0:r/n,new e.HSL(this._hue,t,a/2,this._alpha)},fromRgb:function(){var t,a=this._red,r=this._green,n=this._blue,i=Math.max(a,r,n),o=i-Math.min(a,r,n),s=0===i?0:o/i,f=i;if(0===o)t=0;else switch(i){case a:t=(r-n)/o/6+(r.008856?t:(e-16/116)/7.87},a=(this._l+16)/116,r=this._a/500+a,n=a-this._b/200;return new e.XYZ(95.047*t(r),100*t(a),108.883*t(n),this._alpha)}})})).use(s).use(f).use((function(e){e.installColorSpace("CMYK",["cyan","magenta","yellow","black","alpha"],{rgb:function(){return new e.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 t=this._red,a=this._green,r=this._blue,n=1-t,i=1-a,o=1-r,s=1;return t||a||r?(n=(n-(s=Math.min(n,Math.min(i,o))))/(1-s),i=(i-s)/(1-s),o=(o-s)/(1-s)):s=1,new e.CMYK(n,i,o,s,this._alpha)}})})).use((function(e){e.namedColors={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",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:"f0f",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:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",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",rebeccapurple:"639",red:"f00",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:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"}})).use((function(e){e.installMethod("clearer",(function(e){return this.alpha(isNaN(e)?-.1:-e,!0)}))})).use((function(e){e.use(u),e.installMethod("contrast",(function(e){var t=this.luminance(),a=e.luminance();return t>a?(t+.05)/(a+.05):(a+.05)/(t+.05)}))})).use((function(e){e.use(f),e.installMethod("darken",(function(e){return this.lightness(isNaN(e)?-.1:-e,!0)}))})).use((function(e){e.use(f),e.installMethod("desaturate",(function(e){return this.saturation(isNaN(e)?-.1:-e,!0)}))})).use((function(e){function t(){var t=this.rgb(),a=.3*t._red+.59*t._green+.11*t._blue;return new e.RGB(a,a,a,t._alpha)}e.installMethod("greyscale",t).installMethod("grayscale",t)})).use(l).use((function(e){e.use(l),e.installMethod("isLight",(function(){return!this.isDark()}))})).use((function(e){e.use(f),e.installMethod("lighten",(function(e){return this.lightness(isNaN(e)?.1:e,!0)}))})).use(u).use((function(e){e.installMethod("mix",(function(t,a){t=e(t).rgb();var r=2*(a=1-(isNaN(a)?.5:a))-1,n=this._alpha-t._alpha,i=((r*n==-1?r:(r+n)/(1+r*n))+1)/2,o=1-i,s=this.rgb();return new e.RGB(s._red*i+t._red*o,s._green*i+t._green*o,s._blue*i+t._blue*o,s._alpha*a+t._alpha*(1-a))}))})).use((function(e){e.installMethod("negate",(function(){var t=this.rgb();return new e.RGB(1-t._red,1-t._green,1-t._blue,this._alpha)}))})).use((function(e){e.installMethod("opaquer",(function(e){return this.alpha(isNaN(e)?.1:e,!0)}))})).use((function(e){e.use(f),e.installMethod("rotate",(function(e){return this.hue((e||0)/360,!0)}))})).use((function(e){e.use(f),e.installMethod("saturate",(function(e){return this.saturation(isNaN(e)?.1:e,!0)}))})).use((function(e){e.installMethod("toAlpha",(function(e){var t=this.rgb(),a=e(e).rgb(),r=new e.RGB(0,0,0,t._alpha),n=["_red","_green","_blue"];return n.forEach((function(e){t[e]<1e-10?r[e]=t[e]:t[e]>a[e]?r[e]=(t[e]-a[e])/(1-a[e]):t[e]>a[e]?r[e]=(a[e]-t[e])/a[e]:r[e]=0})),r._red>r._green?r._red>r._blue?t._alpha=r._red:t._alpha=r._blue:r._green>r._blue?t._alpha=r._green:t._alpha=r._blue,t._alpha<1e-10||(n.forEach((function(e){t[e]=(t[e]-a[e])/t._alpha+a[e]})),t._alpha*=r._alpha),t}))}))})); +//# sourceMappingURL=one-color-all.js.map diff --git a/one-color-all.js.map b/one-color-all.js.map new file mode 100644 index 0000000..40e0cb9 --- /dev/null +++ b/one-color-all.js.map @@ -0,0 +1 @@ +{"version":3,"file":"one-color-all.js","sources":["lib/color.js","lib/XYZ.js","lib/HSV.js","lib/HSL.js","lib/plugins/luminance.js","lib/plugins/isDark.js","index.js","lib/LAB.js","lib/CMYK.js","lib/plugins/namedColors.js","lib/plugins/clearer.js","lib/plugins/contrast.js","lib/plugins/darken.js","lib/plugins/desaturate.js","lib/plugins/grayscale.js","lib/plugins/isLight.js","lib/plugins/lighten.js","lib/plugins/mix.js","lib/plugins/negate.js","lib/plugins/opaquer.js","lib/plugins/rotate.js","lib/plugins/saturate.js","lib/plugins/toAlpha.js"],"sourcesContent":["var installedColorSpaces = [];\nvar undef = function (obj) {\n return typeof obj === 'undefined';\n};\nvar channelRegExp = /\\s*(\\.\\d+|\\d+(?:\\.\\d+)?)(%)?\\s*/;\nvar percentageChannelRegExp = /\\s*(\\.\\d+|100|\\d?\\d(?:\\.\\d+)?)%\\s*/;\nvar alphaChannelRegExp = /\\s*(\\.\\d+|\\d+(?:\\.\\d+)?)\\s*/;\nvar cssColorRegExp = new RegExp(\n '^(rgb|hsl|hsv)a?' +\n '\\\\(' +\n channelRegExp.source +\n ',' +\n channelRegExp.source +\n ',' +\n channelRegExp.source +\n '(?:,' +\n alphaChannelRegExp.source +\n ')?' +\n '\\\\)$',\n 'i'\n);\n\nfunction color(obj) {\n if (Array.isArray(obj)) {\n if (typeof obj[0] === 'string' && typeof color[obj[0]] === 'function') {\n // Assumed array from .toJSON()\n return new color[obj[0]](obj.slice(1, obj.length));\n } else if (obj.length === 4) {\n // Assumed 4 element int RGB array from canvas with all channels [0;255]\n return new color.RGB(\n obj[0] / 255,\n obj[1] / 255,\n obj[2] / 255,\n obj[3] / 255\n );\n }\n } else if (typeof obj === 'string') {\n var lowerCased = obj.toLowerCase();\n if (color.namedColors[lowerCased]) {\n obj = '#' + color.namedColors[lowerCased];\n }\n if (lowerCased === 'transparent') {\n obj = 'rgba(0,0,0,0)';\n }\n // Test for CSS rgb(....) string\n var matchCssSyntax = obj.match(cssColorRegExp);\n if (matchCssSyntax) {\n var colorSpaceName = matchCssSyntax[1].toUpperCase();\n var alpha = undef(matchCssSyntax[8])\n ? matchCssSyntax[8]\n : parseFloat(matchCssSyntax[8]);\n var hasHue = colorSpaceName[0] === 'H';\n var firstChannelDivisor = matchCssSyntax[3] ? 100 : hasHue ? 360 : 255;\n var secondChannelDivisor = matchCssSyntax[5] || hasHue ? 100 : 255;\n var thirdChannelDivisor = matchCssSyntax[7] || hasHue ? 100 : 255;\n if (undef(color[colorSpaceName])) {\n throw new Error('color.' + colorSpaceName + ' is not installed.');\n }\n return new color[colorSpaceName](\n parseFloat(matchCssSyntax[2]) / firstChannelDivisor,\n parseFloat(matchCssSyntax[4]) / secondChannelDivisor,\n parseFloat(matchCssSyntax[6]) / thirdChannelDivisor,\n alpha\n );\n }\n // Assume hex syntax\n if (obj.length < 6) {\n // Allow CSS shorthand\n obj = obj.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, '$1$1$2$2$3$3');\n }\n // Split obj into red, green, and blue components\n var hexMatch = obj.match(\n /^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i\n );\n if (hexMatch) {\n return new color.RGB(\n parseInt(hexMatch[1], 16) / 255,\n parseInt(hexMatch[2], 16) / 255,\n parseInt(hexMatch[3], 16) / 255\n );\n }\n\n // No match so far. Lets try the less likely ones\n if (color.CMYK) {\n var cmykMatch = obj.match(\n new RegExp(\n '^cmyk' +\n '\\\\(' +\n percentageChannelRegExp.source +\n ',' +\n percentageChannelRegExp.source +\n ',' +\n percentageChannelRegExp.source +\n ',' +\n percentageChannelRegExp.source +\n '\\\\)$',\n 'i'\n )\n );\n if (cmykMatch) {\n return new color.CMYK(\n parseFloat(cmykMatch[1]) / 100,\n parseFloat(cmykMatch[2]) / 100,\n parseFloat(cmykMatch[3]) / 100,\n parseFloat(cmykMatch[4]) / 100\n );\n }\n }\n } else if (typeof obj === 'object' && obj.isColor) {\n return obj;\n }\n return false;\n}\n\ncolor.namedColors = {};\n\ncolor.installColorSpace = function (colorSpaceName, propertyNames, config) {\n color[colorSpaceName] = function (a1) {\n // ...\n var args = Array.isArray(a1) ? a1 : arguments;\n propertyNames.forEach(function (propertyName, i) {\n var propertyValue = args[i];\n if (propertyName === 'alpha') {\n this._alpha =\n isNaN(propertyValue) || propertyValue > 1\n ? 1\n : propertyValue < 0\n ? 0\n : propertyValue;\n } else {\n if (isNaN(propertyValue)) {\n throw new Error(\n '[' +\n colorSpaceName +\n ']: Invalid color: (' +\n propertyNames.join(',') +\n ')'\n );\n }\n if (propertyName === 'hue') {\n this._hue =\n propertyValue < 0\n ? propertyValue - Math.floor(propertyValue)\n : propertyValue % 1;\n } else {\n this['_' + propertyName] =\n propertyValue < 0 ? 0 : propertyValue > 1 ? 1 : propertyValue;\n }\n }\n }, this);\n };\n color[colorSpaceName].propertyNames = propertyNames;\n\n var prototype = color[colorSpaceName].prototype;\n\n ['valueOf', 'hex', 'hexa', 'css', 'cssa'].forEach(function (methodName) {\n prototype[methodName] =\n prototype[methodName] ||\n (colorSpaceName === 'RGB'\n ? prototype.hex\n : function () {\n return this.rgb()[methodName]();\n });\n });\n\n prototype.isColor = true;\n\n prototype.equals = function (otherColor, epsilon) {\n if (undef(epsilon)) {\n epsilon = 1e-10;\n }\n\n otherColor = otherColor[colorSpaceName.toLowerCase()]();\n\n for (var i = 0; i < propertyNames.length; i = i + 1) {\n if (\n Math.abs(\n this['_' + propertyNames[i]] - otherColor['_' + propertyNames[i]]\n ) > epsilon\n ) {\n return false;\n }\n }\n\n return true;\n };\n\n prototype.toJSON = function () {\n return [colorSpaceName].concat(\n propertyNames.map(function (propertyName) {\n return this['_' + propertyName];\n }, this)\n );\n };\n\n for (var propertyName in config) {\n if (Object.prototype.hasOwnProperty.call(config, propertyName)) {\n var matchFromColorSpace = propertyName.match(/^from(.*)$/);\n if (matchFromColorSpace) {\n color[matchFromColorSpace[1].toUpperCase()].prototype[\n colorSpaceName.toLowerCase()\n ] = config[propertyName];\n } else {\n prototype[propertyName] = config[propertyName];\n }\n }\n }\n\n // It is pretty easy to implement the conversion to the same color space:\n prototype[colorSpaceName.toLowerCase()] = function () {\n return this;\n };\n prototype.toString = function () {\n return (\n '[' +\n colorSpaceName +\n ' ' +\n propertyNames\n .map(function (propertyName) {\n return this['_' + propertyName];\n }, this)\n .join(', ') +\n ']'\n );\n };\n\n // Generate getters and setters\n propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n prototype[propertyName] = prototype[shortName] = function (value, isDelta) {\n // Simple getter mode: color.red()\n if (typeof value === 'undefined') {\n return this['_' + propertyName];\n } else if (isDelta) {\n // Adjuster: color.red(+.2, true)\n return new this.constructor(\n propertyNames.map(function (otherPropertyName) {\n return (\n this['_' + otherPropertyName] +\n (propertyName === otherPropertyName ? value : 0)\n );\n }, this)\n );\n } else {\n // Setter: color.red(.2);\n return new this.constructor(\n propertyNames.map(function (otherPropertyName) {\n return propertyName === otherPropertyName\n ? value\n : this['_' + otherPropertyName];\n }, this)\n );\n }\n };\n });\n\n function installForeignMethods(targetColorSpaceName, sourceColorSpaceName) {\n var obj = {};\n obj[sourceColorSpaceName.toLowerCase()] = function () {\n return this.rgb()[sourceColorSpaceName.toLowerCase()]();\n };\n color[sourceColorSpaceName].propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n obj[propertyName] = obj[shortName] = function (value, isDelta) {\n return this[sourceColorSpaceName.toLowerCase()]()[propertyName](\n value,\n isDelta\n );\n };\n });\n for (var prop in obj) {\n if (\n Object.prototype.hasOwnProperty.call(obj, prop) &&\n color[targetColorSpaceName].prototype[prop] === undefined\n ) {\n color[targetColorSpaceName].prototype[prop] = obj[prop];\n }\n }\n }\n\n installedColorSpaces.forEach(function (otherColorSpaceName) {\n installForeignMethods(colorSpaceName, otherColorSpaceName);\n installForeignMethods(otherColorSpaceName, colorSpaceName);\n });\n\n installedColorSpaces.push(colorSpaceName);\n return color;\n};\n\ncolor.pluginList = [];\n\ncolor.use = function (plugin) {\n if (color.pluginList.indexOf(plugin) === -1) {\n this.pluginList.push(plugin);\n plugin(color);\n }\n return color;\n};\n\ncolor.installMethod = function (name, fn) {\n installedColorSpaces.forEach(function (colorSpace) {\n color[colorSpace].prototype[name] = fn;\n });\n return this;\n};\n\ncolor.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], {\n hex: function () {\n var hexString = (\n Math.round(255 * this._red) * 0x10000 +\n Math.round(255 * this._green) * 0x100 +\n Math.round(255 * this._blue)\n ).toString(16);\n return '#' + '00000'.substr(0, 6 - hexString.length) + hexString;\n },\n\n hexa: function () {\n var alphaString = Math.round(this._alpha * 255).toString(16);\n return (\n '#' +\n '00'.substr(0, 2 - alphaString.length) +\n alphaString +\n this.hex().substr(1, 6)\n );\n },\n\n css: function () {\n return (\n 'rgb(' +\n Math.round(255 * this._red) +\n ',' +\n Math.round(255 * this._green) +\n ',' +\n Math.round(255 * this._blue) +\n ')'\n );\n },\n\n cssa: function () {\n return (\n 'rgba(' +\n Math.round(255 * this._red) +\n ',' +\n Math.round(255 * this._green) +\n ',' +\n Math.round(255 * this._blue) +\n ',' +\n this._alpha +\n ')'\n );\n },\n});\n\nmodule.exports = color;\n","module.exports = function XYZ(color) {\n color.installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], {\n fromRgb: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=02#text2\n var convert = function (channel) {\n return channel > 0.04045\n ? Math.pow((channel + 0.055) / 1.055, 2.4)\n : channel / 12.92;\n };\n var r = convert(this._red);\n var g = convert(this._green);\n var b = convert(this._blue);\n\n // Reference white point sRGB D65:\n // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n return new color.XYZ(\n r * 0.4124564 + g * 0.3575761 + b * 0.1804375,\n r * 0.2126729 + g * 0.7151522 + b * 0.072175,\n r * 0.0193339 + g * 0.119192 + b * 0.9503041,\n this._alpha\n );\n },\n\n rgb: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=01#text1\n var x = this._x;\n var y = this._y;\n var z = this._z;\n var convert = function (channel) {\n return channel > 0.0031308\n ? 1.055 * Math.pow(channel, 1 / 2.4) - 0.055\n : 12.92 * channel;\n };\n\n // Reference white point sRGB D65:\n // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n return new color.RGB(\n convert(x * 3.2404542 + y * -1.5371385 + z * -0.4985314),\n convert(x * -0.969266 + y * 1.8760108 + z * 0.041556),\n convert(x * 0.0556434 + y * -0.2040259 + z * 1.0572252),\n this._alpha\n );\n },\n\n lab: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=07#text7\n var convert = function (channel) {\n return channel > 0.008856\n ? Math.pow(channel, 1 / 3)\n : 7.787037 * channel + 4 / 29;\n };\n var x = convert(this._x / 95.047);\n var y = convert(this._y / 100.0);\n var z = convert(this._z / 108.883);\n\n return new color.LAB(\n 116 * y - 16,\n 500 * (x - y),\n 200 * (y - z),\n this._alpha\n );\n },\n });\n};\n","module.exports = function HSV(color) {\n color.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {\n rgb: function () {\n var hue = this._hue;\n var saturation = this._saturation;\n var value = this._value;\n var i = Math.min(5, Math.floor(hue * 6));\n var f = hue * 6 - i;\n var p = value * (1 - saturation);\n var q = value * (1 - f * saturation);\n var t = value * (1 - (1 - f) * saturation);\n var red;\n var green;\n var blue;\n switch (i) {\n case 0:\n red = value;\n green = t;\n blue = p;\n break;\n case 1:\n red = q;\n green = value;\n blue = p;\n break;\n case 2:\n red = p;\n green = value;\n blue = t;\n break;\n case 3:\n red = p;\n green = q;\n blue = value;\n break;\n case 4:\n red = t;\n green = p;\n blue = value;\n break;\n case 5:\n red = value;\n green = p;\n blue = q;\n break;\n }\n return new color.RGB(red, green, blue, this._alpha);\n },\n\n hsl: function () {\n var l = (2 - this._saturation) * this._value;\n var sv = this._saturation * this._value;\n var svDivisor = l <= 1 ? l : 2 - l;\n var saturation;\n\n // Avoid division by zero when lightness approaches zero:\n if (svDivisor < 1e-9) {\n saturation = 0;\n } else {\n saturation = sv / svDivisor;\n }\n return new color.HSL(this._hue, saturation, l / 2, this._alpha);\n },\n\n fromRgb: function () {\n // Becomes one.color.RGB.prototype.hsv\n var red = this._red;\n var green = this._green;\n var blue = this._blue;\n var max = Math.max(red, green, blue);\n var min = Math.min(red, green, blue);\n var delta = max - min;\n var hue;\n var saturation = max === 0 ? 0 : delta / max;\n var value = max;\n if (delta === 0) {\n hue = 0;\n } else {\n switch (max) {\n case red:\n hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);\n break;\n case green:\n hue = (blue - red) / delta / 6 + 1 / 3;\n break;\n case blue:\n hue = (red - green) / delta / 6 + 2 / 3;\n break;\n }\n }\n return new color.HSV(hue, saturation, value, this._alpha);\n },\n });\n};\n","module.exports = function HSL(color) {\n color.use(require('./HSV'));\n\n color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {\n hsv: function () {\n // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts\n var l = this._lightness * 2;\n var s = this._saturation * (l <= 1 ? l : 2 - l);\n var saturation;\n\n // Avoid division by zero when l + s is very small (approaching black):\n if (l + s < 1e-9) {\n saturation = 0;\n } else {\n saturation = (2 * s) / (l + s);\n }\n\n return new color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);\n },\n\n rgb: function () {\n return this.hsv().rgb();\n },\n\n fromRgb: function () {\n // Becomes one.color.RGB.prototype.hsv\n return this.hsv().hsl();\n },\n });\n};\n","module.exports = function luminance(color) {\n // http://www.w3.org/TR/WCAG20/#relativeluminancedef\n\n function channelLuminance(value) {\n return value <= 0.03928\n ? value / 12.92\n : Math.pow((value + 0.055) / 1.055, 2.4);\n }\n\n color.installMethod('luminance', function () {\n var rgb = this.rgb();\n return (\n 0.2126 * channelLuminance(rgb._red) +\n 0.7152 * channelLuminance(rgb._green) +\n 0.0722 * channelLuminance(rgb._blue)\n );\n });\n};\n","module.exports = function isDark(color) {\n color.installMethod('isDark', function () {\n var rgb = this.rgb();\n\n // YIQ equation from http://24ways.org/2010/calculating-color-contrast\n var yiq =\n (rgb._red * 255 * 299 + rgb._green * 255 * 587 + rgb._blue * 255 * 114) /\n 1000;\n return yiq < 128;\n });\n};\n","module.exports = require('./lib/color')\n .use(require('./lib/XYZ'))\n .use(require('./lib/LAB'))\n .use(require('./lib/HSV'))\n .use(require('./lib/HSL'))\n .use(require('./lib/CMYK'))\n\n // Convenience functions\n .use(require('./lib/plugins/namedColors'))\n .use(require('./lib/plugins/clearer.js'))\n .use(require('./lib/plugins/contrast.js'))\n .use(require('./lib/plugins/darken.js'))\n .use(require('./lib/plugins/desaturate.js'))\n .use(require('./lib/plugins/grayscale.js'))\n .use(require('./lib/plugins/isDark.js'))\n .use(require('./lib/plugins/isLight.js'))\n .use(require('./lib/plugins/lighten.js'))\n .use(require('./lib/plugins/luminance.js'))\n .use(require('./lib/plugins/mix.js'))\n .use(require('./lib/plugins/negate.js'))\n .use(require('./lib/plugins/opaquer.js'))\n .use(require('./lib/plugins/rotate.js'))\n .use(require('./lib/plugins/saturate.js'))\n .use(require('./lib/plugins/toAlpha.js'));\n","module.exports = function LAB(color) {\n color.use(require('./XYZ.js'));\n\n color.installColorSpace('LAB', ['l', 'a', 'b', 'alpha'], {\n fromRgb: function () {\n return this.xyz().lab();\n },\n\n rgb: function () {\n return this.xyz().rgb();\n },\n\n xyz: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=08#text8\n var convert = function (channel) {\n var pow = Math.pow(channel, 3);\n return pow > 0.008856 ? pow : (channel - 16 / 116) / 7.87;\n };\n var y = (this._l + 16) / 116;\n var x = this._a / 500 + y;\n var z = y - this._b / 200;\n\n return new color.XYZ(\n convert(x) * 95.047,\n convert(y) * 100.0,\n convert(z) * 108.883,\n this._alpha\n );\n },\n });\n};\n","module.exports = function CMYK(color) {\n color.installColorSpace(\n 'CMYK',\n ['cyan', 'magenta', 'yellow', 'black', 'alpha'],\n {\n rgb: function () {\n return new color.RGB(\n 1 - this._cyan * (1 - this._black) - this._black,\n 1 - this._magenta * (1 - this._black) - this._black,\n 1 - this._yellow * (1 - this._black) - this._black,\n this._alpha\n );\n },\n\n fromRgb: function () {\n // Becomes one.color.RGB.prototype.cmyk\n // Adapted from http://www.javascripter.net/faq/rgb2cmyk.htm\n var red = this._red;\n var green = this._green;\n var blue = this._blue;\n var cyan = 1 - red;\n var magenta = 1 - green;\n var yellow = 1 - blue;\n var black = 1;\n if (red || green || blue) {\n black = Math.min(cyan, Math.min(magenta, yellow));\n cyan = (cyan - black) / (1 - black);\n magenta = (magenta - black) / (1 - black);\n yellow = (yellow - black) / (1 - black);\n } else {\n black = 1;\n }\n return new color.CMYK(cyan, magenta, yellow, black, this._alpha);\n },\n }\n );\n};\n","module.exports = function namedColors(color) {\n color.namedColors = {\n aliceblue: 'f0f8ff',\n antiquewhite: 'faebd7',\n aqua: '0ff',\n aquamarine: '7fffd4',\n azure: 'f0ffff',\n beige: 'f5f5dc',\n bisque: 'ffe4c4',\n black: '000',\n blanchedalmond: 'ffebcd',\n blue: '00f',\n blueviolet: '8a2be2',\n brown: 'a52a2a',\n burlywood: 'deb887',\n cadetblue: '5f9ea0',\n chartreuse: '7fff00',\n chocolate: 'd2691e',\n coral: 'ff7f50',\n cornflowerblue: '6495ed',\n cornsilk: 'fff8dc',\n crimson: 'dc143c',\n cyan: '0ff',\n darkblue: '00008b',\n darkcyan: '008b8b',\n darkgoldenrod: 'b8860b',\n darkgray: 'a9a9a9',\n darkgrey: 'a9a9a9',\n darkgreen: '006400',\n darkkhaki: 'bdb76b',\n darkmagenta: '8b008b',\n darkolivegreen: '556b2f',\n darkorange: 'ff8c00',\n darkorchid: '9932cc',\n darkred: '8b0000',\n darksalmon: 'e9967a',\n darkseagreen: '8fbc8f',\n darkslateblue: '483d8b',\n darkslategray: '2f4f4f',\n darkslategrey: '2f4f4f',\n darkturquoise: '00ced1',\n darkviolet: '9400d3',\n deeppink: 'ff1493',\n deepskyblue: '00bfff',\n dimgray: '696969',\n dimgrey: '696969',\n dodgerblue: '1e90ff',\n firebrick: 'b22222',\n floralwhite: 'fffaf0',\n forestgreen: '228b22',\n fuchsia: 'f0f',\n gainsboro: 'dcdcdc',\n ghostwhite: 'f8f8ff',\n gold: 'ffd700',\n goldenrod: 'daa520',\n gray: '808080',\n grey: '808080',\n green: '008000',\n greenyellow: 'adff2f',\n honeydew: 'f0fff0',\n hotpink: 'ff69b4',\n indianred: 'cd5c5c',\n indigo: '4b0082',\n ivory: 'fffff0',\n khaki: 'f0e68c',\n lavender: 'e6e6fa',\n lavenderblush: 'fff0f5',\n lawngreen: '7cfc00',\n lemonchiffon: 'fffacd',\n lightblue: 'add8e6',\n lightcoral: 'f08080',\n lightcyan: 'e0ffff',\n lightgoldenrodyellow: 'fafad2',\n lightgray: 'd3d3d3',\n lightgrey: 'd3d3d3',\n lightgreen: '90ee90',\n lightpink: 'ffb6c1',\n lightsalmon: 'ffa07a',\n lightseagreen: '20b2aa',\n lightskyblue: '87cefa',\n lightslategray: '789',\n lightslategrey: '789',\n lightsteelblue: 'b0c4de',\n lightyellow: 'ffffe0',\n lime: '0f0',\n limegreen: '32cd32',\n linen: 'faf0e6',\n magenta: 'f0f',\n maroon: '800000',\n mediumaquamarine: '66cdaa',\n mediumblue: '0000cd',\n mediumorchid: 'ba55d3',\n mediumpurple: '9370d8',\n mediumseagreen: '3cb371',\n mediumslateblue: '7b68ee',\n mediumspringgreen: '00fa9a',\n mediumturquoise: '48d1cc',\n mediumvioletred: 'c71585',\n midnightblue: '191970',\n mintcream: 'f5fffa',\n mistyrose: 'ffe4e1',\n moccasin: 'ffe4b5',\n navajowhite: 'ffdead',\n navy: '000080',\n oldlace: 'fdf5e6',\n olive: '808000',\n olivedrab: '6b8e23',\n orange: 'ffa500',\n orangered: 'ff4500',\n orchid: 'da70d6',\n palegoldenrod: 'eee8aa',\n palegreen: '98fb98',\n paleturquoise: 'afeeee',\n palevioletred: 'd87093',\n papayawhip: 'ffefd5',\n peachpuff: 'ffdab9',\n peru: 'cd853f',\n pink: 'ffc0cb',\n plum: 'dda0dd',\n powderblue: 'b0e0e6',\n purple: '800080',\n rebeccapurple: '639',\n red: 'f00',\n rosybrown: 'bc8f8f',\n royalblue: '4169e1',\n saddlebrown: '8b4513',\n salmon: 'fa8072',\n sandybrown: 'f4a460',\n seagreen: '2e8b57',\n seashell: 'fff5ee',\n sienna: 'a0522d',\n silver: 'c0c0c0',\n skyblue: '87ceeb',\n slateblue: '6a5acd',\n slategray: '708090',\n slategrey: '708090',\n snow: 'fffafa',\n springgreen: '00ff7f',\n steelblue: '4682b4',\n tan: 'd2b48c',\n teal: '008080',\n thistle: 'd8bfd8',\n tomato: 'ff6347',\n turquoise: '40e0d0',\n violet: 'ee82ee',\n wheat: 'f5deb3',\n white: 'fff',\n whitesmoke: 'f5f5f5',\n yellow: 'ff0',\n yellowgreen: '9acd32',\n };\n};\n","module.exports = function clearer(color) {\n color.installMethod('clearer', function (amount) {\n return this.alpha(isNaN(amount) ? -0.1 : -amount, true);\n });\n};\n","module.exports = function contrast(color) {\n // http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n\n color.use(require('./luminance'));\n\n color.installMethod('contrast', function (color2) {\n var lum1 = this.luminance();\n var lum2 = color2.luminance();\n if (lum1 > lum2) {\n return (lum1 + 0.05) / (lum2 + 0.05);\n }\n\n return (lum2 + 0.05) / (lum1 + 0.05);\n });\n};\n","module.exports = function darken(color) {\n color.use(require('../HSL'));\n\n color.installMethod('darken', function (amount) {\n return this.lightness(isNaN(amount) ? -0.1 : -amount, true);\n });\n};\n","module.exports = function desaturate(color) {\n color.use(require('../HSL'));\n\n color.installMethod('desaturate', function (amount) {\n return this.saturation(isNaN(amount) ? -0.1 : -amount, true);\n });\n};\n","module.exports = function grayscale(color) {\n function gs() {\n /* jslint strict:false */\n var rgb = this.rgb();\n var val = rgb._red * 0.3 + rgb._green * 0.59 + rgb._blue * 0.11;\n\n return new color.RGB(val, val, val, rgb._alpha);\n }\n\n color.installMethod('greyscale', gs).installMethod('grayscale', gs);\n};\n","module.exports = function isLight(color) {\n color.use(require('./isDark'));\n\n color.installMethod('isLight', function () {\n return !this.isDark();\n });\n};\n","module.exports = function lighten(color) {\n color.use(require('../HSL'));\n\n color.installMethod('lighten', function (amount) {\n return this.lightness(isNaN(amount) ? 0.1 : amount, true);\n });\n};\n","module.exports = function mix(color) {\n color.installMethod('mix', function (otherColor, weight) {\n otherColor = color(otherColor).rgb();\n weight = 1 - (isNaN(weight) ? 0.5 : weight);\n\n var w = weight * 2 - 1;\n var a = this._alpha - otherColor._alpha;\n var weight1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;\n var weight2 = 1 - weight1;\n var rgb = this.rgb();\n\n return new color.RGB(\n rgb._red * weight1 + otherColor._red * weight2,\n rgb._green * weight1 + otherColor._green * weight2,\n rgb._blue * weight1 + otherColor._blue * weight2,\n rgb._alpha * weight + otherColor._alpha * (1 - weight)\n );\n });\n};\n","module.exports = function negate(color) {\n color.installMethod('negate', function () {\n var rgb = this.rgb();\n return new color.RGB(\n 1 - rgb._red,\n 1 - rgb._green,\n 1 - rgb._blue,\n this._alpha\n );\n });\n};\n","module.exports = function opaquer(color) {\n color.installMethod('opaquer', function (amount) {\n return this.alpha(isNaN(amount) ? 0.1 : amount, true);\n });\n};\n","module.exports = function rotate(color) {\n color.use(require('../HSL'));\n\n color.installMethod('rotate', function (degrees) {\n return this.hue((degrees || 0) / 360, true);\n });\n};\n","module.exports = function saturate(color) {\n color.use(require('../HSL'));\n\n color.installMethod('saturate', function (amount) {\n return this.saturation(isNaN(amount) ? 0.1 : amount, true);\n });\n};\n","// Adapted from http://gimp.sourcearchive.com/documentation/2.6.6-1ubuntu1/color-to-alpha_8c-source.html\n// toAlpha returns a color where the values of the argument have been converted to alpha\nmodule.exports = function toAlpha(color) {\n color.installMethod('toAlpha', function (color) {\n var me = this.rgb();\n var other = color(color).rgb();\n var epsilon = 1e-10;\n var a = new color.RGB(0, 0, 0, me._alpha);\n var channels = ['_red', '_green', '_blue'];\n\n channels.forEach(function (channel) {\n if (me[channel] < epsilon) {\n a[channel] = me[channel];\n } else if (me[channel] > other[channel]) {\n a[channel] = (me[channel] - other[channel]) / (1 - other[channel]);\n } else if (me[channel] > other[channel]) {\n a[channel] = (other[channel] - me[channel]) / other[channel];\n } else {\n a[channel] = 0;\n }\n });\n\n if (a._red > a._green) {\n if (a._red > a._blue) {\n me._alpha = a._red;\n } else {\n me._alpha = a._blue;\n }\n } else if (a._green > a._blue) {\n me._alpha = a._green;\n } else {\n me._alpha = a._blue;\n }\n\n if (me._alpha < epsilon) {\n return me;\n }\n\n channels.forEach(function (channel) {\n me[channel] = (me[channel] - other[channel]) / me._alpha + other[channel];\n });\n me._alpha *= a._alpha;\n\n return me;\n });\n};\n"],"names":["installedColorSpaces","undef","obj","channelRegExp","percentageChannelRegExp","cssColorRegExp","RegExp","source","color","Array","isArray","slice","length","RGB","lowerCased","toLowerCase","namedColors","matchCssSyntax","match","colorSpaceName","toUpperCase","alpha","parseFloat","hasHue","firstChannelDivisor","secondChannelDivisor","thirdChannelDivisor","Error","replace","hexMatch","parseInt","CMYK","cmykMatch","isColor","installColorSpace","propertyNames","config","a1","args","arguments","forEach","propertyName","i","propertyValue","this","_alpha","isNaN","join","_hue","Math","floor","prototype","methodName","hex","rgb","equals","otherColor","epsilon","abs","toJSON","concat","map","Object","hasOwnProperty","call","matchFromColorSpace","installForeignMethods","targetColorSpaceName","sourceColorSpaceName","prop","shortName","charAt","value","isDelta","undefined","toString","constructor","otherPropertyName","otherColorSpaceName","push","pluginList","use","plugin","indexOf","installMethod","name","fn","colorSpace","hexString","round","_red","_green","_blue","substr","hexa","alphaString","css","cssa","fromRgb","convert","channel","pow","r","g","b","XYZ","x","_x","y","_y","z","_z","lab","LAB","red","green","blue","hue","saturation","_saturation","_value","min","f","p","q","t","hsl","l","sv","svDivisor","HSL","max","delta","HSV","require$$0","hsv","_lightness","s","channelLuminance","require$$1","xyz","_l","_a","_b","require$$3","require$$4","_cyan","_black","_magenta","_yellow","cyan","magenta","yellow","black","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellowgreen","amount","color2","lum1","luminance","lum2","lightness","gs","val","require$$12","isDark","require$$15","weight","w","a","weight1","weight2","degrees","me","other","channels"],"mappings":"kNAAA,IAAIA,EAAuB,GACvBC,EAAQ,SAAUC,GACpB,YAAsB,IAARA,GAEZC,EAAgB,kCAChBC,EAA0B,qCAE1BC,EAAiB,IAAIC,OACvB,sBAEEH,EAAcI,OACd,IACAJ,EAAcI,OACd,IACAJ,EAAcI,OACd,OATqB,8BAUFA,OARrB,SAWA,KAGF,SAASC,EAAMN,GACb,GAAIO,MAAMC,QAAQR,GAAM,CACtB,GAAsB,iBAAXA,EAAI,IAA4C,mBAAlBM,EAAMN,EAAI,IAEjD,OAAO,IAAIM,EAAMN,EAAI,IAAIA,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G,EAAG,EAAG2S,EAAG3Q,QAC9B6Q,EAAW,CAAC,OAAQ,SAAU,SA0BlC,OAxBAA,EAASlR,SAAQ,SAAU4D,GACrBoN,EAAGpN,GALK,MAMVgN,EAAEhN,GAAWoN,EAAGpN,GACPoN,EAAGpN,GAAWqN,EAAMrN,GAC7BgN,EAAEhN,IAAYoN,EAAGpN,GAAWqN,EAAMrN,KAAa,EAAIqN,EAAMrN,IAChDoN,EAAGpN,GAAWqN,EAAMrN,GAC7BgN,EAAEhN,IAAYqN,EAAMrN,GAAWoN,EAAGpN,IAAYqN,EAAMrN,GAEpDgN,EAAEhN,GAAW,KAIbgN,EAAE1N,KAAO0N,EAAEzN,OACTyN,EAAE1N,KAAO0N,EAAExN,MACb4N,EAAG3Q,OAASuQ,EAAE1N,KAEd8N,EAAG3Q,OAASuQ,EAAExN,MAEPwN,EAAEzN,OAASyN,EAAExN,MACtB4N,EAAG3Q,OAASuQ,EAAEzN,OAEd6N,EAAG3Q,OAASuQ,EAAExN,MAGZ4N,EAAG3Q,OA5BO,QAgCd6Q,EAASlR,SAAQ,SAAU4D,GACzBoN,EAAGpN,IAAYoN,EAAGpN,GAAWqN,EAAMrN,IAAYoN,EAAG3Q,OAAS4Q,EAAMrN,MAEnEoN,EAAG3Q,QAAUuQ,EAAEvQ,QANN2Q"} \ No newline at end of file diff --git a/one-color-all.map b/one-color-all.map deleted file mode 100644 index f2fa36d..0000000 --- a/one-color-all.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["node_modules/browserify/node_modules/browser-pack/_prelude.js","index","lib/plugins/clearer.js","lib/plugins/lighten.js","lib/plugins/desaturate.js","lib/plugins/darken.js","lib/plugins/mix.js","lib/plugins/negate.js","lib/plugins/opaquer.js","lib/plugins/rotate.js","lib/plugins/grayscale.js","lib/plugins/saturate.js","lib/plugins/toAlpha.js","lib/color.js","lib/HSV.js","lib/LAB.js","lib/XYZ.js","lib/HSL.js","lib/CMYK.js","lib/plugins/namedColors.js"],"names":["module","exports","color","installMethod","amount","this","alpha","isNaN","use","require","lightness","saturation","otherColor","weight","rgb","w","a","_alpha","weight1","weight2","RGB","_red","_green","_blue","degrees","hue","gs","val","me","other","epsilon","channels","forEach","channel","obj","Array","isArray","slice","length","lowerCased","toLowerCase","namedColors","matchCssSyntax","match","cssColorRegExp","colorSpaceName","toUpperCase","undef","parseFloat","hasHue","firstChannelDivisor","secondChannelDivisor","thirdChannelDivisor","Error","replace","hexMatch","parseInt","CMYK","cmykMatch","RegExp","percentageChannelRegExp","source","isColor","installedColorSpaces","channelRegExp","alphaChannelRegExp","installColorSpace","propertyNames","config","installForeignMethods","targetColorSpaceName","sourceColorSpaceName","propertyName","shortName","charAt","value","isDelta","prop","hasOwnProperty","undefined","prototype","a1","args","arguments","i","propertyValue","join","_hue","Math","floor","methodName","hex","equals","abs","toJSON","concat","map","matchFromColorSpace","toString","constructor","otherPropertyName","otherColorSpaceName","push","pluginList","plugin","indexOf","name","fn","colorSpace","hexString","round","substr","hexa","alphaString","css","cssa","red","green","blue","_saturation","_value","min","f","p","q","t","hsl","l","sv","svDivisor","HSL","fromRgb","max","delta","HSV","xyz","lab","convert","pow","y","_l","x","_a","z","_b","XYZ","r","g","b","_x","_y","_z","LAB","hsv","_lightness","s","_cyan","_black","_magenta","_yellow","cyan","magenta","yellow","black","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellowgreen"],"mappings":"AAAA;ACAA;;AiBAAA,OAAOC,QAAU,SAAcC,GAC3BA,EAAMgE,kBAAkB,QAAS,OAAQ,UAAW,SAAU,QAAS,UACnEpD,IAAK,WACD,MAAO,IAAIZ,GAAMkB,IAAK,EAAIf,KAAKuJ,OAAS,EAAIvJ,KAAKwJ,QAAUxJ,KAAKwJ,OACtC,EAAIxJ,KAAKyJ,UAAY,EAAIzJ,KAAKwJ,QAAUxJ,KAAKwJ,OAC7C,EAAIxJ,KAAK0J,SAAW,EAAI1J,KAAKwJ,QAAUxJ,KAAKwJ,OAC7CxJ,KAAKY,SAGlCkH,QAAS,WAEL,GAAIf,GAAM/G,KAAKgB,KACXgG,EAAQhH,KAAKiB,OACbgG,EAAOjH,KAAKkB,MACZyI,EAAO,EAAI5C,EACX6C,EAAU,EAAI5C,EACd6C,EAAS,EAAI5C,EACb6C,EAAQ,CASZ,OARI/C,IAAOC,GAASC,GAChB6C,EAAQ3E,KAAKiC,IAAIuC,EAAMxE,KAAKiC,IAAIwC,EAASC,IACzCF,GAAQA,EAAOG,IAAU,EAAIA,GAC7BF,GAAWA,EAAUE,IAAU,EAAIA,GACnCD,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,WAElBP,EAAMC,cAAc,WAAY,SAAUC,GACtC,MAAOC,MAAKM,WAAWJ,MAAMH,GAAU,GAAMA,GAAQ;;ACF7DJ,OAAOC,QAAU,SAAiBC,GAC9BA,EAAMC,cAAc,UAAW,SAAUD,GACrC,GAAI0B,GAAKvB,KAAKS,MACVe,EAAQ3B,EAAMA,GAAOY,MACrBgB,EAAU,MACVd,EAAI,GAAId,GAAMkB,IAAI,EAAG,EAAG,EAAGQ,EAAGX,QAC9Bc,GAAY,OAAQ,SAAU,QA0BlC,OAxBAA,GAASC,QAAQ,SAAUC,GACnBL,EAAGK,GAAWH,EACdd,EAAEiB,GAAWL,EAAGK,GACTL,EAAGK,GAAWJ,EAAMI,GAC3BjB,EAAEiB,IAAYL,EAAGK,GAAWJ,EAAMI,KAAa,EAAIJ,EAAMI,IAClDL,EAAGK,GAAWJ,EAAMI,GAC3BjB,EAAEiB,IAAYJ,EAAMI,GAAWL,EAAGK,IAAYJ,EAAMI,GAEpDjB,EAAEiB,GAAW,IAIjBjB,EAAEK,KAAOL,EAAEM,OACPN,EAAEK,KAAOL,EAAEO,MACXK,EAAGX,OAASD,EAAEK,KAEdO,EAAGX,OAASD,EAAEO,MAEXP,EAAEM,OAASN,EAAEO,MACpBK,EAAGX,OAASD,EAAEM,OAEdM,EAAGX,OAASD,EAAEO,MAGdK,EAAGX,OAASa,EACLF,GAGXG,EAASC,QAAQ,SAAUC,GACvBL,EAAGK,IAAYL,EAAGK,GAAWJ,EAAMI,IAAYL,EAAGX,OAASY,EAAMI,KAErEL,EAAGX,QAAUD,EAAEC,OAERW","file":"bundle.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o other[channel]) {\n a[channel] = (me[channel] - other[channel]) / (1 - other[channel]);\n } else if (me[channel] > other[channel]) {\n a[channel] = (other[channel] - me[channel]) / other[channel];\n } else {\n a[channel] = 0;\n }\n });\n\n if (a._red > a._green) {\n if (a._red > a._blue) {\n me._alpha = a._red;\n } else {\n me._alpha = a._blue;\n }\n } else if (a._green > a._blue) {\n me._alpha = a._green;\n } else {\n me._alpha = a._blue;\n }\n\n if (me._alpha < epsilon) {\n return me;\n }\n\n channels.forEach(function (channel) {\n me[channel] = (me[channel] - other[channel]) / me._alpha + other[channel];\n });\n me._alpha *= a._alpha;\n\n return me;\n });\n};\n","var installedColorSpaces = [],\n undef = function (obj) {\n return typeof obj === 'undefined';\n },\n channelRegExp = /\\s*(\\.\\d+|\\d+(?:\\.\\d+)?)(%)?\\s*/,\n percentageChannelRegExp = /\\s*(\\.\\d+|100|\\d?\\d(?:\\.\\d+)?)%\\s*/,\n alphaChannelRegExp = /\\s*(\\.\\d+|\\d+(?:\\.\\d+)?)\\s*/,\n cssColorRegExp = new RegExp(\n '^(rgb|hsl|hsv)a?' +\n '\\\\(' +\n channelRegExp.source + ',' +\n channelRegExp.source + ',' +\n channelRegExp.source +\n '(?:,' + alphaChannelRegExp.source + ')?' +\n '\\\\)$', 'i');\n\nfunction color(obj) {\n if (Array.isArray(obj)) {\n if (typeof obj[0] === 'string' && typeof color[obj[0]] === 'function') {\n // Assumed array from .toJSON()\n return new color[obj[0]](obj.slice(1, obj.length));\n } else if (obj.length === 4) {\n // Assumed 4 element int RGB array from canvas with all channels [0;255]\n return new color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);\n }\n } else if (typeof obj === 'string') {\n var lowerCased = obj.toLowerCase();\n if (color.namedColors[lowerCased]) {\n obj = '#' + color.namedColors[lowerCased];\n }\n if (lowerCased === 'transparent') {\n obj = 'rgba(0,0,0,0)';\n }\n // Test for CSS rgb(....) string\n var matchCssSyntax = obj.match(cssColorRegExp);\n if (matchCssSyntax) {\n var colorSpaceName = matchCssSyntax[1].toUpperCase(),\n alpha = undef(matchCssSyntax[8]) ? matchCssSyntax[8] : parseFloat(matchCssSyntax[8]),\n hasHue = colorSpaceName[0] === 'H',\n firstChannelDivisor = matchCssSyntax[3] ? 100 : (hasHue ? 360 : 255),\n secondChannelDivisor = (matchCssSyntax[5] || hasHue) ? 100 : 255,\n thirdChannelDivisor = (matchCssSyntax[7] || hasHue) ? 100 : 255;\n if (undef(color[colorSpaceName])) {\n throw new Error('color.' + colorSpaceName + ' is not installed.');\n }\n return new color[colorSpaceName](\n parseFloat(matchCssSyntax[2]) / firstChannelDivisor,\n parseFloat(matchCssSyntax[4]) / secondChannelDivisor,\n parseFloat(matchCssSyntax[6]) / thirdChannelDivisor,\n alpha\n );\n }\n // Assume hex syntax\n if (obj.length < 6) {\n // Allow CSS shorthand\n obj = obj.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, '$1$1$2$2$3$3');\n }\n // Split obj into red, green, and blue components\n var hexMatch = obj.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);\n if (hexMatch) {\n return new color.RGB(\n parseInt(hexMatch[1], 16) / 255,\n parseInt(hexMatch[2], 16) / 255,\n parseInt(hexMatch[3], 16) / 255\n );\n }\n\n // No match so far. Lets try the less likely ones\n if (color.CMYK) {\n var cmykMatch = obj.match(new RegExp(\n '^cmyk' +\n '\\\\(' +\n percentageChannelRegExp.source + ',' +\n percentageChannelRegExp.source + ',' +\n percentageChannelRegExp.source + ',' +\n percentageChannelRegExp.source +\n '\\\\)$', 'i'));\n if (cmykMatch) {\n return new color.CMYK(\n parseFloat(cmykMatch[1]) / 100,\n parseFloat(cmykMatch[2]) / 100,\n parseFloat(cmykMatch[3]) / 100,\n parseFloat(cmykMatch[4]) / 100\n );\n }\n }\n } else if (typeof obj === 'object' && obj.isColor) {\n return obj;\n }\n return false;\n}\n\ncolor.namedColors = {};\n\ncolor.installColorSpace = function (colorSpaceName, propertyNames, config) {\n color[colorSpaceName] = function (a1) { // ...\n var args = Array.isArray(a1) ? a1 : arguments;\n propertyNames.forEach(function (propertyName, i) {\n var propertyValue = args[i];\n if (propertyName === 'alpha') {\n this._alpha = (isNaN(propertyValue) || propertyValue > 1) ? 1 : (propertyValue < 0 ? 0 : propertyValue);\n } else {\n if (isNaN(propertyValue)) {\n throw new Error('[' + colorSpaceName + ']: Invalid color: (' + propertyNames.join(',') + ')');\n }\n if (propertyName === 'hue') {\n this._hue = propertyValue < 0 ? propertyValue - Math.floor(propertyValue) : propertyValue % 1;\n } else {\n this['_' + propertyName] = propertyValue < 0 ? 0 : (propertyValue > 1 ? 1 : propertyValue);\n }\n }\n }, this);\n };\n color[colorSpaceName].propertyNames = propertyNames;\n\n var prototype = color[colorSpaceName].prototype;\n\n ['valueOf', 'hex', 'hexa', 'css', 'cssa'].forEach(function (methodName) {\n prototype[methodName] = prototype[methodName] || (colorSpaceName === 'RGB' ? prototype.hex : function () {\n return this.rgb()[methodName]();\n });\n });\n\n prototype.isColor = true;\n\n prototype.equals = function (otherColor, epsilon) {\n if (undef(epsilon)) {\n epsilon = 1e-10;\n }\n\n otherColor = otherColor[colorSpaceName.toLowerCase()]();\n\n for (var i = 0; i < propertyNames.length; i = i + 1) {\n if (Math.abs(this['_' + propertyNames[i]] - otherColor['_' + propertyNames[i]]) > epsilon) {\n return false;\n }\n }\n\n return true;\n };\n\n prototype.toJSON = function () {\n return [colorSpaceName].concat(propertyNames.map(function (propertyName) {\n return this['_' + propertyName];\n }, this));\n };\n\n for (var propertyName in config) {\n if (config.hasOwnProperty(propertyName)) {\n var matchFromColorSpace = propertyName.match(/^from(.*)$/);\n if (matchFromColorSpace) {\n color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];\n } else {\n prototype[propertyName] = config[propertyName];\n }\n }\n }\n\n // It is pretty easy to implement the conversion to the same color space:\n prototype[colorSpaceName.toLowerCase()] = function () {\n return this;\n };\n prototype.toString = function () {\n return '[' + colorSpaceName + ' ' + propertyNames.map(function (propertyName) {\n return this['_' + propertyName];\n }).join(', ') + ']';\n };\n\n // Generate getters and setters\n propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n prototype[propertyName] = prototype[shortName] = function (value, isDelta) {\n // Simple getter mode: color.red()\n if (typeof value === 'undefined') {\n return this['_' + propertyName];\n } else if (isDelta) {\n // Adjuster: color.red(+.2, true)\n return new this.constructor(propertyNames.map(function (otherPropertyName) {\n return this['_' + otherPropertyName] + (propertyName === otherPropertyName ? value : 0);\n }, this));\n } else {\n // Setter: color.red(.2);\n return new this.constructor(propertyNames.map(function (otherPropertyName) {\n return (propertyName === otherPropertyName) ? value : this['_' + otherPropertyName];\n }, this));\n }\n };\n });\n\n function installForeignMethods(targetColorSpaceName, sourceColorSpaceName) {\n var obj = {};\n obj[sourceColorSpaceName.toLowerCase()] = function () {\n return this.rgb()[sourceColorSpaceName.toLowerCase()]();\n };\n color[sourceColorSpaceName].propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n obj[propertyName] = obj[shortName] = function (value, isDelta) {\n return this[sourceColorSpaceName.toLowerCase()]()[propertyName](value, isDelta);\n };\n });\n for (var prop in obj) {\n if (obj.hasOwnProperty(prop) && color[targetColorSpaceName].prototype[prop] === undefined) {\n color[targetColorSpaceName].prototype[prop] = obj[prop];\n }\n }\n }\n\n installedColorSpaces.forEach(function (otherColorSpaceName) {\n installForeignMethods(colorSpaceName, otherColorSpaceName);\n installForeignMethods(otherColorSpaceName, colorSpaceName);\n });\n\n installedColorSpaces.push(colorSpaceName);\n return color;\n};\n\ncolor.pluginList = [];\n\ncolor.use = function (plugin) {\n if (color.pluginList.indexOf(plugin) === -1) {\n this.pluginList.push(plugin);\n plugin(color);\n }\n return color;\n};\n\ncolor.installMethod = function (name, fn) {\n installedColorSpaces.forEach(function (colorSpace) {\n color[colorSpace].prototype[name] = fn;\n });\n return this;\n};\n\ncolor.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], {\n hex: function () {\n var hexString = (Math.round(255 * this._red) * 0x10000 + Math.round(255 * this._green) * 0x100 + Math.round(255 * this._blue)).toString(16);\n return '#' + ('00000'.substr(0, 6 - hexString.length)) + hexString;\n },\n\n hexa: function () {\n var alphaString = Math.round(this._alpha * 255).toString(16);\n return '#' + '00'.substr(0, 2 - alphaString.length) + alphaString + this.hex().substr(1, 6);\n },\n\n css: function () {\n return 'rgb(' + Math.round(255 * this._red) + ',' + Math.round(255 * this._green) + ',' + Math.round(255 * this._blue) + ')';\n },\n\n cssa: function () {\n return 'rgba(' + Math.round(255 * this._red) + ',' + Math.round(255 * this._green) + ',' + Math.round(255 * this._blue) + ',' + this._alpha + ')';\n }\n});\n\nmodule.exports = color;\n","module.exports = function HSV(color) {\n color.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {\n rgb: function () {\n var hue = this._hue,\n saturation = this._saturation,\n value = this._value,\n i = Math.min(5, Math.floor(hue * 6)),\n f = hue * 6 - i,\n p = value * (1 - saturation),\n q = value * (1 - f * saturation),\n t = value * (1 - (1 - f) * saturation),\n red,\n green,\n blue;\n switch (i) {\n case 0:\n red = value;\n green = t;\n blue = p;\n break;\n case 1:\n red = q;\n green = value;\n blue = p;\n break;\n case 2:\n red = p;\n green = value;\n blue = t;\n break;\n case 3:\n red = p;\n green = q;\n blue = value;\n break;\n case 4:\n red = t;\n green = p;\n blue = value;\n break;\n case 5:\n red = value;\n green = p;\n blue = q;\n break;\n }\n return new color.RGB(red, green, blue, this._alpha);\n },\n\n hsl: function () {\n var l = (2 - this._saturation) * this._value,\n sv = this._saturation * this._value,\n svDivisor = l <= 1 ? l : (2 - l),\n saturation;\n\n // Avoid division by zero when lightness approaches zero:\n if (svDivisor < 1e-9) {\n saturation = 0;\n } else {\n saturation = sv / svDivisor;\n }\n return new color.HSL(this._hue, saturation, l / 2, this._alpha);\n },\n\n fromRgb: function () { // Becomes one.color.RGB.prototype.hsv\n var red = this._red,\n green = this._green,\n blue = this._blue,\n max = Math.max(red, green, blue),\n min = Math.min(red, green, blue),\n delta = max - min,\n hue,\n saturation = (max === 0) ? 0 : (delta / max),\n value = max;\n if (delta === 0) {\n hue = 0;\n } else {\n switch (max) {\n case red:\n hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);\n break;\n case green:\n hue = (blue - red) / delta / 6 + 1 / 3;\n break;\n case blue:\n hue = (red - green) / delta / 6 + 2 / 3;\n break;\n }\n }\n return new color.HSV(hue, saturation, value, this._alpha);\n }\n });\n};\n","module.exports = function LAB(color) {\n color.use(require('./XYZ.js'));\n\n color.installColorSpace('LAB', ['l', 'a', 'b', 'alpha'], {\n fromRgb: function () {\n return this.xyz().lab();\n },\n\n rgb: function () {\n return this.xyz().rgb();\n },\n\n xyz: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=08#text8\n var convert = function (channel) {\n var pow = Math.pow(channel, 3);\n return pow > 0.008856 ?\n pow :\n (channel - 16 / 116) / 7.87;\n },\n y = (this._l + 16) / 116,\n x = this._a / 500 + y,\n z = y - this._b / 200;\n\n return new color.XYZ(\n convert(x) * 95.047,\n convert(y) * 100.000,\n convert(z) * 108.883,\n this._alpha\n );\n }\n });\n};\n","module.exports = function XYZ(color) {\n color.installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], {\n fromRgb: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=02#text2\n var convert = function (channel) {\n return channel > 0.04045 ?\n Math.pow((channel + 0.055) / 1.055, 2.4) :\n channel / 12.92;\n },\n r = convert(this._red),\n g = convert(this._green),\n b = convert(this._blue);\n\n // Reference white point sRGB D65:\n // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n return new color.XYZ(\n r * 0.4124564 + g * 0.3575761 + b * 0.1804375,\n r * 0.2126729 + g * 0.7151522 + b * 0.0721750,\n r * 0.0193339 + g * 0.1191920 + b * 0.9503041,\n this._alpha\n );\n },\n\n rgb: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=01#text1\n var x = this._x,\n y = this._y,\n z = this._z,\n convert = function (channel) {\n return channel > 0.0031308 ?\n 1.055 * Math.pow(channel, 1 / 2.4) - 0.055 :\n 12.92 * channel;\n };\n\n // Reference white point sRGB D65:\n // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n return new color.RGB(\n convert(x * 3.2404542 + y * -1.5371385 + z * -0.4985314),\n convert(x * -0.9692660 + y * 1.8760108 + z * 0.0415560),\n convert(x * 0.0556434 + y * -0.2040259 + z * 1.0572252),\n this._alpha\n );\n },\n\n lab: function () {\n // http://www.easyrgb.com/index.php?X=MATH&H=07#text7\n var convert = function (channel) {\n return channel > 0.008856 ?\n Math.pow(channel, 1 / 3) :\n 7.787037 * channel + 4 / 29;\n },\n x = convert(this._x / 95.047),\n y = convert(this._y / 100.000),\n z = convert(this._z / 108.883);\n\n return new color.LAB(\n (116 * y) - 16,\n 500 * (x - y),\n 200 * (y - z),\n this._alpha\n );\n }\n });\n};\n","module.exports = function HSL(color) {\n color.use(require('./HSV'));\n\n color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {\n hsv: function () {\n // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts\n var l = this._lightness * 2,\n s = this._saturation * ((l <= 1) ? l : 2 - l),\n saturation;\n\n // Avoid division by zero when l + s is very small (approaching black):\n if (l + s < 1e-9) {\n saturation = 0;\n } else {\n saturation = (2 * s) / (l + s);\n }\n\n return new color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);\n },\n\n rgb: function () {\n return this.hsv().rgb();\n },\n\n fromRgb: function () { // Becomes one.color.RGB.prototype.hsv\n return this.hsv().hsl();\n }\n });\n};\n","module.exports = function CMYK(color) {\n color.installColorSpace('CMYK', ['cyan', 'magenta', 'yellow', 'black', 'alpha'], {\n rgb: function () {\n return new color.RGB((1 - this._cyan * (1 - this._black) - this._black),\n (1 - this._magenta * (1 - this._black) - this._black),\n (1 - this._yellow * (1 - this._black) - this._black),\n this._alpha);\n },\n\n fromRgb: function () { // Becomes one.color.RGB.prototype.cmyk\n // Adapted from http://www.javascripter.net/faq/rgb2cmyk.htm\n var red = this._red,\n green = this._green,\n blue = this._blue,\n cyan = 1 - red,\n magenta = 1 - green,\n yellow = 1 - blue,\n black = 1;\n if (red || green || blue) {\n black = Math.min(cyan, Math.min(magenta, yellow));\n cyan = (cyan - black) / (1 - black);\n magenta = (magenta - black) / (1 - black);\n yellow = (yellow - black) / (1 - black);\n } else {\n black = 1;\n }\n return new color.CMYK(cyan, magenta, yellow, black, this._alpha);\n }\n });\n};\n","module.exports = function namedColors(color) {\n color.namedColors = {\n aliceblue: 'f0f8ff',\n antiquewhite: 'faebd7',\n aqua: '0ff',\n aquamarine: '7fffd4',\n azure: 'f0ffff',\n beige: 'f5f5dc',\n bisque: 'ffe4c4',\n black: '000',\n blanchedalmond: 'ffebcd',\n blue: '00f',\n blueviolet: '8a2be2',\n brown: 'a52a2a',\n burlywood: 'deb887',\n cadetblue: '5f9ea0',\n chartreuse: '7fff00',\n chocolate: 'd2691e',\n coral: 'ff7f50',\n cornflowerblue: '6495ed',\n cornsilk: 'fff8dc',\n crimson: 'dc143c',\n cyan: '0ff',\n darkblue: '00008b',\n darkcyan: '008b8b',\n darkgoldenrod: 'b8860b',\n darkgray: 'a9a9a9',\n darkgrey: 'a9a9a9',\n darkgreen: '006400',\n darkkhaki: 'bdb76b',\n darkmagenta: '8b008b',\n darkolivegreen: '556b2f',\n darkorange: 'ff8c00',\n darkorchid: '9932cc',\n darkred: '8b0000',\n darksalmon: 'e9967a',\n darkseagreen: '8fbc8f',\n darkslateblue: '483d8b',\n darkslategray: '2f4f4f',\n darkslategrey: '2f4f4f',\n darkturquoise: '00ced1',\n darkviolet: '9400d3',\n deeppink: 'ff1493',\n deepskyblue: '00bfff',\n dimgray: '696969',\n dimgrey: '696969',\n dodgerblue: '1e90ff',\n firebrick: 'b22222',\n floralwhite: 'fffaf0',\n forestgreen: '228b22',\n fuchsia: 'f0f',\n gainsboro: 'dcdcdc',\n ghostwhite: 'f8f8ff',\n gold: 'ffd700',\n goldenrod: 'daa520',\n gray: '808080',\n grey: '808080',\n green: '008000',\n greenyellow: 'adff2f',\n honeydew: 'f0fff0',\n hotpink: 'ff69b4',\n indianred: 'cd5c5c',\n indigo: '4b0082',\n ivory: 'fffff0',\n khaki: 'f0e68c',\n lavender: 'e6e6fa',\n lavenderblush: 'fff0f5',\n lawngreen: '7cfc00',\n lemonchiffon: 'fffacd',\n lightblue: 'add8e6',\n lightcoral: 'f08080',\n lightcyan: 'e0ffff',\n lightgoldenrodyellow: 'fafad2',\n lightgray: 'd3d3d3',\n lightgrey: 'd3d3d3',\n lightgreen: '90ee90',\n lightpink: 'ffb6c1',\n lightsalmon: 'ffa07a',\n lightseagreen: '20b2aa',\n lightskyblue: '87cefa',\n lightslategray: '789',\n lightslategrey: '789',\n lightsteelblue: 'b0c4de',\n lightyellow: 'ffffe0',\n lime: '0f0',\n limegreen: '32cd32',\n linen: 'faf0e6',\n magenta: 'f0f',\n maroon: '800000',\n mediumaquamarine: '66cdaa',\n mediumblue: '0000cd',\n mediumorchid: 'ba55d3',\n mediumpurple: '9370d8',\n mediumseagreen: '3cb371',\n mediumslateblue: '7b68ee',\n mediumspringgreen: '00fa9a',\n mediumturquoise: '48d1cc',\n mediumvioletred: 'c71585',\n midnightblue: '191970',\n mintcream: 'f5fffa',\n mistyrose: 'ffe4e1',\n moccasin: 'ffe4b5',\n navajowhite: 'ffdead',\n navy: '000080',\n oldlace: 'fdf5e6',\n olive: '808000',\n olivedrab: '6b8e23',\n orange: 'ffa500',\n orangered: 'ff4500',\n orchid: 'da70d6',\n palegoldenrod: 'eee8aa',\n palegreen: '98fb98',\n paleturquoise: 'afeeee',\n palevioletred: 'd87093',\n papayawhip: 'ffefd5',\n peachpuff: 'ffdab9',\n peru: 'cd853f',\n pink: 'ffc0cb',\n plum: 'dda0dd',\n powderblue: 'b0e0e6',\n purple: '800080',\n rebeccapurple: '639',\n red: 'f00',\n rosybrown: 'bc8f8f',\n royalblue: '4169e1',\n saddlebrown: '8b4513',\n salmon: 'fa8072',\n sandybrown: 'f4a460',\n seagreen: '2e8b57',\n seashell: 'fff5ee',\n sienna: 'a0522d',\n silver: 'c0c0c0',\n skyblue: '87ceeb',\n slateblue: '6a5acd',\n slategray: '708090',\n slategrey: '708090',\n snow: 'fffafa',\n springgreen: '00ff7f',\n steelblue: '4682b4',\n tan: 'd2b48c',\n teal: '008080',\n thistle: 'd8bfd8',\n tomato: 'ff6347',\n turquoise: '40e0d0',\n violet: 'ee82ee',\n wheat: 'f5deb3',\n white: 'fff',\n whitesmoke: 'f5f5f5',\n yellow: 'ff0',\n yellowgreen: '9acd32'\n };\n};\n"]} \ No newline at end of file diff --git a/one-color.js b/one-color.js index f09f433..431b244 100644 --- a/one-color.js +++ b/one-color.js @@ -1,13 +1,2 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.one || (g.one = {})).color = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=n?n:2-n);return s=1e-9>n+h?0:2*h/(n+h),new t.HSV(this._hue,s,(n+h)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}})}; -},{"2":2}],2:[function(require,module,exports){ -module.exports=function(a){a.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var e,t,s,h=this._hue,i=this._saturation,r=this._value,n=Math.min(5,Math.floor(6*h)),u=6*h-n,c=r*(1-i),l=r*(1-u*i),o=r*(1-(1-u)*i);switch(n){case 0:e=r,t=o,s=c;break;case 1:e=l,t=r,s=c;break;case 2:e=c,t=r,s=o;break;case 3:e=c,t=l,s=r;break;case 4:e=o,t=c,s=r;break;case 5:e=r,t=c,s=l}return new a.RGB(e,t,s,this._alpha)},hsl:function(){var e,t=(2-this._saturation)*this._value,s=this._saturation*this._value,h=1>=t?t:2-t;return e=1e-9>h?0:s/h,new a.HSL(this._hue,e,t/2,this._alpha)},fromRgb:function(){var e,t=this._red,s=this._green,h=this._blue,i=Math.max(t,s,h),r=Math.min(t,s,h),n=i-r,u=0===i?0:n/i,c=i;if(0===n)e=0;else switch(i){case t:e=(s-h)/n/6+(h>s?1:0);break;case s:e=(h-t)/n/6+1/3;break;case h:e=(t-s)/n/6+2/3}return new a.HSV(e,u,c,this._alpha)}})}; -},{}],3:[function(require,module,exports){ -function color(r){if(Array.isArray(r)){if("string"==typeof r[0]&&"function"==typeof color[r[0]])return new color[r[0]](r.slice(1,r.length));if(4===r.length)return new color.RGB(r[0]/255,r[1]/255,r[2]/255,r[3]/255)}else if("string"==typeof r){var o=r.toLowerCase();color.namedColors[o]&&(r="#"+color.namedColors[o]),"transparent"===o&&(r="rgba(0,0,0,0)");var e=r.match(cssColorRegExp);if(e){var t=e[1].toUpperCase(),n=undef(e[8])?e[8]:parseFloat(e[8]),a="H"===t[0],s=e[3]?100:a?360:255,i=e[5]||a?100:255,c=e[7]||a?100:255;if(undef(color[t]))throw new Error("color."+t+" is not installed.");return new color[t](parseFloat(e[2])/s,parseFloat(e[4])/i,parseFloat(e[6])/c,n)}r.length<6&&(r=r.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var l=r.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(l)return new color.RGB(parseInt(l[1],16)/255,parseInt(l[2],16)/255,parseInt(l[3],16)/255);if(color.CMYK){var u=r.match(new RegExp("^cmyk\\("+percentageChannelRegExp.source+","+percentageChannelRegExp.source+","+percentageChannelRegExp.source+","+percentageChannelRegExp.source+"\\)$","i"));if(u)return new color.CMYK(parseFloat(u[1])/100,parseFloat(u[2])/100,parseFloat(u[3])/100,parseFloat(u[4])/100)}}else if("object"==typeof r&&r.isColor)return r;return!1}var installedColorSpaces=[],undef=function(r){return"undefined"==typeof r},channelRegExp=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,percentageChannelRegExp=/\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/,alphaChannelRegExp=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,cssColorRegExp=new RegExp("^(rgb|hsl|hsv)a?\\("+channelRegExp.source+","+channelRegExp.source+","+channelRegExp.source+"(?:,"+alphaChannelRegExp.source+")?\\)$","i");color.namedColors={},color.installColorSpace=function(r,o,e){function t(r,o){var e={};e[o.toLowerCase()]=function(){return this.rgb()[o.toLowerCase()]()},color[o].propertyNames.forEach(function(r){var t="black"===r?"k":r.charAt(0);e[r]=e[t]=function(e,t){return this[o.toLowerCase()]()[r](e,t)}});for(var t in e)e.hasOwnProperty(t)&&void 0===color[r].prototype[t]&&(color[r].prototype[t]=e[t])}color[r]=function(e){var t=Array.isArray(e)?e:arguments;o.forEach(function(e,n){var a=t[n];if("alpha"===e)this._alpha=isNaN(a)||a>1?1:0>a?0:a;else{if(isNaN(a))throw new Error("["+r+"]: Invalid color: ("+o.join(",")+")");"hue"===e?this._hue=0>a?a-Math.floor(a):a%1:this["_"+e]=0>a?0:a>1?1:a}},this)},color[r].propertyNames=o;var n=color[r].prototype;["valueOf","hex","hexa","css","cssa"].forEach(function(o){n[o]=n[o]||("RGB"===r?n.hex:function(){return this.rgb()[o]()})}),n.isColor=!0,n.equals=function(e,t){undef(t)&&(t=1e-10),e=e[r.toLowerCase()]();for(var n=0;nt)return!1;return!0},n.toJSON=function(){return[r].concat(o.map(function(r){return this["_"+r]},this))};for(var a in e)if(e.hasOwnProperty(a)){var s=a.match(/^from(.*)$/);s?color[s[1].toUpperCase()].prototype[r.toLowerCase()]=e[a]:n[a]=e[a]}return n[r.toLowerCase()]=function(){return this},n.toString=function(){return"["+r+" "+o.map(function(r){return this["_"+r]}).join(", ")+"]"},o.forEach(function(r){var e="black"===r?"k":r.charAt(0);n[r]=n[e]=function(e,t){return"undefined"==typeof e?this["_"+r]:t?new this.constructor(o.map(function(o){return this["_"+o]+(r===o?e:0)},this)):new this.constructor(o.map(function(o){return r===o?e:this["_"+o]},this))}}),installedColorSpaces.forEach(function(o){t(r,o),t(o,r)}),installedColorSpaces.push(r),color},color.pluginList=[],color.use=function(r){return-1===color.pluginList.indexOf(r)&&(this.pluginList.push(r),r(color)),color},color.installMethod=function(r,o){return installedColorSpaces.forEach(function(e){color[e].prototype[r]=o}),this},color.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var r=(65536*Math.round(255*this._red)+256*Math.round(255*this._green)+Math.round(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-r.length)+r},hexa:function(){var r=Math.round(255*this._alpha).toString(16);return"#"+"00".substr(0,2-r.length)+r+this.hex().substr(1,6)},css:function(){return"rgb("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+")"},cssa:function(){return"rgba("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+","+this._alpha+")"}}),module.exports=color; -},{}],4:[function(require,module,exports){ -module.exports=require(3).use(require(2)).use(require(1)); -},{"1":1,"2":2,"3":3}]},{},[4])(4) -}); - - -//# sourceMappingURL=one-color.map \ No newline at end of file +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):((t=t||self).one=t.one||{},t.one.color=r())}(this,(function(){"use strict";var t=[],r=function(t){return void 0===t},e=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,n=/\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/,a=new RegExp("^(rgb|hsl|hsv)a?\\("+e.source+","+e.source+","+e.source+"(?:,"+/\s*(\.\d+|\d+(?:\.\d+)?)\s*/.source+")?\\)$","i");function o(t){if(Array.isArray(t)){if("string"==typeof t[0]&&"function"==typeof o[t[0]])return new o[t[0]](t.slice(1,t.length));if(4===t.length)return new o.RGB(t[0]/255,t[1]/255,t[2]/255,t[3]/255)}else if("string"==typeof t){var e=t.toLowerCase();o.namedColors[e]&&(t="#"+o.namedColors[e]),"transparent"===e&&(t="rgba(0,0,0,0)");var s=t.match(a);if(s){var i=s[1].toUpperCase(),u=r(s[8])?s[8]:parseFloat(s[8]),h="H"===i[0],c=s[3]?100:h?360:255,f=s[5]||h?100:255,l=s[7]||h?100:255;if(r(o[i]))throw new Error("color."+i+" is not installed.");return new o[i](parseFloat(s[2])/c,parseFloat(s[4])/f,parseFloat(s[6])/l,u)}t.length<6&&(t=t.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var p=t.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(p)return new o.RGB(parseInt(p[1],16)/255,parseInt(p[2],16)/255,parseInt(p[3],16)/255);if(o.CMYK){var d=t.match(new RegExp("^cmyk\\("+n.source+","+n.source+","+n.source+","+n.source+"\\)$","i"));if(d)return new o.CMYK(parseFloat(d[1])/100,parseFloat(d[2])/100,parseFloat(d[3])/100,parseFloat(d[4])/100)}}else if("object"==typeof t&&t.isColor)return t;return!1}o.namedColors={},o.installColorSpace=function(e,n,a){o[e]=function(t){var r=Array.isArray(t)?t:arguments;n.forEach((function(t,a){var o=r[a];if("alpha"===t)this._alpha=isNaN(o)||o>1?1:o<0?0:o;else{if(isNaN(o))throw new Error("["+e+"]: Invalid color: ("+n.join(",")+")");"hue"===t?this._hue=o<0?o-Math.floor(o):o%1:this["_"+t]=o<0?0:o>1?1:o}}),this)},o[e].propertyNames=n;var s=o[e].prototype;for(var i in["valueOf","hex","hexa","css","cssa"].forEach((function(t){s[t]=s[t]||("RGB"===e?s.hex:function(){return this.rgb()[t]()})})),s.isColor=!0,s.equals=function(t,a){r(a)&&(a=1e-10),t=t[e.toLowerCase()]();for(var o=0;oa)return!1;return!0},s.toJSON=function(){return[e].concat(n.map((function(t){return this["_"+t]}),this))},a)if(Object.prototype.hasOwnProperty.call(a,i)){var u=i.match(/^from(.*)$/);u?o[u[1].toUpperCase()].prototype[e.toLowerCase()]=a[i]:s[i]=a[i]}function h(t,r){var e={};for(var n in e[r.toLowerCase()]=function(){return this.rgb()[r.toLowerCase()]()},o[r].propertyNames.forEach((function(t){var n="black"===t?"k":t.charAt(0);e[t]=e[n]=function(e,n){return this[r.toLowerCase()]()[t](e,n)}})),e)Object.prototype.hasOwnProperty.call(e,n)&&void 0===o[t].prototype[n]&&(o[t].prototype[n]=e[n])}return s[e.toLowerCase()]=function(){return this},s.toString=function(){return"["+e+" "+n.map((function(t){return this["_"+t]}),this).join(", ")+"]"},n.forEach((function(t){var r="black"===t?"k":t.charAt(0);s[t]=s[r]=function(r,e){return void 0===r?this["_"+t]:e?new this.constructor(n.map((function(e){return this["_"+e]+(t===e?r:0)}),this)):new this.constructor(n.map((function(e){return t===e?r:this["_"+e]}),this))}})),t.forEach((function(t){h(e,t),h(t,e)})),t.push(e),o},o.pluginList=[],o.use=function(t){return-1===o.pluginList.indexOf(t)&&(this.pluginList.push(t),t(o)),o},o.installMethod=function(r,e){return t.forEach((function(t){o[t].prototype[r]=e})),this},o.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var t=(65536*Math.round(255*this._red)+256*Math.round(255*this._green)+Math.round(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-t.length)+t},hexa:function(){var t=Math.round(255*this._alpha).toString(16);return"#"+"00".substr(0,2-t.length)+t+this.hex().substr(1,6)},css:function(){return"rgb("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+")"},cssa:function(){return"rgba("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+","+this._alpha+")"}});var s=function(t){t.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var r,e,n,a=this._hue,o=this._saturation,s=this._value,i=Math.min(5,Math.floor(6*a)),u=6*a-i,h=s*(1-o),c=s*(1-u*o),f=s*(1-(1-u)*o);switch(i){case 0:r=s,e=f,n=h;break;case 1:r=c,e=s,n=h;break;case 2:r=h,e=s,n=f;break;case 3:r=h,e=c,n=s;break;case 4:r=f,e=h,n=s;break;case 5:r=s,e=h,n=c}return new t.RGB(r,e,n,this._alpha)},hsl:function(){var r,e=(2-this._saturation)*this._value,n=this._saturation*this._value,a=e<=1?e:2-e;return r=a<1e-9?0:n/a,new t.HSL(this._hue,r,e/2,this._alpha)},fromRgb:function(){var r,e=this._red,n=this._green,a=this._blue,o=Math.max(e,n,a),s=o-Math.min(e,n,a),i=0===o?0:s/o,u=o;if(0===s)r=0;else switch(o){case e:r=(n-a)/s/6+(n 1\n ? 1\n : propertyValue < 0\n ? 0\n : propertyValue;\n } else {\n if (isNaN(propertyValue)) {\n throw new Error(\n '[' +\n colorSpaceName +\n ']: Invalid color: (' +\n propertyNames.join(',') +\n ')'\n );\n }\n if (propertyName === 'hue') {\n this._hue =\n propertyValue < 0\n ? propertyValue - Math.floor(propertyValue)\n : propertyValue % 1;\n } else {\n this['_' + propertyName] =\n propertyValue < 0 ? 0 : propertyValue > 1 ? 1 : propertyValue;\n }\n }\n }, this);\n };\n color[colorSpaceName].propertyNames = propertyNames;\n\n var prototype = color[colorSpaceName].prototype;\n\n ['valueOf', 'hex', 'hexa', 'css', 'cssa'].forEach(function (methodName) {\n prototype[methodName] =\n prototype[methodName] ||\n (colorSpaceName === 'RGB'\n ? prototype.hex\n : function () {\n return this.rgb()[methodName]();\n });\n });\n\n prototype.isColor = true;\n\n prototype.equals = function (otherColor, epsilon) {\n if (undef(epsilon)) {\n epsilon = 1e-10;\n }\n\n otherColor = otherColor[colorSpaceName.toLowerCase()]();\n\n for (var i = 0; i < propertyNames.length; i = i + 1) {\n if (\n Math.abs(\n this['_' + propertyNames[i]] - otherColor['_' + propertyNames[i]]\n ) > epsilon\n ) {\n return false;\n }\n }\n\n return true;\n };\n\n prototype.toJSON = function () {\n return [colorSpaceName].concat(\n propertyNames.map(function (propertyName) {\n return this['_' + propertyName];\n }, this)\n );\n };\n\n for (var propertyName in config) {\n if (Object.prototype.hasOwnProperty.call(config, propertyName)) {\n var matchFromColorSpace = propertyName.match(/^from(.*)$/);\n if (matchFromColorSpace) {\n color[matchFromColorSpace[1].toUpperCase()].prototype[\n colorSpaceName.toLowerCase()\n ] = config[propertyName];\n } else {\n prototype[propertyName] = config[propertyName];\n }\n }\n }\n\n // It is pretty easy to implement the conversion to the same color space:\n prototype[colorSpaceName.toLowerCase()] = function () {\n return this;\n };\n prototype.toString = function () {\n return (\n '[' +\n colorSpaceName +\n ' ' +\n propertyNames\n .map(function (propertyName) {\n return this['_' + propertyName];\n }, this)\n .join(', ') +\n ']'\n );\n };\n\n // Generate getters and setters\n propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n prototype[propertyName] = prototype[shortName] = function (value, isDelta) {\n // Simple getter mode: color.red()\n if (typeof value === 'undefined') {\n return this['_' + propertyName];\n } else if (isDelta) {\n // Adjuster: color.red(+.2, true)\n return new this.constructor(\n propertyNames.map(function (otherPropertyName) {\n return (\n this['_' + otherPropertyName] +\n (propertyName === otherPropertyName ? value : 0)\n );\n }, this)\n );\n } else {\n // Setter: color.red(.2);\n return new this.constructor(\n propertyNames.map(function (otherPropertyName) {\n return propertyName === otherPropertyName\n ? value\n : this['_' + otherPropertyName];\n }, this)\n );\n }\n };\n });\n\n function installForeignMethods(targetColorSpaceName, sourceColorSpaceName) {\n var obj = {};\n obj[sourceColorSpaceName.toLowerCase()] = function () {\n return this.rgb()[sourceColorSpaceName.toLowerCase()]();\n };\n color[sourceColorSpaceName].propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n obj[propertyName] = obj[shortName] = function (value, isDelta) {\n return this[sourceColorSpaceName.toLowerCase()]()[propertyName](\n value,\n isDelta\n );\n };\n });\n for (var prop in obj) {\n if (\n Object.prototype.hasOwnProperty.call(obj, prop) &&\n color[targetColorSpaceName].prototype[prop] === undefined\n ) {\n color[targetColorSpaceName].prototype[prop] = obj[prop];\n }\n }\n }\n\n installedColorSpaces.forEach(function (otherColorSpaceName) {\n installForeignMethods(colorSpaceName, otherColorSpaceName);\n installForeignMethods(otherColorSpaceName, colorSpaceName);\n });\n\n installedColorSpaces.push(colorSpaceName);\n return color;\n};\n\ncolor.pluginList = [];\n\ncolor.use = function (plugin) {\n if (color.pluginList.indexOf(plugin) === -1) {\n this.pluginList.push(plugin);\n plugin(color);\n }\n return color;\n};\n\ncolor.installMethod = function (name, fn) {\n installedColorSpaces.forEach(function (colorSpace) {\n color[colorSpace].prototype[name] = fn;\n });\n return this;\n};\n\ncolor.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], {\n hex: function () {\n var hexString = (\n Math.round(255 * this._red) * 0x10000 +\n Math.round(255 * this._green) * 0x100 +\n Math.round(255 * this._blue)\n ).toString(16);\n return '#' + '00000'.substr(0, 6 - hexString.length) + hexString;\n },\n\n hexa: function () {\n var alphaString = Math.round(this._alpha * 255).toString(16);\n return (\n '#' +\n '00'.substr(0, 2 - alphaString.length) +\n alphaString +\n this.hex().substr(1, 6)\n );\n },\n\n css: function () {\n return (\n 'rgb(' +\n Math.round(255 * this._red) +\n ',' +\n Math.round(255 * this._green) +\n ',' +\n Math.round(255 * this._blue) +\n ')'\n );\n },\n\n cssa: function () {\n return (\n 'rgba(' +\n Math.round(255 * this._red) +\n ',' +\n Math.round(255 * this._green) +\n ',' +\n Math.round(255 * this._blue) +\n ',' +\n this._alpha +\n ')'\n );\n },\n});\n\nmodule.exports = color;\n","module.exports = function HSV(color) {\n color.installColorSpace('HSV', ['hue', 'saturation', 'value', 'alpha'], {\n rgb: function () {\n var hue = this._hue;\n var saturation = this._saturation;\n var value = this._value;\n var i = Math.min(5, Math.floor(hue * 6));\n var f = hue * 6 - i;\n var p = value * (1 - saturation);\n var q = value * (1 - f * saturation);\n var t = value * (1 - (1 - f) * saturation);\n var red;\n var green;\n var blue;\n switch (i) {\n case 0:\n red = value;\n green = t;\n blue = p;\n break;\n case 1:\n red = q;\n green = value;\n blue = p;\n break;\n case 2:\n red = p;\n green = value;\n blue = t;\n break;\n case 3:\n red = p;\n green = q;\n blue = value;\n break;\n case 4:\n red = t;\n green = p;\n blue = value;\n break;\n case 5:\n red = value;\n green = p;\n blue = q;\n break;\n }\n return new color.RGB(red, green, blue, this._alpha);\n },\n\n hsl: function () {\n var l = (2 - this._saturation) * this._value;\n var sv = this._saturation * this._value;\n var svDivisor = l <= 1 ? l : 2 - l;\n var saturation;\n\n // Avoid division by zero when lightness approaches zero:\n if (svDivisor < 1e-9) {\n saturation = 0;\n } else {\n saturation = sv / svDivisor;\n }\n return new color.HSL(this._hue, saturation, l / 2, this._alpha);\n },\n\n fromRgb: function () {\n // Becomes one.color.RGB.prototype.hsv\n var red = this._red;\n var green = this._green;\n var blue = this._blue;\n var max = Math.max(red, green, blue);\n var min = Math.min(red, green, blue);\n var delta = max - min;\n var hue;\n var saturation = max === 0 ? 0 : delta / max;\n var value = max;\n if (delta === 0) {\n hue = 0;\n } else {\n switch (max) {\n case red:\n hue = (green - blue) / delta / 6 + (green < blue ? 1 : 0);\n break;\n case green:\n hue = (blue - red) / delta / 6 + 1 / 3;\n break;\n case blue:\n hue = (red - green) / delta / 6 + 2 / 3;\n break;\n }\n }\n return new color.HSV(hue, saturation, value, this._alpha);\n },\n });\n};\n","module.exports = require('./lib/color')\n .use(require('./lib/HSV'))\n .use(require('./lib/HSL'));\n","module.exports = function HSL(color) {\n color.use(require('./HSV'));\n\n color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {\n hsv: function () {\n // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts\n var l = this._lightness * 2;\n var s = this._saturation * (l <= 1 ? l : 2 - l);\n var saturation;\n\n // Avoid division by zero when l + s is very small (approaching black):\n if (l + s < 1e-9) {\n saturation = 0;\n } else {\n saturation = (2 * s) / (l + s);\n }\n\n return new color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);\n },\n\n rgb: function () {\n return this.hsv().rgb();\n },\n\n fromRgb: function () {\n // Becomes one.color.RGB.prototype.hsv\n return this.hsv().hsl();\n },\n });\n};\n"],"names":["installedColorSpaces","undef","obj","channelRegExp","percentageChannelRegExp","cssColorRegExp","RegExp","source","color","Array","isArray","slice","length","RGB","lowerCased","toLowerCase","namedColors","matchCssSyntax","match","colorSpaceName","toUpperCase","alpha","parseFloat","hasHue","firstChannelDivisor","secondChannelDivisor","thirdChannelDivisor","Error","replace","hexMatch","parseInt","CMYK","cmykMatch","isColor","installColorSpace","propertyNames","config","a1","args","arguments","forEach","propertyName","i","propertyValue","this","_alpha","isNaN","join","_hue","Math","floor","prototype","methodName","hex","rgb","equals","otherColor","epsilon","abs","toJSON","concat","map","Object","hasOwnProperty","call","matchFromColorSpace","installForeignMethods","targetColorSpaceName","sourceColorSpaceName","prop","shortName","charAt","value","isDelta","undefined","toString","constructor","otherPropertyName","otherColorSpaceName","push","pluginList","use","plugin","indexOf","installMethod","name","fn","colorSpace","hexString","round","_red","_green","_blue","substr","hexa","alphaString","css","cssa","red","green","blue","hue","saturation","_saturation","_value","min","f","p","q","t","hsl","l","sv","svDivisor","HSL","fromRgb","max","delta","HSV","require$$1","require$$0","hsv","_lightness","s"],"mappings":"kNAAA,IAAIA,EAAuB,GACvBC,EAAQ,SAAUC,GACp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nE,KAAK8E,WACTC,EAAI/E,KAAK2D,aAAeQ,GAAK,EAAIA,EAAI,EAAIA,GAU7C,OALET,EADES,EAAIY,EAAI,KACG,EAEC,EAAIA,GAAMZ,EAAIY,GAGvB,IAAInH,EAAM8G,IAAI1E,KAAKI,KAAMsD,GAAaS,EAAIY,GAAK,EAAG/E,KAAKC,SAGhES,IAAK,WACH,OAAOV,KAAK6E,MAAMnE,OAGpB6D,QAAS,WAEP,OAAOvE,KAAK6E,MAAMX"} \ No newline at end of file diff --git a/one-color.map b/one-color.map deleted file mode 100644 index 7caaa1d..0000000 --- a/one-color.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["node_modules/browserify/node_modules/browser-pack/_prelude.js","minimal","lib/HSV.js","lib/color.js","lib/HSL.js"],"names":["module","exports","color","installColorSpace","rgb","red","green","blue","hue","this","_hue","saturation","_saturation","value","_value","i","Math","min","floor","f","p","q","t","RGB","_alpha","hsl","l","sv","svDivisor","HSL","fromRgb","_red","_green","_blue","max","delta","HSV","obj","Array","isArray","slice","length","lowerCased","toLowerCase","namedColors","matchCssSyntax","match","cssColorRegExp","colorSpaceName","toUpperCase","alpha","undef","parseFloat","hasHue","firstChannelDivisor","secondChannelDivisor","thirdChannelDivisor","Error","replace","hexMatch","parseInt","CMYK","cmykMatch","RegExp","percentageChannelRegExp","source","isColor","installedColorSpaces","channelRegExp","alphaChannelRegExp","propertyNames","config","installForeignMethods","targetColorSpaceName","sourceColorSpaceName","forEach","propertyName","shortName","charAt","isDelta","prop","hasOwnProperty","undefined","prototype","a1","args","arguments","propertyValue","isNaN","join","methodName","hex","equals","otherColor","epsilon","abs","toJSON","concat","map","matchFromColorSpace","toString","constructor","otherPropertyName","otherColorSpaceName","push","pluginList","use","plugin","indexOf","installMethod","name","fn","colorSpace","hexString","round","substr","hexa","alphaString","css","cssa","require","hsv","_lightness","s"],"mappings":"AAAA;AIAAA,OAAOC,QAAU,SAAaC,GAC1BA,EAAMwG,IAAIc,QAAQ,U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G,KAAKsB,MAAQ,IAAMf,KAAKkG,MAAM,IAAMzG,KAAKuB,QAAU,IAAMhB,KAAKkG,MAAM,IAAMzG,KAAKwB,OAAS,KAG7HsF,KAAM,WACF,MAAO,QAAUvG,KAAKkG,MAAM,IAAMzG,KAAKsB,MAAQ,IAAMf,KAAKkG,MAAM,IAAMzG,KAAKuB,QAAU,IAAMhB,KAAKkG,MAAM,IAAMzG,KAAKwB,OAAS,IAAMxB,KAAKe,OAAS,OAItJxB,OAAOC,QAAUC;;AF7PjB","file":"bundle.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o 1) ? 1 : (propertyValue < 0 ? 0 : propertyValue);\n } else {\n if (isNaN(propertyValue)) {\n throw new Error('[' + colorSpaceName + ']: Invalid color: (' + propertyNames.join(',') + ')');\n }\n if (propertyName === 'hue') {\n this._hue = propertyValue < 0 ? propertyValue - Math.floor(propertyValue) : propertyValue % 1;\n } else {\n this['_' + propertyName] = propertyValue < 0 ? 0 : (propertyValue > 1 ? 1 : propertyValue);\n }\n }\n }, this);\n };\n color[colorSpaceName].propertyNames = propertyNames;\n\n var prototype = color[colorSpaceName].prototype;\n\n ['valueOf', 'hex', 'hexa', 'css', 'cssa'].forEach(function (methodName) {\n prototype[methodName] = prototype[methodName] || (colorSpaceName === 'RGB' ? prototype.hex : function () {\n return this.rgb()[methodName]();\n });\n });\n\n prototype.isColor = true;\n\n prototype.equals = function (otherColor, epsilon) {\n if (undef(epsilon)) {\n epsilon = 1e-10;\n }\n\n otherColor = otherColor[colorSpaceName.toLowerCase()]();\n\n for (var i = 0; i < propertyNames.length; i = i + 1) {\n if (Math.abs(this['_' + propertyNames[i]] - otherColor['_' + propertyNames[i]]) > epsilon) {\n return false;\n }\n }\n\n return true;\n };\n\n prototype.toJSON = function () {\n return [colorSpaceName].concat(propertyNames.map(function (propertyName) {\n return this['_' + propertyName];\n }, this));\n };\n\n for (var propertyName in config) {\n if (config.hasOwnProperty(propertyName)) {\n var matchFromColorSpace = propertyName.match(/^from(.*)$/);\n if (matchFromColorSpace) {\n color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];\n } else {\n prototype[propertyName] = config[propertyName];\n }\n }\n }\n\n // It is pretty easy to implement the conversion to the same color space:\n prototype[colorSpaceName.toLowerCase()] = function () {\n return this;\n };\n prototype.toString = function () {\n return '[' + colorSpaceName + ' ' + propertyNames.map(function (propertyName) {\n return this['_' + propertyName];\n }).join(', ') + ']';\n };\n\n // Generate getters and setters\n propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n prototype[propertyName] = prototype[shortName] = function (value, isDelta) {\n // Simple getter mode: color.red()\n if (typeof value === 'undefined') {\n return this['_' + propertyName];\n } else if (isDelta) {\n // Adjuster: color.red(+.2, true)\n return new this.constructor(propertyNames.map(function (otherPropertyName) {\n return this['_' + otherPropertyName] + (propertyName === otherPropertyName ? value : 0);\n }, this));\n } else {\n // Setter: color.red(.2);\n return new this.constructor(propertyNames.map(function (otherPropertyName) {\n return (propertyName === otherPropertyName) ? value : this['_' + otherPropertyName];\n }, this));\n }\n };\n });\n\n function installForeignMethods(targetColorSpaceName, sourceColorSpaceName) {\n var obj = {};\n obj[sourceColorSpaceName.toLowerCase()] = function () {\n return this.rgb()[sourceColorSpaceName.toLowerCase()]();\n };\n color[sourceColorSpaceName].propertyNames.forEach(function (propertyName) {\n var shortName = propertyName === 'black' ? 'k' : propertyName.charAt(0);\n obj[propertyName] = obj[shortName] = function (value, isDelta) {\n return this[sourceColorSpaceName.toLowerCase()]()[propertyName](value, isDelta);\n };\n });\n for (var prop in obj) {\n if (obj.hasOwnProperty(prop) && color[targetColorSpaceName].prototype[prop] === undefined) {\n color[targetColorSpaceName].prototype[prop] = obj[prop];\n }\n }\n }\n\n installedColorSpaces.forEach(function (otherColorSpaceName) {\n installForeignMethods(colorSpaceName, otherColorSpaceName);\n installForeignMethods(otherColorSpaceName, colorSpaceName);\n });\n\n installedColorSpaces.push(colorSpaceName);\n return color;\n};\n\ncolor.pluginList = [];\n\ncolor.use = function (plugin) {\n if (color.pluginList.indexOf(plugin) === -1) {\n this.pluginList.push(plugin);\n plugin(color);\n }\n return color;\n};\n\ncolor.installMethod = function (name, fn) {\n installedColorSpaces.forEach(function (colorSpace) {\n color[colorSpace].prototype[name] = fn;\n });\n return this;\n};\n\ncolor.installColorSpace('RGB', ['red', 'green', 'blue', 'alpha'], {\n hex: function () {\n var hexString = (Math.round(255 * this._red) * 0x10000 + Math.round(255 * this._green) * 0x100 + Math.round(255 * this._blue)).toString(16);\n return '#' + ('00000'.substr(0, 6 - hexString.length)) + hexString;\n },\n\n hexa: function () {\n var alphaString = Math.round(this._alpha * 255).toString(16);\n return '#' + '00'.substr(0, 2 - alphaString.length) + alphaString + this.hex().substr(1, 6);\n },\n\n css: function () {\n return 'rgb(' + Math.round(255 * this._red) + ',' + Math.round(255 * this._green) + ',' + Math.round(255 * this._blue) + ')';\n },\n\n cssa: function () {\n return 'rgba(' + Math.round(255 * this._red) + ',' + Math.round(255 * this._green) + ',' + Math.round(255 * this._blue) + ',' + this._alpha + ')';\n }\n});\n\nmodule.exports = color;\n","module.exports = function HSL(color) {\n color.use(require('./HSV'));\n\n color.installColorSpace('HSL', ['hue', 'saturation', 'lightness', 'alpha'], {\n hsv: function () {\n // Algorithm adapted from http://wiki.secondlife.com/wiki/Color_conversion_scripts\n var l = this._lightness * 2,\n s = this._saturation * ((l <= 1) ? l : 2 - l),\n saturation;\n\n // Avoid division by zero when l + s is very small (approaching black):\n if (l + s < 1e-9) {\n saturation = 0;\n } else {\n saturation = (2 * s) / (l + s);\n }\n\n return new color.HSV(this._hue, saturation, (l + s) / 2, this._alpha);\n },\n\n rgb: function () {\n return this.hsv().rgb();\n },\n\n fromRgb: function () { // Becomes one.color.RGB.prototype.hsv\n return this.hsv().hsl();\n }\n });\n};\n"]} \ No newline at end of file diff --git a/package.json b/package.json index e2721e2..3e1f2a4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "onecolor", "description": "Javascript color object with implicit color space conversions. Supports RGB, HSV, HSL and CMYK with alpha channel.", "repository": "git@github.com:One-com/one-color.git", - "version": "3.0.4", + "version": "3.1.0", "license": "BSD-2-Clause", "keywords": [ "color", @@ -20,18 +20,28 @@ }, { "name": "Andreas Lind", - "email": "andreas@one.com" + "email": "andreaslindpetersen@gmail.com" } ], "devDependencies": { - "browserify": "13.0.0", - "bundle-collapser": "1.2.1", + "@rollup/plugin-commonjs": "^14.0.0", "coveralls": "2.11.9", + "eslint": "^7.4.0", + "eslint-config-prettier": "^6.11.0", + "eslint-config-standard": "^14.1.1", + "eslint-plugin-import": "^2.22.0", + "eslint-plugin-mocha": "^7.0.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.1", + "evaldown": "^1.2.2", "istanbul": "0.4.2", - "jshint": "^2.9.1", - "minifyify": "7.3.2", "mocha": "2.4.5", "mocha-lcov-reporter": "1.2.0", + "onecolor": "file:./", + "prettier": "^2.0.5", + "rollup": "^2.21.0", + "rollup-plugin-terser": "^6.1.0", "unexpected": "10.11.1" }, "engines": { @@ -46,16 +56,16 @@ "minimal.js", "lib" ], - "publishConfig": { - "registry": "http://registry.npmjs.org/" - }, "scripts": { - "build": "browserify -p bundle-collapser/plugin -p [ minifyify --map one-color-all.map --output one-color-all.map ] --debug -e index -s one.color > one-color-all.js && browserify -p bundle-collapser/plugin -p [ minifyify --map one-color.map --output one-color.map ] --debug -e minimal -s one.color > one-color.js", - "preversion": "npm run lint && npm run build && npm test && bash -c 'git add one-color{-all,}.{js,map}'", - "lint": "jshint .", + "one-color-all": "rollup -c rollup.config.js index.js -o one-color-all.js", + "one-color": "rollup -c rollup.config.js minimal.js -o one-color.js", + "build": "npm run one-color && npm run one-color-all", + "preversion": "npm run lint && npm run build && TEST_BUNDLES=true npm test && bash -c 'git add one-color{-all,}.{js,map}'", + "lint": "eslint . && prettier --check '**/*.{js,md}'", "test": "npm run lint && mocha", + "test:documentation": "evaldown --validate --capture=console ./README.md", "coverage": "istanbul cover _mocha -- --reporter dot", - "travis": "npm run lint && npm run build && npm run coverage" + "ci:test": "TEST_BUNDLES=true npm run coverage" }, "jspm": { "dependencies": {}, diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..6ba8fb6 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,14 @@ +module.exports = { + // entry: 'index.js', + + plugins: [ + require('@rollup/plugin-commonjs')(), + require('rollup-plugin-terser').terser(), + ], + + output: { + format: 'umd', + name: 'one.color', + sourcemap: true, + }, +}; diff --git a/test/color.js b/test/color.js index 17542eb..8b66cac 100644 --- a/test/color.js +++ b/test/color.js @@ -1,184 +1,269 @@ var expect = require('unexpected'); -var color = require('../'); +var libs = [ + { + name: 'index.js', + lib: require('../'), + }, +]; + +if (process.env.TEST_BUNDLES) { + libs.push({ + name: 'Bundle: one-color-all.js', + lib: require('../one-color-all'), + }); +} + var namedColorSamples = require('./samples'); var spaces = [ - { - name: 'RGB', - channels: ['red', 'green', 'blue', 'alpha'] - }, - { - name: 'HSV', - channels: ['hue', 'saturation', 'value', 'alpha'] - }, - { - name: 'HSL', - channels: ['hue', 'saturation', 'lightness', 'alpha'] - }, - { - name: 'CMYK', - channels: ['cyan', 'magenta', 'yellow', 'black', 'alpha'] - } - // { - // name: 'XYZ', - // channels: ['x', 'y', 'z', 'alpha'] - // }, - // { - // name: 'LAB', - // channels: ['l', 'a', 'b', 'alpha'] - // } + { + name: 'RGB', + channels: ['red', 'green', 'blue', 'alpha'], + }, + { + name: 'HSV', + channels: ['hue', 'saturation', 'value', 'alpha'], + }, + { + name: 'HSL', + channels: ['hue', 'saturation', 'lightness', 'alpha'], + }, + { + name: 'CMYK', + channels: ['cyan', 'magenta', 'yellow', 'black', 'alpha'], + }, + // { + // name: 'XYZ', + // channels: ['x', 'y', 'z', 'alpha'] + // }, + // { + // name: 'LAB', + // channels: ['l', 'a', 'b', 'alpha'] + // } ]; +function testLib(libConfig) { + var color = libConfig.lib; -describe('Named colors', function () { - Object.keys(namedColorSamples).forEach(function (namedColor) { + describe(libConfig.name, function () { + describe('Named colors', function () { + Object.keys(namedColorSamples).forEach(function (namedColor) { var hex = namedColorSamples[namedColor].toLowerCase(); it('should parse ' + namedColor + ' as ' + hex, function () { - return expect(color(namedColor).hex(), 'to be', hex); + return expect(color(namedColor).hex(), 'to be', hex); }); + }); }); -}); -spaces.forEach(function (colorSpace) { - describe(colorSpace.name, function () { + spaces.forEach(function (colorSpace) { + describe(colorSpace.name, function () { var spaceName = colorSpace.name; it('should have a constructor function', function () { - expect(color[spaceName], 'to be a function'); + expect(color[spaceName], 'to be a function'); }); - var clr = colorSpace.name === 'CMYK' ? new color[spaceName](1, 1, 1, 1, 1) : new color[spaceName](0, 0, 0, 1); + var clr = + colorSpace.name === 'CMYK' + ? new color[spaceName](1, 1, 1, 1, 1) + : new color[spaceName](0, 0, 0, 1); it('should be constructed correctly', function () { - expect(clr, 'to satisfy', { - isColor: true - }); + expect(clr, 'to satisfy', { + isColor: true, + }); }); describe('color space conversion', function () { - spaces.forEach(function (otherSpace) { - - it('should have a ' + otherSpace.name + ' conversion method', function () { - var expected = {}; - - expected[otherSpace.name.toLowerCase()] = expect.it('to be a function'); - - expect(clr, 'to satisfy', expected); - }); - - it('should convert to ' + otherSpace.name, function () { - var expected = { - isColor: true - }; - - otherSpace.channels.forEach(function (channelName) { - expected['_' + channelName] = expect.it('to be a number'); - }); - - expect(clr[otherSpace.name.toLowerCase()](), 'to satisfy', expected); - - // Awaiting unexpected patch - // expect(clr[otherSpace.name.toLowerCase()](), 'to exhaustively satisfy', expected); - }); + spaces.forEach(function (otherSpace) { + it( + 'should have a ' + otherSpace.name + ' conversion method', + function () { + var expected = {}; + + expected[otherSpace.name.toLowerCase()] = expect.it( + 'to be a function' + ); + + expect(clr, 'to satisfy', expected); + } + ); + + it('should convert to ' + otherSpace.name, function () { + var expected = { + isColor: true, + }; + + otherSpace.channels.forEach(function (channelName) { + expected['_' + channelName] = expect.it('to be a number'); + }); + + expect( + clr[otherSpace.name.toLowerCase()](), + 'to satisfy', + expected + ); + + // Awaiting unexpected patch + // expect(clr[otherSpace.name.toLowerCase()](), 'to exhaustively satisfy', expected); }); + }); }); describe('equality', function () { - it('should have an equals method', function () { - expect(clr, 'to satisfy', { - equals: expect.it('to be a function').and('to have arity', 2) - }); + it('should have an equals method', function () { + expect(clr, 'to satisfy', { + equals: expect.it('to be a function').and('to have arity', 2), }); - - spaces.forEach(function (otherSpace) { - it('should equal same color in ' + otherSpace.name, function () { - if (otherSpace.name === 'CMYK') { - expect(clr.equals(new color[otherSpace.name](1, 1, 1, 1, 1)), 'to be true'); - } else { - expect(clr.equals(new color[otherSpace.name](0, 0, 0, 1)), 'to be true'); - } - }); + }); + + spaces.forEach(function (otherSpace) { + it('should equal same color in ' + otherSpace.name, function () { + if (otherSpace.name === 'CMYK') { + expect( + clr.equals(new color[otherSpace.name](1, 1, 1, 1, 1)), + 'to be true' + ); + } else { + expect( + clr.equals(new color[otherSpace.name](0, 0, 0, 1)), + 'to be true' + ); + } }); + }); }); it('should convert to JSON', function () { - var clr = new color[colorSpace.name](Math.random(), Math.random(), Math.random(), Math.random(), Math.random()); - - expect(clr.equals(color(clr.toJSON())), 'to be true'); + var clr = new color[colorSpace.name]( + Math.random(), + Math.random(), + Math.random(), + Math.random(), + Math.random() + ); + + expect(clr.equals(color(clr.toJSON())), 'to be true'); }); describe('color channels', function () { - colorSpace.channels.forEach(function (channel) { - var shortHand = channel === 'black' ? 'k' : channel.charAt(0); - - describe(channel, function () { - it('should have a "' + channel + '" method', function () { - var expected = {}; - - expected[channel] = expect.it('to be a function').and('to have arity', 2); - - expect(clr, 'to satisfy', expected); - }); - - it('should have a "' + shortHand + '" shorthand method', function () { - var expected = {}; - - expected[shortHand] = expect.it('to be a function').and('to have arity', 2); - - expect(clr, 'to satisfy', expected); - }); - - it('should get the "' + channel + '" value', function () { - expect(new color[colorSpace.name](0, 0, 0, 0, 0)[channel](), 'to be', 0); - }); - - it('should get the "' + channel + '" shorthand "' + shortHand + '" value', function () { - expect(new color[colorSpace.name](0, 0, 0, 0, 0)[channel](), 'to be', 0); - }); - - it('should set the "' + channel + '" value', function () { - expect(clr[channel](0)[channel](), 'to be', 0); - expect(clr[channel](0.5)[channel](), 'to be', 0.5); - - if (channel === 'hue') { - // Hue is considered a circle, and thus has periodic boundary conditions - expect(clr[channel](1)[channel](), 'to be', 0); - expect(clr[channel](-0.1)[channel](), 'to be', 0.9); - expect(clr[channel](1.5)[channel](), 'to be', 0.5); - } else { - expect(clr[channel](1)[channel](), 'to be', 1); - expect(clr[channel](-0.1)[channel](), 'to be', 0); - expect(clr[channel](1.1)[channel](), 'to be', 1); - } - }); - - it('should set the "' + channel + '" shorthand "' + shortHand + '" value', function () { - expect(clr[shortHand](0)[channel](), 'to be', 0); - expect(clr[shortHand](0.5)[channel](), 'to be', 0.5); - - if (channel === 'hue') { - // Hue is considered a circle, and thus has periodic boundary conditions - expect(clr[shortHand](1)[channel](), 'to be', 0); - expect(clr[shortHand](-0.1)[channel](), 'to be', 0.9); - expect(clr[shortHand](1.5)[channel](), 'to be', 0.5); - } else { - expect(clr[shortHand](1)[channel](), 'to be', 1); - expect(clr[shortHand](-0.1)[channel](), 'to be', 0); - expect(clr[shortHand](1.1)[channel](), 'to be', 1); - } - }); - - it('should adjust the "' + channel + '" value', function () { - expect(clr[channel](0)[channel](0.5, true)[channel](), 'to be', 0.5); - }); - - it('should adjust the "' + channel + '", shorthand "' + shortHand + '" value', function () { - expect(clr[channel](0)[shortHand](0.5, true)[channel](), 'to be', 0.5); - }); - }); - + colorSpace.channels.forEach(function (channel) { + var shortHand = channel === 'black' ? 'k' : channel.charAt(0); + + describe(channel, function () { + it('should have a "' + channel + '" method', function () { + var expected = {}; + + expected[channel] = expect + .it('to be a function') + .and('to have arity', 2); + + expect(clr, 'to satisfy', expected); + }); + + it( + 'should have a "' + shortHand + '" shorthand method', + function () { + var expected = {}; + + expected[shortHand] = expect + .it('to be a function') + .and('to have arity', 2); + + expect(clr, 'to satisfy', expected); + } + ); + + it('should get the "' + channel + '" value', function () { + expect( + new color[colorSpace.name](0, 0, 0, 0, 0)[channel](), + 'to be', + 0 + ); + }); + + it( + 'should get the "' + + channel + + '" shorthand "' + + shortHand + + '" value', + function () { + expect( + new color[colorSpace.name](0, 0, 0, 0, 0)[channel](), + 'to be', + 0 + ); + } + ); + + it('should set the "' + channel + '" value', function () { + expect(clr[channel](0)[channel](), 'to be', 0); + expect(clr[channel](0.5)[channel](), 'to be', 0.5); + + if (channel === 'hue') { + // Hue is considered a circle, and thus has periodic boundary conditions + expect(clr[channel](1)[channel](), 'to be', 0); + expect(clr[channel](-0.1)[channel](), 'to be', 0.9); + expect(clr[channel](1.5)[channel](), 'to be', 0.5); + } else { + expect(clr[channel](1)[channel](), 'to be', 1); + expect(clr[channel](-0.1)[channel](), 'to be', 0); + expect(clr[channel](1.1)[channel](), 'to be', 1); + } + }); + + it( + 'should set the "' + + channel + + '" shorthand "' + + shortHand + + '" value', + function () { + expect(clr[shortHand](0)[channel](), 'to be', 0); + expect(clr[shortHand](0.5)[channel](), 'to be', 0.5); + + if (channel === 'hue') { + // Hue is considered a circle, and thus has periodic boundary conditions + expect(clr[shortHand](1)[channel](), 'to be', 0); + expect(clr[shortHand](-0.1)[channel](), 'to be', 0.9); + expect(clr[shortHand](1.5)[channel](), 'to be', 0.5); + } else { + expect(clr[shortHand](1)[channel](), 'to be', 1); + expect(clr[shortHand](-0.1)[channel](), 'to be', 0); + expect(clr[shortHand](1.1)[channel](), 'to be', 1); + } + } + ); + + it('should adjust the "' + channel + '" value', function () { + expect( + clr[channel](0)[channel](0.5, true)[channel](), + 'to be', + 0.5 + ); + }); + + it( + 'should adjust the "' + + channel + + '", shorthand "' + + shortHand + + '" value', + function () { + expect( + clr[channel](0)[shortHand](0.5, true)[channel](), + 'to be', + 0.5 + ); + } + ); }); + }); }); - + }); }); -}); + }); +} + +libs.forEach(testLib); diff --git a/test/contrast.js b/test/contrast.js new file mode 100644 index 0000000..7c2525d --- /dev/null +++ b/test/contrast.js @@ -0,0 +1,18 @@ +var color = require('../'); + +var expect = require('unexpected').clone(); + +function contrast(color1, color2) { + var contrast = color(color1).contrast(color(color2)); + return Math.round(contrast * 100) / 100; +} + +describe('contrast', function () { + it('should return the contrast for colors', function () { + expect(contrast('white', 'black'), 'to equal', 21); + expect(contrast('white', 'red'), 'to equal', 4); + expect(contrast('red', 'white'), 'to equal', 4); + expect(contrast('005aff', 'eeeeee'), 'to equal', 4.63); + expect(contrast('blue', 'blue'), 'to equal', 1); + }); +}); diff --git a/test/conversion.js b/test/conversion.js index 699bf76..3e9cb22 100644 --- a/test/conversion.js +++ b/test/conversion.js @@ -1,22 +1,17 @@ var expect = require('unexpected'); var namedColorSamples = require('./samples'); var color = require('../'); -var spaces = [ - 'rgb', - 'hsl', - 'hsv', - 'cmyk' -]; +var spaces = ['rgb', 'hsl', 'hsv', 'cmyk']; describe('conversion', function () { - Object.keys(namedColorSamples).forEach(function (namedColor) { - describe('with named color sample ' + namedColor, function () { - var instance = color(namedColorSamples[namedColor]); - spaces.forEach(function (space) { - it('should convert to ' + space, function () { - expect(instance[space]().hex(), 'to equal', instance.hex()); - }); - }); + Object.keys(namedColorSamples).forEach(function (namedColor) { + describe('with named color sample ' + namedColor, function () { + var instance = color(namedColorSamples[namedColor]); + spaces.forEach(function (space) { + it('should convert to ' + space, function () { + expect(instance[space]().hex(), 'to equal', instance.hex()); }); + }); }); + }); }); diff --git a/test/grayscale.js b/test/grayscale.js index 53b8807..865a3d3 100644 --- a/test/grayscale.js +++ b/test/grayscale.js @@ -3,7 +3,7 @@ var color = require('../'); var expect = require('unexpected').clone(); describe('grayscale', function () { - it('should convert a non-gray to a shade of gray', function () { - expect(color('#550022').grayscale().hex(), 'to equal', '#1d1d1d'); - }); + it('should convert a non-gray to a shade of gray', function () { + expect(color('#550022').grayscale().hex(), 'to equal', '#1d1d1d'); + }); }); diff --git a/test/isDark.js b/test/isDark.js new file mode 100644 index 0000000..b79ac59 --- /dev/null +++ b/test/isDark.js @@ -0,0 +1,15 @@ +var color = require('../'); + +var expect = require('unexpected').clone(); + +describe('isDark', function () { + it('should return true, if the color is dark', function () { + expect(color('black').isDark(), 'to equal', true); + expect(color('white').isDark(), 'to equal', false); + expect(color('blue').isDark(), 'to equal', true); + expect(color('darkgreen').isDark(), 'to equal', true); + expect(color('pink').isDark(), 'to equal', false); + expect(color('goldenrod').isDark(), 'to equal', false); + expect(color('red').isDark(), 'to equal', true); + }); +}); diff --git a/test/isLight.js b/test/isLight.js new file mode 100644 index 0000000..6b12237 --- /dev/null +++ b/test/isLight.js @@ -0,0 +1,15 @@ +var color = require('../'); + +var expect = require('unexpected').clone(); + +describe('isLight', function () { + it('should return true, if the color is light', function () { + expect(color('black').isLight(), 'to equal', false); + expect(color('white').isLight(), 'to equal', true); + expect(color('blue').isLight(), 'to equal', false); + expect(color('darkgreen').isLight(), 'to equal', false); + expect(color('pink').isLight(), 'to equal', true); + expect(color('goldenrod').isLight(), 'to equal', true); + expect(color('red').isLight(), 'to equal', false); + }); +}); diff --git a/test/luminance.js b/test/luminance.js new file mode 100644 index 0000000..470aa01 --- /dev/null +++ b/test/luminance.js @@ -0,0 +1,13 @@ +var color = require('../'); + +var expect = require('unexpected').clone(); + +describe('luminance', function () { + it('should return the luminance for colors', function () { + expect(color('white').luminance(), 'to equal', 1); + expect(color('black').luminance(), 'to equal', 0); + expect(color('ff0000').luminance(), 'to equal', 0.2126); + expect(color('00ff00').luminance(), 'to equal', 0.7152); + expect(color('0000ff').luminance(), 'to equal', 0.0722); + }); +}); diff --git a/test/mix.js b/test/mix.js index 6d915d8..e63b32e 100644 --- a/test/mix.js +++ b/test/mix.js @@ -3,7 +3,7 @@ var color = require('../'); var expect = require('unexpected').clone(); describe('mix', function () { - it('black and white 50% mix should be gray', function () { - expect(color('white').mix('black').hex(), 'to equal', '#808080'); - }); + it('black and white 50% mix should be gray', function () { + expect(color('white').mix('black').hex(), 'to equal', '#808080'); + }); }); diff --git a/test/parse.js b/test/parse.js index 0644c47..fdcf9a7 100644 --- a/test/parse.js +++ b/test/parse.js @@ -1,175 +1,180 @@ var color = require('../'); var expect = require('unexpected').clone(); -expect.addAssertion(' to be a color instance', function (expect, subject) { - expect(subject, 'to satisfy', { isColor: true }); +expect.addAssertion(' to be a color instance', function ( + expect, + subject +) { + expect(subject, 'to satisfy', { isColor: true }); }); - describe('parsing', function () { - describe('when parsing cmyk example from https://github.com/One-com/one-color/issues/25', function () { - expect(color('cmyk(1.95468%,3.82086%,5.06294%,11.3802%)'), 'to be a color instance'); + describe('when parsing cmyk example from https://github.com/One-com/one-color/issues/25', function () { + expect( + color('cmyk(1.95468%,3.82086%,5.06294%,11.3802%)'), + 'to be a color instance' + ); + }); + + describe('when parsing white cmyk', function () { + var instance = color('cmyk(0%,0%,0%,0%)'); + + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); }); - describe('when parsing white cmyk', function () { - var instance = color('cmyk(0%,0%,0%,0%)'); - - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); - - it('should be white', function () { - expect(instance.hex(), 'to equal', '#ffffff'); - }); + it('should be white', function () { + expect(instance.hex(), 'to equal', '#ffffff'); }); + }); - describe('when parsing black cmyk', function () { - var instance = color('cmyk(100%,100%,100%,100%)'); + describe('when parsing black cmyk', function () { + var instance = color('cmyk(100%,100%,100%,100%)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be black', function () { - expect(instance.hex(), 'to equal', '#000000'); - }); + it('should be black', function () { + expect(instance.hex(), 'to equal', '#000000'); }); + }); - describe('with invalid strings', function () { - it('should refuse a percentage > 100', function () { - expect(color('cmyk(100.1%,100%,100%,100%)'), 'to be false'); - }); + describe('with invalid strings', function () { + it('should refuse a percentage > 100', function () { + expect(color('cmyk(100.1%,100%,100%,100%)'), 'to be false'); + }); - it('should refuse to parse a non-percentage', function () { - expect(color('cmyk(100,100%,100%,100%)'), 'to be false'); - }); + it('should refuse to parse a non-percentage', function () { + expect(color('cmyk(100,100%,100%,100%)'), 'to be false'); + }); - it('should refuse to parse less than 4 channels', function () { - expect(color('cmyk(100,100%,100%)'), 'to be false'); - }); + it('should refuse to parse less than 4 channels', function () { + expect(color('cmyk(100,100%,100%)'), 'to be false'); }); + }); - describe('with #rrggbbaa', function () { - var instance = color('#00ff0080'); + describe('with #rrggbbaa', function () { + var instance = color('#00ff0080'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#00ff00'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#00ff00'); + }); - it('should have its alpha channel set correctly', function () { - expect(instance.alpha().toFixed(2), 'to equal', '0.50'); - }); + it('should have its alpha channel set correctly', function () { + expect(instance.alpha().toFixed(2), 'to equal', '0.50'); }); + }); - describe('with #rgba', function () { - var instance = color('#0f08'); + describe('with #rgba', function () { + var instance = color('#0f08'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#00ff00'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#00ff00'); + }); - it('should have its alpha channel set correctly', function () { - expect(instance.alpha().toFixed(2), 'to equal', '0.53'); - }); + it('should have its alpha channel set correctly', function () { + expect(instance.alpha().toFixed(2), 'to equal', '0.53'); }); + }); - describe('with rgb(r, g, b)', function () { - var instance = color('rgb(10, 20, 30)'); + describe('with rgb(r, g, b)', function () { + var instance = color('rgb(10, 20, 30)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#0a141e'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#0a141e'); }); + }); - describe('with rgb(r,g,b)', function () { - var instance = color('rgb(10,20,30)'); + describe('with rgb(r,g,b)', function () { + var instance = color('rgb(10,20,30)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#0a141e'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#0a141e'); }); + }); - describe('with rgb(r g b)', function () { - var instance = color('rgb(10 20 30)'); + describe('with rgb(r g b)', function () { + var instance = color('rgb(10 20 30)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#0a141e'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#0a141e'); }); + }); - describe('with rgba(r g b / a)', function () { - var instance = color('rgba(10 20 30 / 50%)'); + describe('with rgba(r g b / a)', function () { + var instance = color('rgba(10 20 30 / 50%)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#0a141e'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#0a141e'); + }); - it('should have its alpha channel set correctly', function () { - expect(instance.alpha().toFixed(2), 'to equal', '0.50'); - }); + it('should have its alpha channel set correctly', function () { + expect(instance.alpha().toFixed(2), 'to equal', '0.50'); }); + }); - describe('with rgba(r g b/a)', function () { - var instance = color('rgba(10 20 30/50%)'); + describe('with rgba(r g b/a)', function () { + var instance = color('rgba(10 20 30/50%)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#0a141e'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#0a141e'); + }); - it('should have its alpha channel set correctly', function () { - expect(instance.alpha().toFixed(2), 'to equal', '0.50'); - }); + it('should have its alpha channel set correctly', function () { + expect(instance.alpha().toFixed(2), 'to equal', '0.50'); }); + }); - describe('with hsl(h s l) and the hue given as a percentage', function () { - var instance = color('hsl(10% 20% 30%)'); + describe('with hsl(h s l) and the hue given as a percentage', function () { + var instance = color('hsl(10% 20% 30%)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#5c503d'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#5c503d'); }); + }); - describe('with hsl(h s l) and the hue given as an angle', function () { - var instance = color('hsl(10deg 20% 30%)'); + describe('with hsl(h s l) and the hue given as an angle', function () { + var instance = color('hsl(10deg 20% 30%)'); - it('should return a color instance', function () { - expect(instance, 'to be a color instance'); - }); + it('should return a color instance', function () { + expect(instance, 'to be a color instance'); + }); - it('should be green', function () { - expect(instance.hex(), 'to equal', '#5c423d'); - }); + it('should be green', function () { + expect(instance.hex(), 'to equal', '#5c423d'); }); + }); }); diff --git a/test/samples.js b/test/samples.js index 109c7be..7f5a32e 100644 --- a/test/samples.js +++ b/test/samples.js @@ -1,147 +1,147 @@ module.exports = { - 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', - 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' + 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', + 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', };