it('ypbpr ←→ xvycc', function () { assert.deepEqual(round(s.ypbpr.xvycc([1, -0.5, -0.5]), 0.001), [235, 16, 16]); assert.deepEqual(round(s.ypbpr.xvycc([1, 0.5, 0.5]), 0.001), [235, 240, 240]); assert.deepEqual(round(s.xvycc.ypbpr([235, 16, 16]), 0.001), [1, -0.5, -0.5]); assert.deepEqual(round(s.xvycc.ypbpr([235, 240, 240]), 0.001), [1, 0.5, 0.5]); });
it('xyy → osaucs', function () { //TODO: fix test according to the paper // assert.deepEqual(round(s.xyz.osaucs([33.71, 26.46, 46.66])), [0,-4,-4]); assert.deepEqual(round(s.xyz.osaucs([33.71, 26.46, 46.66])), [0,-4,-5]); // assert.deepEqual(round(s.xyz.osaucs([1.773902, 1.049996, 7.893570])), [-8,-6,+2]); assert.deepEqual(round(s.xyz.osaucs([1.773902, 1.049996, 7.893570])), [-8,-7,+1]); });
it('ycgco → rgb', function () { assert.deepEqual(round(s.ycgco.rgb([0, 0, 0])), [0, 0, 0]); assert.deepEqual(round(s.ycgco.rgb([1, 0, 0])), [255, 255, 255]); assert.deepEqual(round(s.ycgco.rgb([0.25, -0.25, 0.5])), [255, 0, 0]); assert.deepEqual(round(s.ycgco.rgb(s.rgb.ycgco([10,20,30]))), [10,20,30]); });
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]); });
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('ypbpr ←→ ycbcr', function () { assert.deepEqual(round(s.ypbpr.ycbcr([1, -0.5, -0.5]), 0.001), [235, 16, 16]); assert.deepEqual(round(s.ypbpr.ycbcr([1, 0.5, 0.5]), 0.001), [235, 240, 240]); assert.deepEqual(round(s.ycbcr.ypbpr([235, 16, 16]), 0.001), [1, -0.5, -0.5]); assert.deepEqual(round(s.ycbcr.ypbpr([235, 240, 240]), 0.001), [1, 0.5, 0.5]); });
it('coloroid → xyz', function () { assert.deepEqual(round(s.coloroid.xyz([21, 39, 70]), 1), [56, 49.0, 19]); assert.deepEqual(round(s.coloroid.xyz([61, 0, 90]), 1), [81, 81, 84]); assert.deepEqual(round(s.coloroid.xyz([35, 10, 90]), 1), [85, 81, 86]); //coloroid looses color info via binding hue // assert.deepEqual(round(s.coloroid.xyz(s.xyz.coloroid([10,20,30]))), [10,20,30]); });
it('rgb → yccbccrc', function () { assert.deepEqual(round(s.rgb.yccbccrc([0, 0, 0]), 0.001), [0, 0, 0]); assert.deepEqual(round(s.rgb.yccbccrc([127, 127, 127]), 0.01), [0.5, 0, 0]); assert.deepEqual(round(s.rgb.yccbccrc([255, 255, 255]), 0.001), [1, 0, 0]); // assert.deepEqual(round(s.rgb.yccbccrc([0, 255, 0]), 0.001), [0.715, -0.385, -0.454]); // assert.deepEqual(round(s.rgb.yccbccrc([255, 0, 0]), 0.001), [0.213, -0.115, 0.5]); });
it('luv ←→ lchuv', function () { assert.deepEqual(round( s.lchuv.luv(s.luv.lchuv([0, 0, 0]))), [0, 0, 0]); assert.deepEqual(round( s.lchuv.luv(s.luv.lchuv([50, -50, -50]))), [50, -50, -50]); assert.deepEqual(round( s.lchuv.luv(s.luv.lchuv([50, 50, 50]))), [50, 50, 50]); assert.deepEqual(round( s.lchuv.luv(s.luv.lchuv([100, 0, 0]))), [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('rgb → labh', function () { assert.deepEqual(round(s.rgb.labh([0, 0, 0])), [0, 0, 0]); assert.deepEqual(round(s.rgb.labh([10, 0, 0]), .1), [2.5, 4.3, 1.6]); assert.deepEqual(round(s.rgb.labh([100, 0, 0]), .1), [16.5, 28.2, 10.6]); assert.deepEqual(round(s.rgb.labh([255, 0, 0]), .1), [46.1, 78.9, 29.8]); assert.deepEqual(round(s.rgb.labh([0, 255, 0]), .1), [84.6, -72.5, 50.8]); assert.deepEqual(round(s.rgb.labh([0, 0, 255]), .1), [26.9, 72.9, -190.9]); assert.deepEqual(round(s.rgb.labh([0, 255, 255]), .1), [88.7, -47, -9.4]); assert.deepEqual(round(s.rgb.labh([255, 255, 255]), .1), [100, -5.3, 5.4]); });
it('xyz → luv', function () { assert.deepEqual(round(s.xyz.luv([0, 0, 0])), [0, 0, 0]); assert.deepEqual(round(s.xyz.luv([95, 100, 100]),.1), [100, 3.5, 8.6]); 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('hcg → rgb', function () { assert.deepEqual(round(s.hcg.rgb([ 0, 100, 0 ])), [255, 0, 0]); assert.deepEqual(round(s.hcg.rgb([ 0, 50, 0 ])), [128, 0, 0]); assert.deepEqual(round(s.hcg.rgb([ 0, 50, 100 ])), [255, 128, 128]); assert.deepEqual(round(s.hcg.rgb([ 0, 50, 50 ])), [191, 64, 64]); assert.deepEqual(round(s.hcg.rgb([ 0, 0, 100 ])), [255, 255, 255]); assert.deepEqual(round(s.hcg.rgb([ 0, 0, 50 ])), [128, 128, 128]); assert.deepEqual(round(s.hcg.rgb([ 0, 0, 0 ])), [0, 0, 0]); });
it('rgb → hcg', function () { assert.deepEqual(round(s.rgb.hcg([255, 0, 0])), [ 0, 100, 0 ]); assert.deepEqual(round(s.rgb.hcg([128, 0, 0])), [ 0, 50, 0 ]); assert.deepEqual(round(s.rgb.hcg([255, 128, 128])),[ 0, 50, 100 ] ); assert.deepEqual(round(s.rgb.hcg([192, 64, 64])), [ 0, 50, 50 ]); assert.deepEqual(round(s.rgb.hcg([255, 255, 255])), [ 0, 0, 100 ]); assert.deepEqual(round(s.rgb.hcg([128, 128, 128])), [ 0, 0, 50 ]); assert.deepEqual(round(s.rgb.hcg([ 0, 0, 0 ])), [0, 0, 0]); });
it('_hsluv: lch → rgb ≡ lchuv → rgb', function () { assert.deepEqual( max(round(mult(hsluv.lchToRgb([1,20,40]), 255), .001), 0), max(round(s.lchuv.rgb([1,20,40]), .001), 0) ); assert.deepEqual( max(round(mult(hsluv.lchToRgb([25,30,43]), 255), .001), 0), max(round(s.lchuv.rgb([25,30,43]), .001), 0) ); assert.deepEqual( max(round(mult(hsluv.lchToRgb([33,40,50]), 255), .001), 0), max(round(s.lchuv.rgb([33,40,50]), .001), 0) ); });
it('_hsluv: xyz → rgb ≡ xyz → rgb', function () { assert.deepEqual( round( max(mult(hsluv.xyzToRgb(div([33,40,50], 100)), 255), 0), .0001 ), round(s.xyz.rgb([33,40,50]), .0001) ); assert.deepEqual( round( max(mult(hsluv.xyzToRgb(div([1,20,40], 100)), 255), 0), .0001 ), round(s.xyz.rgb([1,20,40]), .0001) ); assert.deepEqual( round( max(mult(hsluv.xyzToRgb(div([25,30,43], 100)), 255), 0), .0001 ), round(s.xyz.rgb([25,30,43]), .0001) ); });
it('hsp → rgb', function () { assert.deepEqual(round(s.hsp.rgb([0.2, 0.5, 0.3])), [0, 0, 0]); });
it('xyz → coloroid', function () { assert.deepEqual(round(s.xyz.coloroid([54.64, 64.0, 18.26]), 1), [10, 48, 80]); assert.deepEqual(round(s.xyz.coloroid([54.2, 49.0, 17.6]), 1), [21, 39, 70]); });
it('rgb → hsv', function () { assert.deepEqual(round(s.rgb.hsv([140, 200, 100])), [96, 50, 78]); });
it('uvw → xyz', function () { // assert.deepEqual(round(s.uvw.xyz([0, 0, 0])), [0, 0, 0]); // assert.deepEqual(round(s.uvw.xyz([1, 0, 0])), [1, 1, 1]); assert.deepEqual(round(s.uvw.xyz(s.xyz.uvw([10,20,30]))), [10,20,30]); });
it('ycbcr → rgb', function () { assert.deepEqual(round(s.ycbcr.rgb([16, 128, 128])), [0, 0, 0]); assert.deepEqual(round(s.ycbcr.rgb([235, 128, 128])), [255, 255, 255]); assert.deepEqual(round(s.ycbcr.rgb(s.rgb.ycbcr([10,20,30]))), [10,20,30]); });
it('rgb → jpeg', function () { assert.deepEqual(round(s.rgb.jpeg([0, 0, 0]), 0.001), [0, 128, 128]); assert.deepEqual(round(s.rgb.jpeg([255, 255, 255]), 0.001), [255, 128, 128]); });
it('jpeg → rgb', function () { assert.deepEqual(round(s.jpeg.rgb([0, 128, 128])), [0, 0, 0]); assert.deepEqual(round(s.jpeg.rgb([255, 128, 128])), [255, 255, 255]); assert.deepEqual(round(s.jpeg.rgb(s.rgb.jpeg([10,20,30]))), [10,20,30]); });
it('yccbccrc → rgb', function () { assert.deepEqual(round(s.yccbccrc.rgb([0, 0, 0])), [0, 0, 0]); // assert.deepEqual(round(s.yccbccrc.rgb([0.715, -0.385, -0.454])), [0, 255, 0]); assert.deepEqual(round(s.yccbccrc.rgb([1, 0, 0])), [255, 255, 255]); assert.deepEqual(round(s.yccbccrc.rgb(s.rgb.yccbccrc([0.10,0.20,0.30])), 0.001), [0.10,0.20,0.30]); });
it('rgb → xvycc', function () { assert.deepEqual(round(s.rgb.xvycc([0, 0, 0]), 0.001), [16, 128, 128]); assert.deepEqual(round(s.rgb.xvycc([255, 255, 255]), 0.001), [235, 128, 128]); });
it('xvycc → rgb', function () { assert.deepEqual(round(s.xvycc.rgb([16, 128, 128])), [0, 0, 0]); assert.deepEqual(round(s.xvycc.rgb([235, 128, 128])), [255, 255, 255]); assert.deepEqual(round(s.xvycc.rgb(s.rgb.xvycc([10,20,30]))), [10,20,30]); });
it('rgb → hsp', function () { assert.deepEqual(round(s.rgb.hsp([98, 115, 255])), [234, 62, 134]); });
it('hsv → cmyk', function () { assert.deepEqual(round(s.hsv.cmyk([96, 50, 78])), [30, 0, 50, 22]); });
it('rgb → hsp', function () { assert.deepEqual(round(s.rgb.hsp([110, 110, 110])), [0, 0, 110]); });
it('hsv → hsl', function () { assert.deepEqual(round(s.hsv.hsl([96, 50, 78])), [96, 47, 59]); //keep hue assert.deepEqual(round(s.hsv.hsl([120,0,0])), [120,0,0]); });