color-space
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -17,2 +17,3 @@ /** | ||
/** Default options for space */ | ||
@@ -32,7 +33,8 @@ var defaults = cubehelix.defaults = { | ||
/** | ||
* cubehelix to RGB | ||
* Transform cubehelix level to RGB | ||
* | ||
* @param {Array} cubehelix RGB values | ||
* @param {Number} fraction 0..1 cubehelix level | ||
* @param {Object} options Mapping options, overrides defaults | ||
* | ||
* @return {Array} cubehelix values | ||
* @return {Array} rgb tuple | ||
*/ | ||
@@ -42,2 +44,4 @@ cubehelix.rgb = function(fraction, options) { | ||
if (fraction.length) fraction = fraction[0]; | ||
var start = options.start !== undefined ? options.start : defaults.start; | ||
@@ -69,8 +73,8 @@ var rotation = options.rotation !== undefined ? options.rotation : defaults.rotation; | ||
* | ||
* @param {Array} cubehelix cubehelix values | ||
* @param {Array} rgb RGB values | ||
* | ||
* @return {Array} RGB values | ||
* @return {Array} cubehelix fraction(s) | ||
*/ | ||
rgb.cubehelix = function(rgb) { | ||
//TODO - there’re no backwise conversion yet | ||
//TODO - there is no backwise conversion yet | ||
}; |
@@ -24,2 +24,3 @@ /** | ||
labh: require('./labh'), | ||
lms: require('./lms'), | ||
lchab: require('./lchab'), | ||
@@ -26,0 +27,0 @@ luv: require('./luv'), |
54
lms.js
@@ -21,26 +21,26 @@ /** | ||
/* | ||
//transform matrices | ||
transform: { | ||
// hunt–pointer–estevez | ||
rlab: [ | ||
matrix: { | ||
HPE: [ | ||
0.38971, 0.68898,-0.07868, | ||
-0.22981, 1.18340, 0.04641, | ||
0.00000, 0.00000, 1.00000], | ||
rlabD65: [ | ||
VONKRIES: [ | ||
0.4002, 0.7076, -0.0808, | ||
-0.2263, 1.1653, 0.0457, | ||
0.00000,0.00000, 0.9182], | ||
cmccat97: [ | ||
BFD: [ | ||
0.8951, 0.2664,-0.1614, | ||
-0.7502, 1.7135, 0.0367, | ||
0.0389,-0.0686, 1.0296], | ||
cat97: [ | ||
CAT97: [ | ||
0.8562, 0.3372,-0.1934, | ||
-0.8360, 1.8327, 0.0033, | ||
0.0357,-0.00469,1.0112], | ||
cat00: [ | ||
CAT00: [ | ||
0.7982, 0.3389,-0.1371, | ||
-0.5918, 1.5512, 0.0406, | ||
0.0008, 0.0239, 0.9753], | ||
cat02: [ | ||
CAT02: [ | ||
0.7328, 0.4296,-0.1624, | ||
@@ -50,15 +50,19 @@ -0.7036, 1.6975, 0.0061, | ||
}, | ||
*/ | ||
//m - a matrix | ||
xyz: function(arg, m){ | ||
var x = arg[0], y = arg[1], z = arg[2]; | ||
xyz: function(arg, matrix){ | ||
var l = arg[0], m = arg[1], s = arg[2]; | ||
if (!m) { | ||
m = lms.transform[cat02]; | ||
if (!matrix) { | ||
matrix = [ | ||
1.096123820835514, -0.278869000218287, +0.182745179382773, | ||
0.454369041975359, + 0.473533154307412, +0.072097803717229, | ||
-0.009627608738429, -0.005698031216113, +1.015325639954543 | ||
]; | ||
} | ||
return [ | ||
x * m[0] + y * m[1] + z * m[2], | ||
x * m[3] + y * m[4] + z * m[5], | ||
x * m[6] + y * m[7] + z * m[8] | ||
l * matrix[0] + m * matrix[1] + s * matrix[2], | ||
l * matrix[3] + m * matrix[4] + s * matrix[5], | ||
l * matrix[6] + m * matrix[7] + s * matrix[8] | ||
]; | ||
@@ -68,6 +72,18 @@ } | ||
xyz.lms = function(arg, i, o) { | ||
//TODO | ||
xyz.lms = function(arg, matrix) { | ||
var x = arg[0], y = arg[1], z = arg[2]; | ||
return [l, u, v]; | ||
if (!matrix) { | ||
matrix = [ | ||
0.7328, 0.4296,-0.1624, | ||
-0.7036, 1.6975, 0.0061, | ||
0.0030, 0.0136, 0.9834 | ||
]; | ||
} | ||
return [ | ||
x * matrix[0] + y * matrix[1] + z * matrix[2], | ||
x * matrix[3] + y * matrix[4] + z * matrix[5], | ||
x * matrix[6] + y * matrix[7] + z * matrix[8] | ||
]; | ||
}; |
{ | ||
"name": "color-space", | ||
"description": "Color space conversions and data", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": "Deema Yvanow <dfcreative@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -10,3 +10,3 @@ # 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) | ||
[![NPM](https://nodei.co/npm/color-space.png?mini=true)](https://nodei.co/npm/color-space/) | ||
[![npm install color-space](https://nodei.co/npm/color-space.png?mini=true)](https://npmjs.org/package/color-space/) | ||
@@ -42,3 +42,2 @@ ```js | ||
xyz.whitepoint //list of whitepoint references | ||
lms.transform //list of transform matrices | ||
``` | ||
@@ -80,3 +79,3 @@ | ||
* [ ] [HKS](https://en.wikipedia.org/wiki/HKS_(colour_system)) | ||
* [ ] [LMS](http://en.wikipedia.org/wiki/LMS_color_space). | ||
* [x] [LMS](http://en.wikipedia.org/wiki/LMS_color_space). | ||
* [x] [cubehelix](https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/) | ||
@@ -83,0 +82,0 @@ * [ ] [gray](http://dev.w3.org/csswg/css-color/#grays) |
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
88297
2764
100