Sha256: 5bbf3cb76c5cf6c8c690569bad0f7eef1c3e05ef24649b2104b761d250e8e069

Contents?: true

Size: 883 Bytes

Versions: 2

Compression:

Stored size: 883 Bytes

Contents

/*global INCLUDE, installColorSpace, ONECOLOR*/
INCLUDE('lib:color.js');
INCLUDE('lib:color/XYZ.js');

installColorSpace('LAB', ['l', 'a', 'b', 'alpha'], {
    fromRgb: function () {
        return this.xyz().lab();
    },

    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;

        return new ONECOLOR.XYZ(
            convert(x) *  95.047,
            convert(y) * 100.000,
            convert(z) * 108.883,
            this._alpha
        );
    }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pleeease-0.0.3 node_modules/pleeease/node_modules/csswring/node_modules/onecolor/lib/color/LAB.js
pleeease-0.0.2 node_modules/pleeease/node_modules/csswring/node_modules/onecolor/lib/color/LAB.js