color-space
Advanced tools
Comparing version 0.3.2 to 0.3.3
53
hwb.js
var rgb = require('./rgb'); | ||
var hsv = require('./hsv'); | ||
var hsl = require('./hsl'); | ||
var hwb = module.exports = { | ||
@@ -47,29 +50,25 @@ name: 'hwb', | ||
hsl: function(args) { | ||
return rgb.hsl(hwb.rgb(args)); | ||
}, | ||
hsv: function(args) { | ||
return rgb.hsv(hwb.rgb(args)); | ||
}, | ||
// http://alvyray.com/Papers/CG/HWB_JGTv208.pdf | ||
hsv: function(arg){ | ||
var h = arg[0], w = arg[1], b = arg[2], s, v; | ||
cmyk: function(args) { | ||
return rgb.cmyk(hwb.rgb(args)); | ||
}, | ||
//if w+b > 100% - take proportion (how many times ) | ||
if (w + b >= 100){ | ||
s = 0; | ||
v = 100 * w/(w+b); | ||
} | ||
//by default - take wiki formula | ||
else { | ||
s = 100-(w/(1-b/100)); | ||
v = 100-b; | ||
} | ||
xyz: function(args) { | ||
return rgb.xyz(hwb.rgb(args)); | ||
}, | ||
lab: function(arg) { | ||
return rgb.lab(hwb.rgb(arg)); | ||
return [h, s, v]; | ||
}, | ||
lch: function(arg) { | ||
return rgb.lch(hwb.rgb(arg)); | ||
}, | ||
luv: function(arg) { | ||
return rgb.luv(hwb.rgb(arg)); | ||
hsl: function(arg){ | ||
return hsv.hsl(hwb.hsv(arg)); | ||
} | ||
@@ -89,2 +88,16 @@ }; | ||
return [h, w * 100, b * 100]; | ||
}; | ||
//keep proper hue on 0 values (conversion to rgb loses hue on zero-lightness) | ||
hsv.hwb = function(arg){ | ||
var h = arg[0], s = arg[1], v = arg[2]; | ||
return [h, v === 0 ? 0 : (v * (1-s/100)), 100 - v]; | ||
}; | ||
//extend hsl with proper conversions | ||
hsl.hwb = function(arg){ | ||
return hsv.hwb(hsl.hsv(arg)); | ||
}; |
18
luv.js
@@ -6,4 +6,4 @@ var xyz = require('./xyz'); | ||
name: 'luv', | ||
min: [0,-100,-100], | ||
max: [100,100,100], | ||
min: [0,-134,-140], | ||
max: [100,224,122], | ||
channel: ['lightness', 'u', 'v'], | ||
@@ -36,9 +36,17 @@ alias: ['cieluv'], | ||
//wikipedia method | ||
y = l > 8 ? yn * Math.pow( (l + 16) / 116 , 3) : yn * l * k; | ||
x = y * 9 * _u / (4 * _v) || 0; | ||
z = y * (12 - 3 * _u - 20 * _v) / (4 * _v) || 0; | ||
x = y * 9 * _u / (4 * _v); | ||
//lindbloom method (needs checking) | ||
// var a = (52 * l / (u + 13 * l * un) - 1) / 3; | ||
// var b =-5 * y; | ||
// var c = -1/3; | ||
// var d = y * ( 39 * l /(v + 13 * l * vn) - 5); | ||
z = y * (12 - 3 * _u - 20 * _v) / (4 * _v); | ||
// x = (d-b) / (a-c); | ||
// y = l > k*e ? Math.pow( (l + 16) / 116 , 3) : l/k; | ||
// z = x*a + b; | ||
return [x, y, z]; | ||
@@ -45,0 +53,0 @@ } |
{ | ||
"name": "color-space", | ||
"description": "Math & data behind color spaces and color conversions.", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"author": "Deema Ywanow <dfcreative@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -37,3 +37,3 @@ # color-space [![Build Status](https://travis-ci.org/dfcreative/color-space.svg?branch=master)](https://travis-ci.org/dfcreative/color-space) | ||
Convert from one space to another: | ||
Convert one space to another: | ||
@@ -46,3 +46,3 @@ ```js | ||
Get space data: | ||
Space data: | ||
@@ -49,0 +49,0 @@ ```js |
@@ -1,2 +0,2 @@ | ||
var convert = require("../index"); | ||
var s = require("../index"); | ||
var assert = require("assert"); | ||
@@ -9,34 +9,10 @@ var round = require('mumath').round; | ||
//Check values here: http://www.easyrgb.com/index.php?X=CALC#Result | ||
//Check values here: | ||
// http://www.easyrgb.com/index.php?X=CALC#Result | ||
// http://colormine.org/convert/luv-to-rgb | ||
/** Tests */ | ||
describe('rgb', function(){ | ||
before(function(){ | ||
createSpaceCase('rgb'); | ||
}); | ||
it('to hsl', function(){ | ||
assert.deepEqual(round(convert.rgb.hsl([140, 200, 100])), [96, 48, 59]); | ||
}); | ||
it('to hsv', function(){ | ||
assert.deepEqual(round(convert.rgb.hsv([140, 200, 100])), [96, 50, 78]); | ||
}); | ||
it('to hwb', function(){ | ||
assert.deepEqual(round(convert.rgb.hwb([140, 200, 100])), [96, 39, 22]); | ||
}); | ||
it('to cmyk', function(){ | ||
assert.deepEqual(round(convert.rgb.cmyk([140, 200, 100])), [30, 0, 50, 22]); | ||
assert.deepEqual(round(convert.rgb.cmyk([0,0,0,1])), [0,0,0,100]); | ||
}); | ||
it('to xyz', function(){ | ||
assert.deepEqual(round(convert.rgb.xyz([92, 191, 84])), [25, 40, 15]); | ||
}); | ||
it('to lab', function(){ | ||
assert.deepEqual(round(convert.rgb.lab([92, 191, 84])), [70, -50, 45]); | ||
}); | ||
it('to lch', function(){ | ||
assert.deepEqual(round(convert.rgb.lch([92, 191, 84])), [70, 67, 138]); | ||
}); | ||
}); | ||
createSpaceCase('rgb'); | ||
//TODO: save hue on zero-saturation | ||
@@ -48,15 +24,14 @@ describe('hsl', function(){ | ||
it('to rgb', function(){ | ||
assert.deepEqual(round(convert.hsl.rgb([96, 48, 59])), [140, 201, 100]); | ||
it('hsl → rgb', function(){ | ||
assert.deepEqual(round(s.hsl.rgb([96, 48, 59])), [140, 201, 100]); | ||
}); | ||
it('to hsv', function(){ | ||
it('hsl → hsv', function(){ | ||
// colorpicker says [96,50,79] | ||
assert.deepEqual(round(convert.hsl.hsv([96, 48, 59])), [96, 50, 79]); | ||
assert.deepEqual(round(s.hsl.hsv([96, 48, 59])), [96, 50, 79]); | ||
}); | ||
it('to hwb', function(){ | ||
// computer round to 21, should be 22 | ||
assert.deepEqual(round(convert.hsl.hwb([96, 48, 59])), [96, 39, 21]); | ||
it('hsl → cmyk', function(){ | ||
assert.deepEqual(round(s.hsl.cmyk([96, 48, 59])), [30, 0, 50, 21]); | ||
}); | ||
it('to cmyk', function(){ | ||
assert.deepEqual(round(convert.hsl.cmyk([96, 48, 59])), [30, 0, 50, 21]); | ||
it('rgb → hsl', function(){ | ||
assert.deepEqual(round(s.rgb.hsl([140, 200, 100])), [96, 48, 59]); | ||
}); | ||
@@ -71,14 +46,14 @@ }); | ||
it('to rgb', function(){ | ||
assert.deepEqual(round(convert.hsv.rgb([96, 50, 78])), [139, 199, 99]); | ||
it('hsv → rgb', function(){ | ||
assert.deepEqual(round(s.hsv.rgb([96, 50, 78])), [139, 199, 99]); | ||
}); | ||
it('to hsl', function(){ | ||
assert.deepEqual(round(convert.hsv.hsl([96, 50, 78])), [96, 47, 59]); | ||
assert.deepEqual(round(convert.hsv.hsl([0,0,0])), [0,0,0]); | ||
it('hsv → hsl', function(){ | ||
assert.deepEqual(round(s.hsv.hsl([96, 50, 78])), [96, 47, 59]); | ||
assert.deepEqual(round(s.hsv.hsl([0,0,0])), [0,0,0]); | ||
}); | ||
it('to hwb', function(){ | ||
assert.deepEqual(round(convert.hsv.hwb([96, 50, 78])), [96, 39, 22]); | ||
it('hsv → cmyk', function(){ | ||
assert.deepEqual(round(s.hsv.cmyk([96, 50, 78])), [30, 0, 50, 22]); | ||
}); | ||
it('to cmyk', function(){ | ||
assert.deepEqual(round(convert.hsv.cmyk([96, 50, 78])), [30, 0, 50, 22]); | ||
it('rgb → hsv', function(){ | ||
assert.deepEqual(round(s.rgb.hsv([140, 200, 100])), [96, 50, 78]); | ||
}); | ||
@@ -91,5 +66,6 @@ }); | ||
createSpaceCase('hwb'); | ||
createSpaceCase('hsl'); | ||
}); | ||
it('to rgb', function(){ | ||
it('hwb → rgb', function(){ | ||
// hwb | ||
@@ -100,22 +76,64 @@ // http://dev.w3.org/csswg/css-color/#hwb-examples | ||
for(var angle = 0; angle <= 360; angle ++) { | ||
assert.deepEqual(round(convert.hwb.rgb([angle, 0, 100])), [0, 0, 0]); | ||
assert.deepEqual(round(convert.hwb.rgb([angle, 100, 0])), [255, 255, 255]); | ||
assert.deepEqual(round(convert.hwb.rgb([angle, 100, 100])), [128, 128, 128]); | ||
assert.deepEqual(round(s.hwb.rgb([angle, 0, 100])), [0, 0, 0]); | ||
assert.deepEqual(round(s.hwb.rgb([angle, 100, 0])), [255, 255, 255]); | ||
assert.deepEqual(round(s.hwb.rgb([angle, 100, 100])), [128, 128, 128]); | ||
} | ||
assert.deepEqual(round(convert.hwb.rgb([0, 0, 0])), [255,0,0]); | ||
assert.deepEqual(round(convert.hwb.rgb([0, 20, 40])), [153, 51, 51]); | ||
assert.deepEqual(round(convert.hwb.rgb([0, 40, 40])), [153, 102, 102]); | ||
assert.deepEqual(round(convert.hwb.rgb([0, 40, 20])), [204, 102, 102]); | ||
assert.deepEqual(round(s.hwb.rgb([0, 0, 0])), [255,0,0]); | ||
assert.deepEqual(round(s.hwb.rgb([0, 20, 40])), [153, 51, 51]); | ||
assert.deepEqual(round(s.hwb.rgb([0, 40, 40])), [153, 102, 102]); | ||
assert.deepEqual(round(s.hwb.rgb([0, 40, 20])), [204, 102, 102]); | ||
assert.deepEqual(round(convert.hwb.rgb([120, 0, 0])), [0,255,0]); | ||
assert.deepEqual(round(convert.hwb.rgb([120, 20, 40])), [51, 153, 51]); | ||
assert.deepEqual(round(convert.hwb.rgb([120, 40, 40])), [102, 153, 102]); | ||
assert.deepEqual(round(convert.hwb.rgb([120, 40, 20])), [102, 204, 102]); | ||
assert.deepEqual(round(s.hwb.rgb([120, 0, 0])), [0,255,0]); | ||
assert.deepEqual(round(s.hwb.rgb([120, 20, 40])), [51, 153, 51]); | ||
assert.deepEqual(round(s.hwb.rgb([120, 40, 40])), [102, 153, 102]); | ||
assert.deepEqual(round(s.hwb.rgb([120, 40, 20])), [102, 204, 102]); | ||
assert.deepEqual(round(convert.hwb.rgb([240, 0, 0])), [0,0,255]); | ||
assert.deepEqual(round(convert.hwb.rgb([240, 20, 40])), [51, 51, 153]); | ||
assert.deepEqual(round(convert.hwb.rgb([240, 40, 40])), [102, 102, 153]); | ||
assert.deepEqual(round(convert.hwb.rgb([240, 40, 20])), [102, 102, 204]); | ||
assert.deepEqual(round(s.hwb.rgb([240, 0, 0])), [0,0,255]); | ||
assert.deepEqual(round(s.hwb.rgb([240, 20, 40])), [51, 51, 153]); | ||
assert.deepEqual(round(s.hwb.rgb([240, 40, 40])), [102, 102, 153]); | ||
assert.deepEqual(round(s.hwb.rgb([240, 40, 20])), [102, 102, 204]); | ||
}); | ||
it('rgb → hwb', function(){ | ||
assert.deepEqual(round(s.rgb.hwb([140, 200, 100])), [96, 39, 22]); | ||
}); | ||
it('hsv → hwb', function(){ | ||
assert.deepEqual(round(s.hsv.hwb([10, 100, 0])), [10, 0, 100]); | ||
assert.deepEqual(round(s.hsv.hwb([20, 0, 0])), [20, 0, 100]); | ||
assert.deepEqual(round(s.hsv.hwb([30, 0, 100])), [30, 100, 0]); | ||
assert.deepEqual(round(s.hsv.hwb([40, 0, 100])), [40, 100, 0]); | ||
assert.deepEqual(round(s.hsv.hwb([96, 50, 78])), [96, 39, 22]); | ||
}); | ||
it('hwb → hsv', function(){ | ||
assert.deepEqual(round(s.hwb.hsv([0, 50, 100])), [0, 0, 33]); | ||
assert.deepEqual(round(s.hwb.hsv([0, 100, 50])), [0, 0, 67]); | ||
assert.deepEqual(round(s.hwb.hsv([96, 39, 22])), [96, 50, 78]); | ||
assert.deepEqual(round(s.hwb.hsv([20, 100, 0])), [20, 0, 100]); | ||
assert.deepEqual(round(s.hwb.hsv([20, 0, 0])), [20, 100, 100]); | ||
assert.deepEqual(round(s.hwb.hsv([2, 50, 50])), [2, 0, 50]); | ||
assert.deepEqual(round(s.hwb.hsv([2, 90, 90])), [2, 0, 50]); | ||
assert.deepEqual(round(s.hwb.hsv([2, 100, 100])), [2, 0, 50]); | ||
assert.deepEqual(round(s.hwb.hsv([0, 0, 100])), [0, 0, 0]); | ||
assert.deepEqual(round(s.hwb.hsv([0, 50, 50])), [0, 0, 50]); | ||
assert.deepEqual(round(s.hwb.hsv([0, 50, 100])), [0, 0, 33]); | ||
}); | ||
it('hwb → hsl', function(){ | ||
assert.deepEqual(round(s.hwb.hsl([20, 50, 50])), [20, 0, 50]); | ||
assert.deepEqual(round(s.hwb.hsl([20, 100, 100])), [20, 0, 50]); | ||
assert.deepEqual(round(s.hwb.hsl([20, 100, 100])), [20, 0, 50]); | ||
}); | ||
it('hsl → hwb', function(){ | ||
assert.deepEqual(round(s.hsl.hwb([20, 100, 0])), [20, 0, 100]); | ||
assert.deepEqual(round(s.hsl.hwb([20, 100, 50])), [20, 0, 0]); | ||
assert.deepEqual(round(s.hsl.hwb([20, 0, 50])), [20, 50, 50]); | ||
assert.deepEqual(round(s.hsl.hwb([20, 50, 100])), [20, 100, 0]); | ||
assert.deepEqual(round(s.hsl.hwb([96, 48, 59])), [96, 39, 21]); | ||
}); | ||
}); | ||
@@ -129,14 +147,19 @@ | ||
it('to rgb', function(){ | ||
assert.deepEqual(round(convert.cmyk.rgb([30, 0, 50, 22])), [139, 199, 99]); | ||
it('rgb → cmyk', function(){ | ||
assert.deepEqual(round(s.rgb.cmyk([140, 200, 100])), [30, 0, 50, 22]); | ||
assert.deepEqual(round(s.rgb.cmyk([0,0,0,1])), [0,0,0,100]); | ||
}); | ||
it('to hsl', function(){ | ||
assert.deepEqual(round(convert.cmyk.hsl([30, 0, 50, 22])), [96, 47, 59]); | ||
it('cmyk → rgb', function(){ | ||
assert.deepEqual(round(s.cmyk.rgb([30, 0, 50, 22])), [139, 199, 99]); | ||
}); | ||
it('to hsv', function(){ | ||
assert.deepEqual(round(convert.cmyk.hsv([30, 0, 50, 22])), [96, 50, 78]); | ||
it('cmyk → hsl', function(){ | ||
assert.deepEqual(round(s.cmyk.hsl([30, 0, 50, 22])), [96, 47, 59]); | ||
}); | ||
it('to hwb', function(){ | ||
assert.deepEqual(round(convert.cmyk.hwb([30, 0, 50, 22])), [96, 39, 22]); | ||
it('cmyk → hsv', function(){ | ||
assert.deepEqual(round(s.cmyk.hsv([30, 0, 50, 22])), [96, 50, 78]); | ||
}); | ||
// it('cmyk → hwb', function(){ | ||
// assert.deepEqual(round(s.cmyk.hwb([30, 0, 50, 22])), [96, 39, 22]); | ||
// }); | ||
}); | ||
@@ -151,12 +174,15 @@ | ||
//TODO: more tests here | ||
it('to rgb', function(){ | ||
assert.deepEqual(round(convert.xyz.rgb([25, 40, 15])), [97, 190, 85]); | ||
assert.deepEqual(round(convert.xyz.rgb([50, 100, 100])), [0, 255, 241]); | ||
it('xyz → rgb', function(){ | ||
assert.deepEqual(round(s.xyz.rgb([25, 40, 15])), [97, 190, 85]); | ||
assert.deepEqual(round(s.xyz.rgb([50, 100, 100])), [0, 255, 241]); | ||
}); | ||
it('to lab', function(){ | ||
assert.deepEqual(round(convert.xyz.lab([25, 40, 15])), [69, -48, 44]); | ||
it('xyz → lab', function(){ | ||
assert.deepEqual(round(s.xyz.lab([25, 40, 15])), [69, -48, 44]); | ||
}); | ||
it('to lch', function(){ | ||
assert.deepEqual(round(convert.xyz.lch([25, 40, 15])), [69, 65, 137]); | ||
it('xyz → lch', function(){ | ||
assert.deepEqual(round(s.xyz.lch([25, 40, 15])), [69, 65, 137]); | ||
}); | ||
it('rgb → xyz', function(){ | ||
assert.deepEqual(round(s.rgb.xyz([92, 191, 84])), [25, 40, 15]); | ||
}); | ||
}); | ||
@@ -170,11 +196,14 @@ | ||
it('to xyz', function(){ | ||
assert.deepEqual(round(convert.lab.xyz([69, -48, 44])), [25, 39, 15]); | ||
it('lab → xyz', function(){ | ||
assert.deepEqual(round(s.lab.xyz([69, -48, 44])), [25, 39, 15]); | ||
}); | ||
it('to rgb', function(){ | ||
assert.deepEqual(round(convert.lab.rgb([75, 20, -30])), [194, 175, 240]); | ||
it('lab → rgb', function(){ | ||
assert.deepEqual(round(s.lab.rgb([75, 20, -30])), [194, 175, 240]); | ||
}); | ||
it('to lch', function(){ | ||
assert.deepEqual(round(convert.lab.lch([69, -48, 44])), [69, 65, 137]); | ||
it('lab → lch', function(){ | ||
assert.deepEqual(round(s.lab.lch([69, -48, 44])), [69, 65, 137]); | ||
}); | ||
it('rgb → lab', function(){ | ||
assert.deepEqual(round(s.rgb.lab([92, 191, 84])), [70, -50, 45]); | ||
}); | ||
}); | ||
@@ -188,11 +217,14 @@ | ||
it('to lab', function(){ | ||
assert.deepEqual(round(convert.lch.lab([69, 65, 137])), [69, -48, 44]); | ||
it('lch → lab', function(){ | ||
assert.deepEqual(round(s.lch.lab([69, 65, 137])), [69, -48, 44]); | ||
}); | ||
it('to xyz', function(){ | ||
assert.deepEqual(round(convert.lch.xyz([69, 65, 137])), [25, 39, 15]); | ||
it('lch → xyz', function(){ | ||
assert.deepEqual(round(s.lch.xyz([69, 65, 137])), [25, 39, 15]); | ||
}); | ||
it('to rgb', function(){ | ||
assert.deepEqual(round(convert.lch.rgb([69, 65, 137])), [98, 188, 83]); | ||
it('lch → rgb', function(){ | ||
assert.deepEqual(round(s.lch.rgb([69, 65, 137])), [98, 188, 83]); | ||
}); | ||
it('rgb → lch', function(){ | ||
assert.deepEqual(round(s.rgb.lch([92, 191, 84])), [70, 67, 138]); | ||
}); | ||
}); | ||
@@ -206,32 +238,35 @@ | ||
it.skip('rgb → luv', function(){ | ||
assert.deepEqual(round(convert.rgb.luv([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(convert.rgb.luv([10, 0, 0])), [1, 2, 0]); | ||
assert.deepEqual(round(convert.rgb.luv([100, 0, 0])), [19, 62, 13]); | ||
assert.deepEqual(round(convert.rgb.luv([255, 0, 0])), [53, 175, 38]); | ||
assert.deepEqual(round(convert.rgb.luv([0, 255, 0])), [88, -83, 107]); | ||
assert.deepEqual(round(convert.rgb.luv([0, 0, 255])), [32, -9, -130]); | ||
assert.deepEqual(round(convert.rgb.luv([0, 255, 255])), [91, -70, -15]); | ||
assert.deepEqual(round(convert.rgb.luv([255, 255, 255])), [100, 0, 0]); | ||
it('rgb → luv', function(){ | ||
assert.deepEqual(round(s.rgb.luv([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(s.rgb.luv([10, 0, 0])), [1, 2, 0]); | ||
assert.deepEqual(round(s.rgb.luv([100, 0, 0])), [19, 62, 13]); | ||
assert.deepEqual(round(s.rgb.luv([255, 0, 0])), [53, 175, 38]); | ||
assert.deepEqual(round(s.rgb.luv([0, 255, 0])), [88, -83, 107]); | ||
assert.deepEqual(round(s.rgb.luv([0, 0, 255])), [32, -9, -130]); | ||
assert.deepEqual(round(s.rgb.luv([0, 255, 255])), [91, -70, -15]); | ||
assert.deepEqual(round(s.rgb.luv([255, 255, 255])), [100, 0, 0]); | ||
}); | ||
it.skip('luv → rgb', function(){ | ||
it('luv → rgb', function(){ | ||
assert.deepEqual(round(s.luv.rgb([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(s.luv.rgb([0, -134, -140])), [0, 0, 0]); | ||
assert.deepEqual(round(s.luv.rgb([90, 128, 100])), [255, 189, 0]); | ||
assert.deepEqual(round(s.luv.rgb([50, -134, 122])), [0, 159, 0]); | ||
}); | ||
it('xyz → luv', function(){ | ||
assert.deepEqual(round(convert.xyz.luv([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(convert.xyz.luv([95, 100, 100])), [100, 3, 9]); | ||
assert.deepEqual(round(convert.xyz.luv([50, 50, 50])), [76, 13, 5]); | ||
assert.deepEqual(round(convert.xyz.luv([100, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(convert.xyz.luv([0, 100, 0])), [100, -257, 171]); | ||
assert.deepEqual(round(convert.xyz.luv([0, 0, 100])), [0, 0, 0]); | ||
assert.deepEqual(round(convert.xyz.luv([95, 0, 100])), [0, 0, 0]); | ||
assert.deepEqual(round(s.xyz.luv([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(s.xyz.luv([95, 100, 100])), [100, 3, 9]); | ||
assert.deepEqual(round(s.xyz.luv([50, 50, 50])), [76, 13, 5]); | ||
assert.deepEqual(round(s.xyz.luv([100, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(s.xyz.luv([0, 100, 0])), [100, -257, 171]); | ||
assert.deepEqual(round(s.xyz.luv([0, 0, 100])), [0, 0, 0]); | ||
assert.deepEqual(round(s.xyz.luv([95, 0, 100])), [0, 0, 0]); | ||
}); | ||
it('luv → xyz', function(){ | ||
assert.deepEqual(round(convert.luv.xyz([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(convert.luv.xyz([50, -50, -50])), [13, 18, 45]); | ||
assert.deepEqual(round(convert.luv.xyz([50, 50, 50])), [21, 18, 2]); | ||
assert.deepEqual(round(convert.luv.xyz([100, 0, 0])), [95, 100, 109]); | ||
assert.deepEqual(round(s.luv.xyz([0, 0, 0])), [0, 0, 0]); | ||
assert.deepEqual(round(s.luv.xyz([50, -50, -50])), [13, 18, 45]); | ||
assert.deepEqual(round(s.luv.xyz([50, 50, 50])), [21, 18, 2]); | ||
assert.deepEqual(round(s.luv.xyz([100, 0, 0])), [95, 100, 109]); | ||
}); | ||
@@ -248,9 +283,9 @@ }); | ||
assert.deepEqual(round( | ||
convert.lchuv.luv(convert.luv.lchuv([0, 0, 0]))), [0, 0, 0]); | ||
s.lchuv.luv(s.luv.lchuv([0, 0, 0]))), [0, 0, 0]); | ||
assert.deepEqual(round( | ||
convert.lchuv.luv(convert.luv.lchuv([50, -50, -50]))), [50, -50, -50]); | ||
s.lchuv.luv(s.luv.lchuv([50, -50, -50]))), [50, -50, -50]); | ||
assert.deepEqual(round( | ||
convert.lchuv.luv(convert.luv.lchuv([50, 50, 50]))), [50, 50, 50]); | ||
s.lchuv.luv(s.luv.lchuv([50, 50, 50]))), [50, 50, 50]); | ||
assert.deepEqual(round( | ||
convert.lchuv.luv(convert.luv.lchuv([100, 0, 0]))), [100, 0, 0]); | ||
s.lchuv.luv(s.luv.lchuv([100, 0, 0]))), [100, 0, 0]); | ||
}); | ||
@@ -257,0 +292,0 @@ }); |
11
xyz.js
@@ -11,2 +11,3 @@ var rgb = require('./rgb'); | ||
//observer/illuminant | ||
// http://en.wikipedia.org/wiki/Standard_illuminant | ||
//http://www.easyrgb.com/index.php?X=MATH&H=15#text15 | ||
@@ -18,2 +19,3 @@ //Xn, Yn, Zn | ||
A:[109.85, 100, 35.585], | ||
// B:[], | ||
C: [98.074, 100, 118.232], | ||
@@ -26,5 +28,14 @@ D50: [96.422, 100, 82.521], | ||
//flourescent | ||
// F1: [], | ||
F2: [99.187, 100, 67.395], | ||
// F3: [], | ||
// F4: [], | ||
// F5: [], | ||
// F6:[], | ||
F7: [95.044, 100, 108.755], | ||
// F8: [], | ||
// F9: [], | ||
// F10: [], | ||
F11: [100.966, 100, 64.370], | ||
// F12: [], | ||
E: [100,100,100] | ||
@@ -31,0 +42,0 @@ }, |
Sorry, the diff of this file is not supported yet
229457
8027