Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 1.12.0 to 1.13.0

coloroid.js

3

index.js

@@ -39,3 +39,4 @@ /**

huslp: require('./huslp'),
cubehelix: require('./cubehelix')
cubehelix: require('./cubehelix'),
coloroid: require('./coloroid')
};

@@ -42,0 +43,0 @@

{
"name": "color-space",
"description": "Color space conversions and data",
"version": "1.12.0",
"version": "1.13.0",
"author": "Deema Yvanow <dfcreative@gmail.com>",

@@ -23,3 +23,6 @@ "keywords": [

"color-translation",
"color-data"
"color-data",
"coloroid",
"cubehelix",
"munsell"
],

@@ -37,9 +40,10 @@ "repository": {

"husl": ">=5.0",
"mumath": "^1.0.2",
"queried": "^1.4.1"
"mumath": "^1.0.2"
},
"devDependencies": {
"queried": "^1.4.1",
"browserify": "^6.x",
"closurecompiler": "^1.x",
"mocha": "*",
"browserify": "^6.x",
"closurecompiler": "^1.x"
"watchify": "^3.4.0"
},

@@ -50,4 +54,4 @@ "scripts": {

"min": "ccjs dist/color-space.js --language_in=ECMASCRIPT5 > dist/color-space.min.js && cat dist/color-space.min.js | gzip-size | pretty-bytes",
"build-test": "browserify -r ./index:../index -r husl -r assert -r mumath -r queried -d > test/bundle.js"
"watch": "watchify -r ./index:../index -r husl -r assert -r mumath -r queried -d -o test/bundle.js"
}
}

@@ -77,13 +77,10 @@ # Color-space [![Build Status](https://travis-ci.org/dfcreative/color-space.svg?branch=master)](https://travis-ci.org/dfcreative/color-space) [![Code Climate](https://codeclimate.com/github/dfcreative/color-space/badges/gpa.svg)](https://codeclimate.com/github/dfcreative/color-space) [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

* [ ] [RG](https://en.wikipedia.org/wiki/RG_color_space)
* [ ] [Coloroid](https://en.wikipedia.org/wiki/Coloroid)
* [x] [Coloroid](https://en.wikipedia.org/wiki/Coloroid)
* [ ] [OSA-UCS](https://en.wikipedia.org/wiki/OSA-UCS)
* [ ] [HKS](https://en.wikipedia.org/wiki/HKS_(colour_system))
* [x] [LMS](http://en.wikipedia.org/wiki/LMS_color_space)
* [x] [cubehelix](https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)
* [ ] [gray](http://dev.w3.org/csswg/css-color/#grays)
* [x] [Cubehelix](https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)
* [ ] [Gray](http://dev.w3.org/csswg/css-color/#grays)
* [ ] [CIECAM02](https://en.wikipedia.org/wiki/CIECAM02)
* [ ] [ITU](http://www.jentronics.com/color.html)
* [ ] [REC709](http://www.jentronics.com/color.html)
* [ ] [SMTPE](http://www.jentronics.com/color.html)
* [ ] [NTSC](http://www.jentronics.com/color.html)
* [ ] [GREY](http://www.jentronics.com/color.html)
* [ ] [PhotoYCC](http://www5.informatik.tu-muenchen.de/lehre/vorlesungen/graphik/info/csc/COL_34.htm)

@@ -97,2 +94,11 @@

## Related projects
* [color2](https://www.npmjs.com/package/color2) — color class based on color-space.
* [color-ranger](https://www.npmjs.com/package/color-ranger) — visualize color spaces using canvas.
* [color-tool](https://www.npmjs.com/package/color-tool) — color picker based on color-space.
* [color-measure](https://www.npmjs.com/package/color-measure) — list of color measurement functions.
* [color-manipulate](https://www.npmjs.com/package/color-manipulate) — list of color manipulation functions.
## Similar projects

@@ -104,1 +110,2 @@

* [colorspaces.js](https://github.com/boronine/colorspaces.js)

@@ -14,4 +14,4 @@ /**

name: 'uvw',
min: [-134,-140, 0],
max: [224,122, 100],
min: [-134, -140, 0],
max: [224, 122, 100],
channel: ['U','V','W'],

@@ -60,3 +60,3 @@ alias: ['UVW', 'cieuvw', 'cie1964']

xyz.uvw = function (arr, i, o) {
var x = arr[0], y = arr[1], z = arr[2], xn, yn, zn;
var x = arr[0], y = arr[1], z = arr[2], xn, yn, zn, un, vn;

@@ -63,0 +63,0 @@ //find out normal source u v

/**
* https://en.wikipedia.org/wiki/XvYCC
*
* xvYCC is extended YCC
* Sony xvYCC is extended YCbCr
*

@@ -6,0 +6,0 @@ * It uses same transformation as

/**
* Additional xyY space.
* Additional xyY space, where xy are relative chromacity params
*

@@ -8,3 +8,3 @@ * @module color-space/xyy

module.exports = {
var xyy = {
name: 'xyy',

@@ -14,15 +14,14 @@ min: [0,0,0],

channel: ['x','y','Y'],
alias: ['xyY', 'Yxy', 'yxy'],
alias: ['xyY', 'Yxy', 'yxy']
};
// 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];
xyy.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];
};

@@ -38,2 +37,4 @@

return [X / sum, Y / sum, Y];
};
};
module.exports = xyy;

@@ -9,86 +9,105 @@ /**

var xyz = module.exports = {
var xyz = {
name: 'xyz',
min: [0,0,0],
max: [96,100,109],
channel: ['X','Y','Z'],
alias: ['XYZ', 'ciexyz', 'cie1931'],
alias: ['XYZ', 'ciexyz', 'cie1931']
};
//whitepoint with observer/illuminant
// http://en.wikipedia.org/wiki/Standard_illuminant
whitepoint: {
2: {
//incadescent
A:[109.85, 100, 35.585],
// B:[],
C: [98.074, 100, 118.232],
D50: [96.422, 100, 82.521],
D55: [95.682, 100, 92.149],
//daylight
D65: [95.045592705167, 100, 108.9057750759878],
D75: [94.972, 100, 122.638],
//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]
},
10: {
//incadescent
A:[111.144, 100, 35.200],
C: [97.285, 100, 116.145],
D50: [96.720, 100, 81.427],
D55: [95.799, 100, 90.926],
//daylight
D65: [94.811, 100, 107.304],
D75: [94.416, 100, 120.641],
//flourescent
F2: [103.280, 100, 69.026],
F7: [95.792, 100, 107.687],
F11: [103.866, 100, 65.627],
E: [100,100,100]
}
/**
* Whitepoint reference values with observer/illuminant
*
* http://en.wikipedia.org/wiki/Standard_illuminant
*/
xyz.whitepoint = {
//1931 2°
2: {
//incadescent
A:[109.85, 100, 35.585],
// B:[],
C: [98.074, 100, 118.232],
D50: [96.422, 100, 82.521],
D55: [95.682, 100, 92.149],
//daylight
D65: [95.045592705167, 100, 108.9057750759878],
D75: [94.972, 100, 122.638],
//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]
},
//1964 10°
10: {
//incadescent
A:[111.144, 100, 35.200],
C: [97.285, 100, 116.145],
D50: [96.720, 100, 81.427],
D55: [95.799, 100, 90.926],
//daylight
D65: [94.811, 100, 107.304],
D75: [94.416, 100, 120.641],
//flourescent
F2: [103.280, 100, 69.026],
F7: [95.792, 100, 107.687],
F11: [103.866, 100, 65.627],
E: [100,100,100]
}
};
rgb: function(xyz) {
var x = xyz[0] / 100,
y = xyz[1] / 100,
z = xyz[2] / 100,
r, g, b;
// assume sRGB
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293);
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175);
b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878);
/**
* Top values are the whitepoint’s top values, default are D65
*/
xyz.max = xyz.whitepoint[2].D65;
r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
: r = (r * 12.92);
g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
: g = (g * 12.92);
/**
* Transform xyz to rgb
*
* @param {Array} xyz Array of xyz values
*
* @return {Array} RGB values
*/
xyz.rgb = function (xyz) {
var x = xyz[0] / 100,
y = xyz[1] / 100,
z = xyz[2] / 100,
r, g, b;
b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
: b = (b * 12.92);
// assume sRGB
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293);
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175);
b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878);
r = Math.min(Math.max(0, r), 1);
g = Math.min(Math.max(0, g), 1);
b = Math.min(Math.max(0, b), 1);
r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
: r = (r * 12.92);
return [r * 255, g * 255, b * 255];
}
};
g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
: g = (g * 12.92);
b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
: b = (b * 12.92);
r = Math.min(Math.max(0, r), 1);
g = Math.min(Math.max(0, g), 1);
b = Math.min(Math.max(0, b), 1);
return [r * 255, g * 255, b * 255];
}
/**

@@ -116,2 +135,6 @@ * RGB to XYZ

return [x * 100, y *100, z * 100];
};
};
module.exports = xyz;

@@ -14,3 +14,3 @@ /**

channel: ['Y','U','V'],
alias: ['YUV'],
alias: ['YUV', 'EBU'],

@@ -17,0 +17,0 @@ rgb: function(yuv) {

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