Socket
Socket
Sign inDemoInstall

color-space

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-space - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

color-space.js

29

cmyk.js

@@ -20,31 +20,2 @@ var rgb = require('./rgb');

return [r * 255, g * 255, b * 255];
},
hsl: function(args) {
return rgb.hsl(cmyk.rgb(args));
},
hsv: function(args) {
return rgb.hsv(cmyk.rgb(args));
},
hwb: function(args) {
return rgb.hwb(cmyk.rgb(args));
},
xyz: function(arg) {
return rgb.xyz(cmyk.rgb(arg));
},
lab: function(arg) {
return rgb.lab(cmyk.rgb(arg));
},
lch: function(arg) {
return rgb.lch(cmyk.rgb(arg));
},
luv: function(arg) {
return rgb.luv(cmyk.rgb(arg));
}

@@ -51,0 +22,0 @@ };

3

index.js

@@ -11,4 +11,5 @@ //TODO: specify exact lchuv/luv limits

xyz: require('./xyz'),
xyy: require('./xyy'),
lab: require('./lab'),
lch: require('./lch'),
lchab: require('./lchab'),
lchuv: require('./lchuv'),

@@ -15,0 +16,0 @@ luv: require('./luv'),

{
"name": "color-space",
"description": "Math & data behind color spaces and color conversions.",
"version": "0.4.0",
"version": "0.5.0",
"author": "Deema Yvanow <dfcreative@gmail.com>",

@@ -40,5 +40,5 @@ "repository": {

"test": "mocha",
"build": "browserify --standalone color ./index.js > dist/color.js",
"min": "ccjs dist/color.js --language_in=ECMASCRIPT5 > dist/color.min.js && cat dist/color.min.js | gzip-size | pretty-bytes",
"build-test": "browserify -r assert -r mumath -r query-relative -r ./index.js:../index > test/test.bundle.js"
"build": "browserify --standalone color-space ./index.js > color-space.js",
"min": "ccjs color-space.js --language_in=ECMASCRIPT5 --compilation_level=ADVANCED > color-space.min.js && cat color-space.min.js | gzip-size | pretty-bytes",
"build-test": "browserify -r assert -r mumath -r query-relative > test/test.bundle.js"
},

@@ -45,0 +45,0 @@ "dependencies": {

@@ -1,8 +0,12 @@

# color-space [![Build Status](https://travis-ci.org/dfcreative/color-space.svg?branch=master)](https://travis-ci.org/dfcreative/color-space)
# Color-space [![Build Status](https://travis-ci.org/dfcreative/color-space.svg?branch=master)](https://travis-ci.org/dfcreative/color-space)
Math and data behind color spaces and color conversions. _Color-space_ provides uniform interface to all known color-spaces. [Converter & tests](https://cdn.rawgit.com/dfcreative/color-space/master/test/index.html).
[![NPM](https://nodei.co/npm/color-space.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/color-space/)
Math and data behind color spaces and color conversions. _Color-space_ provides uniform interface to all known color spaces: RGB, HSl, HSV (HSB), [HWB](http://dev.w3.org/csswg/css-color/#the-hwb-notation), CMYK, [XYZ](http://en.wikipedia.org/wiki/CIE_1931_color_space), XYY (YXY), [LAB](http://en.wikipedia.org/wiki/Lab_color_space), LCH<sub>ab</sub>, [LUV](http://en.wikipedia.org/wiki/CIELUV), [LCH<sub>uv</sub>](http://en.wikipedia.org/wiki/CIELUV#Cylindrical_representation), [H<sub>u</sub>SL](http://www.boronine.com/husl/), [H<sub>u</sub>SL<sub>p</sub>](http://www.boronine.com/husl/).
#### [Converter demo](https://cdn.rawgit.com/dfcreative/color-space/master/test/index.html)
# Use

@@ -12,3 +16,3 @@

To include all spaces:
Include all spaces:

@@ -49,30 +53,16 @@ ```js

```js
*.name //space name
*.min //channel minimums
*.max //channel maximums
*.channel //channel names
*.alias //alias space names, if any
space.name //space name
space.min //channel minimums
space.max //channel maximums
space.channel //channel names
space.alias //alias space names, if any
xyz.whitepoint //list of whitepoint references
```
Available spaces:
* rgb
* hsl
* hsv (hsb)
* hwb
* cmyk
* xyz ([CIE XYZ](http://en.wikipedia.org/wiki/CIE_1931_color_space))
* lab ([CIE Lab](http://en.wikipedia.org/wiki/Lab_color_space))
* lch (CIE LCHab&thinsp;—&thinsp;cylindrical LAB)
* luv ([CIE Luv](http://en.wikipedia.org/wiki/CIELUV))
* lchuv ([CIE LCHuv](http://en.wikipedia.org/wiki/CIELUV#Cylindrical_representation))
* [husl](http://www.boronine.com/husl/), [huslp](http://www.boronine.com/husl/)
# Contribute
Please fork, add color space & basic conversions (to/from XYZ or RGB), tests.
Please fork, add color space & basic conversions (to/from XYZ or RGB), tests. _Color-space_ is supposed to be a basic library to work with color conversions, an extended replacement for [color-convert](https://github.com/harthur/color-convert).
<a href="http://unlicense.org/UNLICENSE"><img src="http://upload.wikimedia.org/wikipedia/commons/6/62/PD-icon.svg" width="40"/></a>

@@ -19,4 +19,3 @@ var s = require("../index");

//these two are basic spaces
createSpaceCase('rgb');
createSpaceCase('xyz');
createSpaceCase('RGB');

@@ -27,3 +26,3 @@

before(function(){
createSpaceCase('hsl');
createSpaceCase('HSL');
});

@@ -49,3 +48,3 @@

before(function(){
createSpaceCase('hsv');
createSpaceCase('HSV');
});

@@ -71,4 +70,4 @@

before(function(){
createSpaceCase('hwb');
createSpaceCase('hsl');
createSpaceCase('HWB');
createSpaceCase('HSL');
});

@@ -149,3 +148,3 @@

before(function(){
createSpaceCase('cmyk');
createSpaceCase('CMYK');
});

@@ -175,3 +174,3 @@

before(function(){
createSpaceCase('xyz');
createSpaceCase('XYZ');
});

@@ -187,4 +186,4 @@

});
it('xyz → lch', function(){
assert.deepEqual(round(s.xyz.lch([25, 40, 15])), [69, 65, 137]);
it('xyz → lchab', function(){
assert.deepEqual(round(s.xyz.lchab([25, 40, 15])), [69, 65, 137]);
});

@@ -197,5 +196,24 @@ it('rgb → xyz', function(){

describe('xyY', function(){
before(function(){
createSpaceCase('XYZ');
createSpaceCase('xyY');
});
//TODO: more tests here
it('xyz → xyy', function(){
assert.deepEqual(round(s.xyz.xyy([0, 0, 0])), [0, 0, 0]);
assert.deepEqual(round(s.xyz.xyy([25, 40, 15]), .01), [.31, .5, 40]);
assert.deepEqual(round(s.xyz.xyy([50, 100, 100]), .01), [0.2, .4, 100]);
});
it('xyy → xyz', function(){
assert.deepEqual(round(s.xyy.xyz([.40, .15, 25]), .1), [66.7, 25, 75]);
});
});
describe('lab', function(){
before(function(){
createSpaceCase('lab');
createSpaceCase('XYZ');
createSpaceCase('LAB');
});

@@ -209,4 +227,4 @@

});
it('lab → lch', function(){
assert.deepEqual(round(s.lab.lch([69, -48, 44])), [69, 65, 137]);
it('lab → lchab', function(){
assert.deepEqual(round(s.lab.lchab([69, -48, 44])), [69, 65, 137]);
});

@@ -219,18 +237,19 @@ it('rgb → lab', function(){

describe('lch', function(){
describe('lchab', function(){
before(function(){
createSpaceCase('lch');
createSpaceCase('XYZ');
createSpaceCase('LCHab');
});
it('lch → lab', function(){
assert.deepEqual(round(s.lch.lab([69, 65, 137])), [69, -48, 44]);
it('lchab → lab', function(){
assert.deepEqual(round(s.lchab.lab([69, 65, 137])), [69, -48, 44]);
});
it('lch → xyz', function(){
assert.deepEqual(round(s.lch.xyz([69, 65, 137])), [25, 39, 15]);
it('lchab → xyz', function(){
assert.deepEqual(round(s.lchab.xyz([69, 65, 137])), [25, 39, 15]);
});
it('lch → rgb', function(){
assert.deepEqual(round(s.lch.rgb([69, 65, 137])), [98, 188, 83]);
it('lchab → rgb', function(){
assert.deepEqual(round(s.lchab.rgb([69, 65, 137])), [98, 188, 83]);
});
it('rgb → lch', function(){
assert.deepEqual(round(s.rgb.lch([92, 191, 84])), [70, 67, 138]);
it('rgb → lchab', function(){
assert.deepEqual(round(s.rgb.lchab([92, 191, 84])), [70, 67, 138]);
});

@@ -242,3 +261,4 @@ });

before(function(){
createSpaceCase('luv');
createSpaceCase('XYZ');
createSpaceCase('LUV');
});

@@ -284,3 +304,4 @@

before(function(){
createSpaceCase('lchuv');
createSpaceCase('XYZ');
createSpaceCase('LCHuv');
});

@@ -303,3 +324,4 @@

before(function(){
createSpaceCase('husl');
createSpaceCase('XYZ');
createSpaceCase('HuSL');
});

@@ -368,3 +390,4 @@

before(function(){
createSpaceCase('huslp');
createSpaceCase('XYZ');
createSpaceCase('HuSLP');
});

@@ -384,2 +407,3 @@

before(function(){
createSpaceCase('XYZ');
createSpaceCase('ciecam');

@@ -386,0 +410,0 @@ });

@@ -1,12 +0,20 @@

var rgb = require('./rgb');
var xyz = require('./xyz');
var xyz = module.exports = {
var xyy = module.exports = {
name: 'xyy',
min: [0,0,0],
max: [96,100,109],
max: [1,1,100],
channel: ['x','y','Y'],
alias: ['yxy'],
alias: ['Yxy', 'xyY', 'yxy'],
//TODO: fix this maths so to return 255,255,255 in rgb
// https://github.com/boronine/colorspaces.js/blob/master/colorspaces.js#L128
xyz: function(arg) {
var _X, _Y, _Z, _x, _y;
_x = arg[0], _y = arg[1], _Y = arg[2];
if (_y === 0) {
return [0, 0, 0];
}
_X = _x * _Y / _y;
_Z = (1 - _x - _y) * _Y / _y;
return [_X, _Y, _Z];
}

@@ -16,5 +24,11 @@ };

//extend rgb
//extend xyz
xyz.xyy = function(arg) {
var sum, _X, _Y, _Z;
_X = arg[0], _Y = arg[1], _Z = arg[2];
sum = _X + _Y + _Z;
if (sum === 0) {
return [0, 0, _Y];
}
return [_X / sum, _Y / sum, _Y];
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc