mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-12 21:03:32 -06:00
Initial commit
This commit is contained in:
51
node_modules/color-diff/.npmignore
generated
vendored
Normal file
51
node_modules/color-diff/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
# Cortex project
|
||||
build/
|
||||
|
||||
# php files
|
||||
index.php
|
||||
|
||||
# Numerous always-ignore extensions
|
||||
*.bak
|
||||
*.patch
|
||||
*.diff
|
||||
*.err
|
||||
*.orig
|
||||
*.log
|
||||
*.rej
|
||||
*.swo
|
||||
*.swp
|
||||
*.zip
|
||||
*.vi
|
||||
*~
|
||||
*.sass-cache
|
||||
|
||||
# OS or Editor folders
|
||||
.DS_Store
|
||||
._*
|
||||
.cache
|
||||
.project
|
||||
.settings
|
||||
.tmproj
|
||||
*.esproj
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
nbproject
|
||||
thumbs.db
|
||||
|
||||
# Folders to ignore
|
||||
.hg
|
||||
.svn
|
||||
.CVS
|
||||
.idea
|
||||
node_modules
|
||||
old/
|
||||
*-old/
|
||||
*-notrack/
|
||||
build/
|
||||
combo/
|
||||
reference/
|
||||
jscoverage_lib/
|
||||
temp/
|
||||
coverage/
|
||||
|
||||
|
4
node_modules/color-diff/.travis.yml
generated
vendored
Normal file
4
node_modules/color-diff/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.8"
|
24
node_modules/color-diff/COPYING
generated
vendored
Normal file
24
node_modules/color-diff/COPYING
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2012-2015, Markus Ekholm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
75
node_modules/color-diff/README.md
generated
vendored
Normal file
75
node_modules/color-diff/README.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# Color-diff
|
||||
[](https://travis-ci.org/markusn/color-diff)
|
||||
[](https://coveralls.io/r/markusn/color-diff?branch=master)
|
||||
|
||||
Implemets the CIEDE2000 color difference algorithm, conversion between RGB and LAB color and mapping all colors in palette X to the closest color in palette Y based on the CIEDE2000 difference.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install color-diff --save
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
Are located in the `test/` folder and are run by:
|
||||
|
||||
npm test
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var diff = require('color-diff');
|
||||
```
|
||||
|
||||
### diff.closest(color, palette)
|
||||
|
||||
Returns the closest color.
|
||||
|
||||
```js
|
||||
var color = { R: 255, G: 1, B: 30 };
|
||||
// red, green, blue
|
||||
var palette = [ {R: 255, G: 0, B: 0 }, {R: 0, G: 255, B: 0 }, {R: 0, G: 0, B: 255} ];
|
||||
|
||||
diff.closest(color, palette); // {R: 255, G: 0, B: 0 }, red
|
||||
```
|
||||
|
||||
The result above is obvious, but `diff.closest` could deal with more complicated cases.
|
||||
|
||||
### diff.furthest(color, palette)
|
||||
|
||||
Returns the most different color.
|
||||
|
||||
```js
|
||||
var color = { R: 255, G: 255, B: 255 };
|
||||
// black, white
|
||||
var palette = [ {R: 0, G: 0, B: 0 }, {R: 255, G: 255, B: 255 } ];
|
||||
|
||||
diff.furthest(color, palette); // {R: 0, G: 0, B: 0 }, black
|
||||
```
|
||||
|
||||
The result above is obvious, but `diff.furthest` could deal with more complicated cases.
|
||||
|
||||
|
||||
#### color
|
||||
`Object`
|
||||
|
||||
`color` is an object containing 3 properties: 'R', 'G', 'B', such as:
|
||||
|
||||
```js
|
||||
{ R: 255, G: 1, B: 0 }
|
||||
```
|
||||
|
||||
#### palette
|
||||
|
||||
`Array.<Object>`
|
||||
|
||||
Color palette array which contains many `color`-like objects.
|
||||
|
||||
|
||||
## Author
|
||||
Markus Ekholm
|
||||
|
||||
## License
|
||||
3-clause BSD. For details see `COPYING`.
|
113
node_modules/color-diff/lib/convert.js
generated
vendored
Normal file
113
node_modules/color-diff/lib/convert.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* @author Markus Ekholm
|
||||
* @copyright 2012-2015 (c) Markus Ekholm <markus at botten dot org >
|
||||
* @license Copyright (c) 2012-2015, Markus Ekholm
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* EXPORTS
|
||||
*/
|
||||
exports.rgb_to_lab = rgb_to_lab;
|
||||
|
||||
/**
|
||||
* IMPORTS
|
||||
*/
|
||||
var pow = Math.pow;
|
||||
var sqrt = Math.sqrt;
|
||||
|
||||
/**
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns c converted to labcolor.
|
||||
* @param {rgbcolor} c should have fields R,G,B
|
||||
* @return {labcolor} c converted to labcolor
|
||||
*/
|
||||
function rgb_to_lab(c)
|
||||
{
|
||||
return xyz_to_lab(rgb_to_xyz(c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns c converted to xyzcolor.
|
||||
* @param {rgbcolor} c should have fields R,G,B
|
||||
* @return {xyzcolor} c converted to xyzcolor
|
||||
*/
|
||||
function rgb_to_xyz(c)
|
||||
{
|
||||
// Based on http://www.easyrgb.com/index.php?X=MATH&H=02
|
||||
var R = ( c.R / 255 );
|
||||
var G = ( c.G / 255 );
|
||||
var B = ( c.B / 255 );
|
||||
|
||||
if ( R > 0.04045 ) R = pow(( ( R + 0.055 ) / 1.055 ),2.4);
|
||||
else R = R / 12.92;
|
||||
if ( G > 0.04045 ) G = pow(( ( G + 0.055 ) / 1.055 ),2.4);
|
||||
else G = G / 12.92;
|
||||
if ( B > 0.04045 ) B = pow(( ( B + 0.055 ) / 1.055 ), 2.4);
|
||||
else B = B / 12.92;
|
||||
|
||||
R *= 100;
|
||||
G *= 100;
|
||||
B *= 100;
|
||||
|
||||
// Observer. = 2°, Illuminant = D65
|
||||
var X = R * 0.4124 + G * 0.3576 + B * 0.1805;
|
||||
var Y = R * 0.2126 + G * 0.7152 + B * 0.0722;
|
||||
var Z = R * 0.0193 + G * 0.1192 + B * 0.9505;
|
||||
return {'X' : X, 'Y' : Y, 'Z' : Z};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns c converted to labcolor.
|
||||
* @param {xyzcolor} c should have fields X,Y,Z
|
||||
* @return {labcolor} c converted to labcolor
|
||||
*/
|
||||
function xyz_to_lab(c)
|
||||
{
|
||||
// Based on http://www.easyrgb.com/index.php?X=MATH&H=07
|
||||
var ref_Y = 100.000;
|
||||
var ref_Z = 108.883;
|
||||
var ref_X = 95.047; // Observer= 2°, Illuminant= D65
|
||||
var Y = c.Y / ref_Y;
|
||||
var Z = c.Z / ref_Z;
|
||||
var X = c.X / ref_X;
|
||||
if ( X > 0.008856 ) X = pow(X, 1/3);
|
||||
else X = ( 7.787 * X ) + ( 16 / 116 );
|
||||
if ( Y > 0.008856 ) Y = pow(Y, 1/3);
|
||||
else Y = ( 7.787 * Y ) + ( 16 / 116 );
|
||||
if ( Z > 0.008856 ) Z = pow(Z, 1/3);
|
||||
else Z = ( 7.787 * Z ) + ( 16 / 116 );
|
||||
var L = ( 116 * Y ) - 16;
|
||||
var a = 500 * ( X - Y );
|
||||
var b = 200 * ( Y - Z );
|
||||
return {'L' : L , 'a' : a, 'b' : b};
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// allout-layout: t
|
||||
// js-indent-level: 2
|
||||
// End:
|
164
node_modules/color-diff/lib/diff.js
generated
vendored
Normal file
164
node_modules/color-diff/lib/diff.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @author Markus Ekholm
|
||||
* @copyright 2012-2015 (c) Markus Ekholm <markus at botten dot org >
|
||||
* @license Copyright (c) 2012-2015, Markus Ekholm
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* EXPORTS
|
||||
*/
|
||||
exports.ciede2000 = ciede2000;
|
||||
|
||||
/**
|
||||
* IMPORTS
|
||||
*/
|
||||
var sqrt = Math.sqrt;
|
||||
var pow = Math.pow;
|
||||
var cos = Math.cos;
|
||||
var atan2 = Math.atan2;
|
||||
var sin = Math.sin;
|
||||
var abs = Math.abs;
|
||||
var exp = Math.exp;
|
||||
var PI = Math.PI;
|
||||
|
||||
/**
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns diff between c1 and c2 using the CIEDE2000 algorithm
|
||||
* @param {labcolor} c1 Should have fields L,a,b
|
||||
* @param {labcolor} c2 Should have fields L,a,b
|
||||
* @return {float} Difference between c1 and c2
|
||||
*/
|
||||
function ciede2000(c1,c2)
|
||||
{
|
||||
/**
|
||||
* Implemented as in "The CIEDE2000 Color-Difference Formula:
|
||||
* Implementation Notes, Supplementary Test Data, and Mathematical Observations"
|
||||
* by Gaurav Sharma, Wencheng Wu and Edul N. Dalal.
|
||||
*/
|
||||
|
||||
// Get L,a,b values for color 1
|
||||
var L1 = c1.L;
|
||||
var a1 = c1.a;
|
||||
var b1 = c1.b;
|
||||
|
||||
// Get L,a,b values for color 2
|
||||
var L2 = c2.L;
|
||||
var a2 = c2.a;
|
||||
var b2 = c2.b;
|
||||
|
||||
// Weight factors
|
||||
var kL = 1;
|
||||
var kC = 1;
|
||||
var kH = 1;
|
||||
|
||||
/**
|
||||
* Step 1: Calculate C1p, C2p, h1p, h2p
|
||||
*/
|
||||
var C1 = sqrt(pow(a1, 2) + pow(b1, 2)) //(2)
|
||||
var C2 = sqrt(pow(a2, 2) + pow(b2, 2)) //(2)
|
||||
|
||||
var a_C1_C2 = (C1+C2)/2.0; //(3)
|
||||
|
||||
var G = 0.5 * (1 - sqrt(pow(a_C1_C2 , 7.0) /
|
||||
(pow(a_C1_C2, 7.0) + pow(25.0, 7.0)))); //(4)
|
||||
|
||||
var a1p = (1.0 + G) * a1; //(5)
|
||||
var a2p = (1.0 + G) * a2; //(5)
|
||||
|
||||
var C1p = sqrt(pow(a1p, 2) + pow(b1, 2)); //(6)
|
||||
var C2p = sqrt(pow(a2p, 2) + pow(b2, 2)); //(6)
|
||||
|
||||
var hp_f = function(x,y) //(7)
|
||||
{
|
||||
if(x== 0 && y == 0) return 0;
|
||||
else{
|
||||
var tmphp = degrees(atan2(x,y));
|
||||
if(tmphp >= 0) return tmphp
|
||||
else return tmphp + 360;
|
||||
}
|
||||
}
|
||||
|
||||
var h1p = hp_f(b1, a1p); //(7)
|
||||
var h2p = hp_f(b2, a2p); //(7)
|
||||
|
||||
/**
|
||||
* Step 2: Calculate dLp, dCp, dHp
|
||||
*/
|
||||
var dLp = L2 - L1; //(8)
|
||||
var dCp = C2p - C1p; //(9)
|
||||
|
||||
var dhp_f = function(C1, C2, h1p, h2p) //(10)
|
||||
{
|
||||
if(C1*C2 == 0) return 0;
|
||||
else if(abs(h2p-h1p) <= 180) return h2p-h1p;
|
||||
else if((h2p-h1p) > 180) return (h2p-h1p)-360;
|
||||
else if((h2p-h1p) < -180) return (h2p-h1p)+360;
|
||||
else throw(new Error());
|
||||
}
|
||||
var dhp = dhp_f(C1,C2, h1p, h2p); //(10)
|
||||
var dHp = 2*sqrt(C1p*C2p)*sin(radians(dhp)/2.0); //(11)
|
||||
|
||||
/**
|
||||
* Step 3: Calculate CIEDE2000 Color-Difference
|
||||
*/
|
||||
var a_L = (L1 + L2) / 2.0; //(12)
|
||||
var a_Cp = (C1p + C2p) / 2.0; //(13)
|
||||
|
||||
var a_hp_f = function(C1, C2, h1p, h2p) { //(14)
|
||||
if(C1*C2 == 0) return h1p+h2p
|
||||
else if(abs(h1p-h2p)<= 180) return (h1p+h2p)/2.0;
|
||||
else if((abs(h1p-h2p) > 180) && ((h1p+h2p) < 360)) return (h1p+h2p+360)/2.0;
|
||||
else if((abs(h1p-h2p) > 180) && ((h1p+h2p) >= 360)) return (h1p+h2p-360)/2.0;
|
||||
else throw(new Error());
|
||||
}
|
||||
var a_hp = a_hp_f(C1,C2,h1p,h2p); //(14)
|
||||
var T = 1-0.17*cos(radians(a_hp-30))+0.24*cos(radians(2*a_hp))+
|
||||
0.32*cos(radians(3*a_hp+6))-0.20*cos(radians(4*a_hp-63)); //(15)
|
||||
var d_ro = 30 * exp(-(pow((a_hp-275)/25,2))); //(16)
|
||||
var RC = sqrt((pow(a_Cp, 7.0)) / (pow(a_Cp, 7.0) + pow(25.0, 7.0)));//(17)
|
||||
var SL = 1 + ((0.015 * pow(a_L - 50, 2)) /
|
||||
sqrt(20 + pow(a_L - 50, 2.0)));//(18)
|
||||
var SC = 1 + 0.045 * a_Cp;//(19)
|
||||
var SH = 1 + 0.015 * a_Cp * T;//(20)
|
||||
var RT = -2 * RC * sin(radians(2 * d_ro));//(21)
|
||||
var dE = sqrt(pow(dLp /(SL * kL), 2) + pow(dCp /(SC * kC), 2) +
|
||||
pow(dHp /(SH * kH), 2) + RT * (dCp /(SC * kC)) *
|
||||
(dHp / (SH * kH))); //(22)
|
||||
return dE;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL FUNCTIONS
|
||||
*/
|
||||
function degrees(n) { return n*(180/PI); }
|
||||
function radians(n) { return n*(PI/180); }
|
||||
|
||||
// Local Variables:
|
||||
// allout-layout: t
|
||||
// js-indent-level: 2
|
||||
// End:
|
28
node_modules/color-diff/lib/index.js
generated
vendored
Normal file
28
node_modules/color-diff/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var diff = require('./diff');
|
||||
var convert = require('./convert');
|
||||
var palette = require('./palette');
|
||||
|
||||
var color = module.exports = {};
|
||||
|
||||
color.diff = diff.ciede2000;
|
||||
color.rgb_to_lab = convert.rgb_to_lab;
|
||||
color.map_palette = palette.map_palette;
|
||||
color.palette_map_key = palette.palette_map_key;
|
||||
|
||||
color.closest = function(target, relative) {
|
||||
var key = color.palette_map_key(target);
|
||||
|
||||
var result = color.map_palette([target], relative, 'closest');
|
||||
|
||||
return result[key];
|
||||
};
|
||||
|
||||
color.furthest = function(target, relative) {
|
||||
var key = color.palette_map_key(target);
|
||||
|
||||
var result = color.map_palette([target], relative, 'furthest');
|
||||
|
||||
return result[key];
|
||||
};
|
107
node_modules/color-diff/lib/palette.js
generated
vendored
Normal file
107
node_modules/color-diff/lib/palette.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @author Markus Ekholm
|
||||
* @copyright 2012-2015 (c) Markus Ekholm <markus at botten dot org >
|
||||
* @license Copyright (c) 2012-2015, Markus Ekholm
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* EXPORTS
|
||||
*/
|
||||
exports.map_palette = map_palette;
|
||||
exports.palette_map_key = palette_map_key;
|
||||
|
||||
/**
|
||||
* IMPORTS
|
||||
*/
|
||||
var color_diff = require('./diff');
|
||||
var color_convert = require('./convert');
|
||||
|
||||
/**
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the hash key used for a {rgbcolor} in a {palettemap}
|
||||
* @param {rgbcolor} c should have fields R,G,B
|
||||
* @return {string}
|
||||
*/
|
||||
function palette_map_key(c)
|
||||
{
|
||||
return "R" + c.R + "B" + c.B + "G" + c.G;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping from each color in a to the closest color in b
|
||||
* @param [{rgbcolor}] a each element should have fields R,G,B
|
||||
* @param [{rgbcolor}] b each element should have fields R,G,B
|
||||
* @param 'type' should be the string 'closest' or 'furthest'
|
||||
* @return {palettemap}
|
||||
*/
|
||||
function map_palette(a, b, type)
|
||||
{
|
||||
var c = {};
|
||||
type = type || 'closest';
|
||||
for (var idx1 = 0; idx1 < a.length; idx1 += 1){
|
||||
var color1 = a[idx1];
|
||||
var best_color = undefined;
|
||||
var best_color_diff = undefined;
|
||||
for (var idx2 = 0; idx2 < b.length; idx2 += 1)
|
||||
{
|
||||
var color2 = b[idx2];
|
||||
var current_color_diff = diff(color1,color2);
|
||||
|
||||
if((best_color == undefined) || ((type === 'closest') && (current_color_diff < best_color_diff)))
|
||||
{
|
||||
best_color = color2;
|
||||
best_color_diff = current_color_diff;
|
||||
continue;
|
||||
}
|
||||
if((type === 'furthest') && (current_color_diff > best_color_diff))
|
||||
{
|
||||
best_color = color2;
|
||||
best_color_diff = current_color_diff;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
c[palette_map_key(color1)] = best_color;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
function diff(c1,c2)
|
||||
{
|
||||
c1 = color_convert.rgb_to_lab(c1);
|
||||
c2 = color_convert.rgb_to_lab(c2);
|
||||
return color_diff.ciede2000(c1,c2);
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// allout-layout: t
|
||||
// js-indent-level: 2
|
||||
// End:
|
89
node_modules/color-diff/package.json
generated
vendored
Normal file
89
node_modules/color-diff/package.json
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"color-diff@^0.1.3",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/colorguard"
|
||||
]
|
||||
],
|
||||
"_from": "color-diff@>=0.1.3 <0.2.0",
|
||||
"_id": "color-diff@0.1.7",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/color-diff",
|
||||
"_npmUser": {
|
||||
"email": "markus@botten.org",
|
||||
"name": "markusn"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "color-diff",
|
||||
"raw": "color-diff@^0.1.3",
|
||||
"rawSpec": "^0.1.3",
|
||||
"scope": null,
|
||||
"spec": ">=0.1.3 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/colorguard"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/color-diff/-/color-diff-0.1.7.tgz",
|
||||
"_shasum": "6db78cd9482a8e459d40821eaf4b503283dcb8e2",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "color-diff@^0.1.3",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/colorguard",
|
||||
"author": {
|
||||
"name": "markusn kael"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/markusn/color-diff/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Implemets the CIEDE2000 color difference algorithm, conversion between RGB and LAB color and mapping all colors in palette X to the closest or most different color in palette Y based on the CIEDE2000 difference.",
|
||||
"devDependencies": {
|
||||
"assert": "~0.4.9",
|
||||
"coveralls": "~2.1.0",
|
||||
"istanbul": "~0.1.40",
|
||||
"mocha": "~1.12.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "6db78cd9482a8e459d40821eaf4b503283dcb8e2",
|
||||
"tarball": "https://registry.npmjs.org/color-diff/-/color-diff-0.1.7.tgz"
|
||||
},
|
||||
"gitHead": "61269601ac72e65afd111565bfa68a2d13092de0",
|
||||
"homepage": "https://github.com/markusn/color-diff",
|
||||
"keywords": [
|
||||
"CIEDE2000",
|
||||
"closest",
|
||||
"color",
|
||||
"color-diff",
|
||||
"conversion",
|
||||
"convert",
|
||||
"diff",
|
||||
"pallette"
|
||||
],
|
||||
"license": "BSD",
|
||||
"main": "lib/index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "kael",
|
||||
"email": "i@kael.me"
|
||||
},
|
||||
{
|
||||
"name": "markusn",
|
||||
"email": "markus@botten.org"
|
||||
}
|
||||
],
|
||||
"name": "color-diff",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/markusn/color-diff.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "istanbul cover _mocha && ((cat coverage/lcov.info | coveralls) || exit 0)"
|
||||
},
|
||||
"version": "0.1.7"
|
||||
}
|
74
node_modules/color-diff/test/convert.js
generated
vendored
Normal file
74
node_modules/color-diff/test/convert.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @author Markus Ekholm
|
||||
* @copyright 2012-2015 (c) Markus Ekholm <markus at botten dot org >
|
||||
* @license Copyright (c) 2012-2015, Markus Ekholm
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* IMPORTS
|
||||
*/
|
||||
var assert = require('assert');
|
||||
var color_convert = require('../lib/convert');
|
||||
|
||||
/**
|
||||
* TESTS
|
||||
*/
|
||||
|
||||
describe('convert', function(){
|
||||
describe('#rgb_to_lab()', function(){
|
||||
it('should convert to expected lab color #1', function(){
|
||||
assert.deepEqual({'L' : 40.473, 'a' : -6.106, 'b' : -21.417},
|
||||
round_all(color_convert.rgb_to_lab({'R' : 55,
|
||||
'G' : 100,
|
||||
'B' : 130})));
|
||||
});
|
||||
it('should convert to expected lab color #2', function(){
|
||||
assert.deepEqual({'L' : 0, 'a' : 0, 'b' : 0},
|
||||
round_all(color_convert.rgb_to_lab({'R' : 0,
|
||||
'G' : 0,
|
||||
'B' : 0})));
|
||||
});
|
||||
it('should convert to expected lab color #3', function(){
|
||||
assert.deepEqual({'L' : 100, 'a' : 0.005, 'b' : -0.010},
|
||||
round_all(color_convert.rgb_to_lab({'R' : 255,
|
||||
'G' : 255,
|
||||
'B' : 255})));
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* INTERNAL FUNCTIONS
|
||||
*/
|
||||
function round_all(c){ return {'L' : round(c.L),
|
||||
'a' : round(c.a),
|
||||
'b' : round(c.b)};
|
||||
}
|
||||
function round(n){ return Math.round(n*1000)/1000; }
|
||||
|
||||
// Local Variables:
|
||||
// allout-layout: t
|
||||
// js-indent-level: 2
|
||||
// End:
|
450
node_modules/color-diff/test/diff.js
generated
vendored
Normal file
450
node_modules/color-diff/test/diff.js
generated
vendored
Normal file
@@ -0,0 +1,450 @@
|
||||
/**
|
||||
* @author Markus Ekholm
|
||||
* @copyright 2012-2015 (c) Markus Ekholm <markus at botten dot org >
|
||||
* @license Copyright (c) 2012-2015, Markus Ekholm
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* IMPORTS
|
||||
*/
|
||||
var assert = require('assert');
|
||||
var color_diff = require('../lib/diff');
|
||||
|
||||
/**
|
||||
* TESTS
|
||||
*/
|
||||
|
||||
/**
|
||||
* CIEDE2000 tests the diff.cie2000.
|
||||
* Cases taken from the paper "The CIEDE2000 Color-Difference Formula:
|
||||
* Implementation Notes, Supplementary Test Data, and Mathematical Observations"
|
||||
* by Gaurav Sharma, Wencheng Wu and Edul N. Dalal.
|
||||
*/
|
||||
describe('diff', function(){
|
||||
describe('#ciede2000()', function(){
|
||||
it("should use the true chroma difference (#1)", function(){
|
||||
assert_ciede2000_diff(2.0425,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.6772,
|
||||
"b" : -79.7751
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -82.7485
|
||||
});
|
||||
});
|
||||
it("should use the true chroma difference (#2)", function(){
|
||||
assert_ciede2000_diff(2.8615,
|
||||
{"L" : 50.0000,
|
||||
"a" : 3.1571,
|
||||
"b" : -77.2803
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -82.7485
|
||||
});
|
||||
});
|
||||
it("should use the true chroma difference (#3)", function(){
|
||||
assert_ciede2000_diff(3.4412,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.8361,
|
||||
"b" : -74.0200
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -82.7485
|
||||
});
|
||||
});
|
||||
it("should use the true hue difference (#4)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : -1.3802,
|
||||
"b" : -84.2814
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -82.7485
|
||||
});
|
||||
});
|
||||
it("should use the true hue difference (#5)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : -1.1848,
|
||||
"b" : -84.8006
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -82.7485
|
||||
});
|
||||
});
|
||||
it("should use the true hue difference (#6)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : -0.9009,
|
||||
"b" : -85.5211
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -82.7485
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#7)", function(){
|
||||
assert_ciede2000_diff(2.3669,
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : -1.0000,
|
||||
"b" : 2.0000
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#8)", function(){
|
||||
assert_ciede2000_diff(2.3669,
|
||||
{"L" : 50.0000,
|
||||
"a" : -1.0000,
|
||||
"b" : 2.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : 0.0000
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#9)", function(){
|
||||
assert_ciede2000_diff(7.1792,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.4900,
|
||||
"b" : -0.0010
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : -2.4900,
|
||||
"b" : 0.0009
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#10)", function(){
|
||||
assert_ciede2000_diff(7.1792,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.4900,
|
||||
"b" : -0.0010
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : -2.4900,
|
||||
"b" : 0.0010
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#11)", function(){
|
||||
assert_ciede2000_diff(7.2195,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.4900,
|
||||
"b" : -0.0010
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : -2.4900,
|
||||
"b" : 0.0011
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#12)", function(){
|
||||
assert_ciede2000_diff(7.2195,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.4900,
|
||||
"b" : -0.0010
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : -2.4900,
|
||||
"b" : 0.0012
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#13)", function(){
|
||||
assert_ciede2000_diff(4.8045,
|
||||
{"L" : 50.0000,
|
||||
"a" : -0.0010,
|
||||
"b" : 2.4900
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0009,
|
||||
"b" : -2.4900
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#14)", function(){
|
||||
assert_ciede2000_diff(4.8045,
|
||||
{"L" : 50.0000,
|
||||
"a" : -0.0010,
|
||||
"b" : 2.4900
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0010,
|
||||
"b" : -2.4900
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#15)", function(){
|
||||
assert_ciede2000_diff(4.7461,
|
||||
{"L" : 50.0000,
|
||||
"a" : -0.0010,
|
||||
"b" : 2.4900
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0011,
|
||||
"b" : -2.4900
|
||||
});
|
||||
});
|
||||
it("should use the correct arctangent computation (#16)", function(){
|
||||
assert_ciede2000_diff(4.3065,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 0.0000,
|
||||
"b" : -2.5000
|
||||
});
|
||||
});
|
||||
it("should work for large color differences (#17)", function(){
|
||||
assert_ciede2000_diff(27.1492,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 73.0000,
|
||||
"a" : 25.0000,
|
||||
"b" : -18.0000
|
||||
});
|
||||
});
|
||||
it("should work for large color differences (#18)", function(){
|
||||
assert_ciede2000_diff(22.8977,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 61.0000,
|
||||
"a" : -5.0000,
|
||||
"b" : 29.0000
|
||||
});
|
||||
});
|
||||
it("should work for large color differences (#19)", function(){
|
||||
assert_ciede2000_diff(31.9030,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 56.0000,
|
||||
"a" : -27.0000,
|
||||
"b" : -3.0000
|
||||
});
|
||||
});
|
||||
it("should work for large color differences (#20)", function(){
|
||||
assert_ciede2000_diff(19.4535,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 58.0000,
|
||||
"a" : 24.0000,
|
||||
"b" : 15.0000
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#21)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 3.1736,
|
||||
"b" : 0.5854
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#22)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 3.2972,
|
||||
"b" : 0.0000
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#23)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 1.8634,
|
||||
"b" : 0.5757
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#24)", function(){
|
||||
assert_ciede2000_diff(1.0000,
|
||||
{"L" : 50.0000,
|
||||
"a" : 2.5000,
|
||||
"b" : 0.0000
|
||||
},
|
||||
{"L" : 50.0000,
|
||||
"a" : 3.2592,
|
||||
"b" : 0.3350
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#25)", function(){
|
||||
assert_ciede2000_diff(1.2644,
|
||||
{"L" : 60.2574,
|
||||
"a" : -34.0099,
|
||||
"b" : 36.2677
|
||||
},
|
||||
{"L" : 60.4626,
|
||||
"a" : -34.1751,
|
||||
"b" : 39.4387
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#26)", function(){
|
||||
assert_ciede2000_diff(1.2630,
|
||||
{"L" : 63.0109,
|
||||
"a" : -31.0961,
|
||||
"b" : -5.8663
|
||||
},
|
||||
{"L" : 62.8187,
|
||||
"a" : -29.7946,
|
||||
"b" : -4.0864
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#27)", function(){
|
||||
assert_ciede2000_diff(1.8731,
|
||||
{"L" : 61.2901,
|
||||
"a" : 3.7196,
|
||||
"b" : -5.3901
|
||||
},
|
||||
{"L" : 61.4292,
|
||||
"a" : 2.2480,
|
||||
"b" : -4.9620
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#28)", function(){
|
||||
assert_ciede2000_diff(1.8645,
|
||||
{"L" : 35.0831,
|
||||
"a" : -44.1164,
|
||||
"b" : 3.7933
|
||||
},
|
||||
{"L" : 35.0232,
|
||||
"a" : -40.0716,
|
||||
"b" : 1.5901
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#29)", function(){
|
||||
assert_ciede2000_diff(2.0373,
|
||||
{"L" : 22.7233,
|
||||
"a" : 20.0904,
|
||||
"b" : -46.6940
|
||||
},
|
||||
{"L" : 23.0331,
|
||||
"a" : 14.9730,
|
||||
"b" : -42.5619
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#30)", function(){
|
||||
assert_ciede2000_diff(1.4146,
|
||||
{"L" : 36.4612,
|
||||
"a" : 47.8580,
|
||||
"b" : 18.3852
|
||||
},
|
||||
{"L" : 36.2715,
|
||||
"a" : 50.5065,
|
||||
"b" : 21.2231
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#31)", function(){
|
||||
assert_ciede2000_diff(1.4441,
|
||||
{"L" : 90.8027,
|
||||
"a" : -2.0831,
|
||||
"b" : 1.4410
|
||||
},
|
||||
{"L" : 91.1528,
|
||||
"a" : -1.6435,
|
||||
"b" : 0.0447
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#32)", function(){
|
||||
assert_ciede2000_diff(1.5381,
|
||||
{"L" : 90.9257,
|
||||
"a" : -0.5406,
|
||||
"b" : -0.9208
|
||||
},
|
||||
{"L" : 88.6381,
|
||||
"a" : -0.8985,
|
||||
"b" : -0.7239
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#33)", function(){
|
||||
assert_ciede2000_diff(0.6377,
|
||||
{"L" : 6.7747,
|
||||
"a" : -0.2908,
|
||||
"b" : -2.4247
|
||||
},
|
||||
{"L" : 5.8714,
|
||||
"a" : -0.0985,
|
||||
"b" : -2.2286
|
||||
});
|
||||
});
|
||||
it("should produce numbers found in the CIE technical report (#34)", function(){
|
||||
assert_ciede2000_diff(0.9082,
|
||||
{"L" : 2.0776,
|
||||
"a" : 0.0795,
|
||||
"b" : -1.1350
|
||||
},
|
||||
{"L" : 0.9033,
|
||||
"a" : -0.0636,
|
||||
"b" : -0.5514
|
||||
});
|
||||
});
|
||||
it("should throw error", function(){
|
||||
assert.throws(
|
||||
function(){ color_diff.ciede2000({"L" : NaN,
|
||||
"a" : NaN,
|
||||
"b" : NaN},
|
||||
{"L" : 0,
|
||||
"a" : 0,
|
||||
"b" : 0
|
||||
})
|
||||
},
|
||||
Error)
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* INTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
function assert_ciede2000_diff(expected, c1, c2){
|
||||
assert.equal(expected, round(color_diff.ciede2000(c1, c2)));
|
||||
assert.equal(expected, round(color_diff.ciede2000(c2, c1)));
|
||||
}
|
||||
|
||||
function round(n){ return Math.round(n*10000)/10000; }
|
||||
|
||||
// Local Variables:
|
||||
// allout-layout: t
|
||||
// js-indent-level: 2
|
||||
// End:
|
95
node_modules/color-diff/test/palette.js
generated
vendored
Normal file
95
node_modules/color-diff/test/palette.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @author Markus Ekholm
|
||||
* @copyright 2012-2015 (c) Markus Ekholm <markus at botten dot org >
|
||||
* @license Copyright (c) 2012, Markus Ekholm
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL MARKUS EKHOLM BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* IMPORTS
|
||||
*/
|
||||
var assert = require('assert');
|
||||
var color_palette = require('../lib/palette');
|
||||
|
||||
/**
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
var white = {'R':255 , 'G':255 ,'B':255};
|
||||
var black = {'R':0 , 'G':0 ,'B':0};
|
||||
var navy = {'R':0 , 'G':0 ,'B':128};
|
||||
var blue = {'R':0 , 'G':0 ,'B':255};
|
||||
var yellow = {'R':255 , 'G':255 ,'B':0};
|
||||
var gold = {'R':255 , 'G':215 ,'B':0};
|
||||
var colors1 = [white, black, navy, blue, yellow, gold]
|
||||
var colors2 = [white, black, blue, gold]
|
||||
var colors3 = [white, black, yellow, blue]
|
||||
|
||||
/**
|
||||
* TESTS
|
||||
*/
|
||||
|
||||
describe('palette', function(){
|
||||
describe('#map_palette()', function (){
|
||||
it('should map all colors to themselves when possible',
|
||||
function(){
|
||||
var expected1 = {};
|
||||
expected1[color_palette.palette_map_key(white)] = white;
|
||||
expected1[color_palette.palette_map_key(black)] = black;
|
||||
expected1[color_palette.palette_map_key(navy)] = navy;
|
||||
expected1[color_palette.palette_map_key(blue)] = blue;
|
||||
expected1[color_palette.palette_map_key(yellow)] = yellow;
|
||||
expected1[color_palette.palette_map_key(gold)] = gold;
|
||||
assert.deepEqual(expected1, color_palette.map_palette(colors1, colors1));
|
||||
});
|
||||
it('should map navy->blue and yellow->gold when navy and yellow are missing',
|
||||
function(){
|
||||
var expected2 = {};
|
||||
expected2[color_palette.palette_map_key(white)] = white;
|
||||
expected2[color_palette.palette_map_key(black)] = black;
|
||||
expected2[color_palette.palette_map_key(navy)] = blue;
|
||||
expected2[color_palette.palette_map_key(blue)] = blue;
|
||||
expected2[color_palette.palette_map_key(yellow)] = gold;
|
||||
expected2[color_palette.palette_map_key(gold)] = gold;
|
||||
assert.deepEqual(expected2, color_palette.map_palette(colors1, colors2));
|
||||
});
|
||||
it('should map white->black & black,navy,blue->yellow & yellow,gold->blue',
|
||||
function(){
|
||||
var expected3 = {};
|
||||
expected3[color_palette.palette_map_key(white)] = black;
|
||||
expected3[color_palette.palette_map_key(black)] = yellow;
|
||||
expected3[color_palette.palette_map_key(navy)] = yellow;
|
||||
expected3[color_palette.palette_map_key(blue)] = yellow;
|
||||
expected3[color_palette.palette_map_key(yellow)] = blue;
|
||||
expected3[color_palette.palette_map_key(gold)] = blue;
|
||||
assert.deepEqual(expected3, color_palette.map_palette(colors1, colors3, 'furthest'));
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
// Local Variables:
|
||||
// allout-layout: t
|
||||
// js-indent-level: 2
|
||||
// End:
|
Reference in New Issue
Block a user