color-space
Advanced tools
Comparing version 1.11.2 to 1.12.0
@@ -28,2 +28,4 @@ /** | ||
yccbccrc: require('./yccbccrc'), | ||
ucs: require('./ucs'), | ||
uvw: require('./uvw'), | ||
jpeg: require('./jpeg'), | ||
@@ -30,0 +32,0 @@ lab: require('./lab'), |
@@ -17,3 +17,3 @@ /** | ||
channel: ['lightness', 'chroma', 'hue'], | ||
alias: ['LCHab', 'cielch', 'LCH', 'HLC'], | ||
alias: ['LCHab', 'cielch', 'LCH', 'HLC', 'LSH'], | ||
@@ -20,0 +20,0 @@ xyz: function(arg) { |
@@ -18,3 +18,3 @@ /** | ||
channel: ['lightness', 'u', 'v'], | ||
alias: ['LUV', 'cieluv'], | ||
alias: ['LUV', 'cieluv', 'cie1976'], | ||
@@ -21,0 +21,0 @@ xyz: function(arg, i, o){ |
{ | ||
"name": "color-space", | ||
"description": "Color space conversions and data", | ||
"version": "1.11.2", | ||
"version": "1.12.0", | ||
"author": "Deema Yvanow <dfcreative@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -69,3 +69,4 @@ # 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) | ||
* [x] [XvYCC](https://en.wikipedia.org/wiki/XvYCC) | ||
* [ ] [UVW](https://en.wikipedia.org/wiki/CIE_1964_color_space) | ||
* [x] [UCS](https://en.wikipedia.org/wiki/CIE_1960_color_space) | ||
* [x] [UVW](https://en.wikipedia.org/wiki/CIE_1964_color_space) | ||
* [ ] [Munsell](https://en.wikipedia.org/wiki/Munsell_color_system) | ||
@@ -72,0 +73,0 @@ * [ ] [NCS](https://en.wikipedia.org/wiki/Natural_Color_System) |
98
uvw.js
/** | ||
* https://en.wikipedia.org/?title=UVW | ||
* https://en.wikipedia.org/wiki/CIE_1964_color_space | ||
* | ||
* Very similar to LUV, but w and v are calculated a bit differently. | ||
* | ||
* @module color-space/uvw | ||
*/ | ||
var rgb = require('./rgb'); | ||
var ucs = require('./ucs'); | ||
var xyz = require('./xyz'); | ||
var uvw = module.exports = { | ||
name: 'uvw', | ||
min: [0,-0.5,-0.5], | ||
max: [1, 0.5, 0.5], | ||
min: [-134,-140, 0], | ||
max: [224,122, 100], | ||
channel: ['U','V','W'], | ||
alias: ['UVW'] | ||
alias: ['UVW', 'cieuvw', 'cie1964'] | ||
}; | ||
@@ -19,10 +22,74 @@ | ||
/** | ||
* UVW to RGB | ||
* UVW to XYZ | ||
*/ | ||
uvw.xyz = function (arg, i, o) { | ||
var _u, _v, w, u, v, x, y, z, xn, yn, zn, un, vn; | ||
u = arg[0], v = arg[1], w = arg[2]; | ||
if (w === 0) return [0,0,0]; | ||
//get illuminant/observer | ||
i = i || 'D65'; | ||
o = o || 2; | ||
xn = xyz.whitepoint[o][i][0]; | ||
yn = xyz.whitepoint[o][i][1]; | ||
zn = xyz.whitepoint[o][i][2]; | ||
un = (4 * xn) / (xn + (15 * yn) + (3 * zn)); | ||
vn = (6 * yn) / (xn + (15 * yn) + (3 * zn)); | ||
y = Math.pow((w + 17) / 25, 3); | ||
_u = u / (13 * w) + un || 0; | ||
_v = v / (13 * w) + vn || 0; | ||
x = (6 / 4) * y * _u / _v; | ||
z = y * (2 / _v - 0.5 * _u / _v - 5); | ||
return [x, y, z]; | ||
}; | ||
/** | ||
* XYZ to UVW | ||
* | ||
* @param {Array} uvw RGB values | ||
* @return {Array} An UVW array | ||
*/ | ||
xyz.uvw = function (arr, i, o) { | ||
var x = arr[0], y = arr[1], z = arr[2], xn, yn, zn; | ||
//find out normal source u v | ||
i = i || 'D65'; | ||
o = o || 2; | ||
xn = xyz.whitepoint[o][i][0]; | ||
yn = xyz.whitepoint[o][i][1]; | ||
zn = xyz.whitepoint[o][i][2]; | ||
un = (4 * xn) / (xn + (15 * yn) + (3 * zn)); | ||
vn = (6 * yn) / (xn + (15 * yn) + (3 * zn)); | ||
var _u = 4 * x / (x + 15 * y + 3 * z) || 0; | ||
var _v = 6 * y / (x + 15 * y + 3 * z) || 0; | ||
//calc values | ||
var w = 25 * Math.pow(y, 1/3) - 17; | ||
var u = 13 * w * (_u - un); | ||
var v = 13 * w * (_v - vn); | ||
return [u, v, w]; | ||
}; | ||
/** | ||
* UVW to UCS | ||
* | ||
* @param {Array} uvw UCS values | ||
* | ||
* @return {Array} UVW values | ||
*/ | ||
uvw.rgb = function(uvw) { | ||
uvw.ucs = function(uvw) { | ||
//find chromacity variables | ||
}; | ||
@@ -32,10 +99,17 @@ | ||
/** | ||
* RGB to UVW | ||
* UCS to UVW | ||
* | ||
* @param {Array} uvw UVW values | ||
* | ||
* @return {Array} RGB values | ||
* @return {Array} UCS values | ||
*/ | ||
rgb.uvw = function(rgb) { | ||
ucs.uvw = function(ucs) { | ||
//find chromacity variables | ||
var u = U / (U + V + W); | ||
var v = V / (U + V + W); | ||
//find 1964 UVW | ||
w = 25 * Math.pow(y, 1/3) - 17; | ||
u = 13 * w * (u - un); | ||
v = 13 * w * (v - vn); | ||
}; |
@@ -28,4 +28,2 @@ /** | ||
//extend xyz | ||
xyz.xyy = function(arg) { | ||
@@ -32,0 +30,0 @@ var sum, X, Y, Z; |
@@ -14,3 +14,3 @@ /** | ||
channel: ['X','Y','Z'], | ||
alias: ['XYZ', 'ciexyz'], | ||
alias: ['XYZ', 'ciexyz', 'cie1931'], | ||
@@ -63,2 +63,3 @@ //whitepoint with observer/illuminant | ||
rgb: function(xyz) { | ||
@@ -65,0 +66,0 @@ var x = xyz[0] / 100, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97634
36
3158
102