chromaticity-color-utilities
Advanced tools
Comparing version 0.2.5-alpha to 0.2.6-alpha
@@ -252,4 +252,5 @@ "use strict"; | ||
normalize: this.normalized, | ||
colorSpace: this.colorSpace, | ||
referenceWhite: this.referenceWhite, | ||
// Don't pass the following or the color will shift | ||
// colorSpace: this.colorSpace, | ||
// referenceWhite: this.referenceWhite, | ||
kb: this.kb, | ||
@@ -256,0 +257,0 @@ kr: this.kr, |
@@ -927,3 +927,3 @@ "use strict"; | ||
var b = m[2][1] * xyz.x + m[2][1] * xyz.y + m[2][2] * xyz.z; | ||
if (xyz.colorSpace == 'srgb') { | ||
if (colorSpace == 'srgb') { | ||
// sRGB | ||
@@ -934,3 +934,3 @@ r = r <= 0.0031308 ? r * 12.92 : Math.pow((r * 1.055), 1 / 2.4) - 0.055; | ||
} | ||
else if (xyz.colorSpace == 'ecirgb') { | ||
else if (colorSpace == 'ecirgb') { | ||
// L* | ||
@@ -943,8 +943,8 @@ r = r <= Reference_1.cieE ? (r * Reference_1.cieK) / 100 : 1.16 * Math.pow(r, 1 / 3) - 0.16; | ||
// Gamma | ||
if (typeof Reference_1.colorSpaces[xyz.colorSpace]['gamma'] == 'undefined') { | ||
if (typeof space['gamma'] == 'undefined') { | ||
throw new Error('Gamma not defined for this color space'); | ||
} | ||
r = Math.pow(r, 1 / Reference_1.colorSpaces[xyz.colorSpace]['gamma']); | ||
g = Math.pow(g, 1 / Reference_1.colorSpaces[xyz.colorSpace]['gamma']); | ||
b = Math.pow(b, 1 / Reference_1.colorSpaces[xyz.colorSpace]['gamma']); | ||
r = Math.pow(r, 1 / space['gamma']); | ||
g = Math.pow(g, 1 / space['gamma']); | ||
b = Math.pow(b, 1 / space['gamma']); | ||
} | ||
@@ -1031,3 +1031,2 @@ var max = (Math.pow(2, bitDepth)) - 1; | ||
} | ||
console.log(w, l, a, b); | ||
return new Colors.lab(l, a, b); | ||
@@ -1084,2 +1083,3 @@ }; | ||
var v = 13 * l * (vp - vpr); | ||
l = Math.min(Math.max(l, 0), 100); | ||
if (round) { | ||
@@ -1086,0 +1086,0 @@ l = Math.round(l); |
@@ -54,2 +54,4 @@ "use strict"; | ||
switch (type) { | ||
case 'hex': | ||
return new Colors.hex(value); | ||
case 'nm': | ||
@@ -56,0 +58,0 @@ case 'light': |
{ | ||
"name": "chromaticity-color-utilities", | ||
"version": "0.2.5-alpha", | ||
"version": "0.2.6-alpha", | ||
"description": "Color utilities for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -1,2 +0,2 @@ | ||
# <img src="https://github.com/reiniiriarios/chromaticity-color-utilities/raw/main/docs/chromaticity-icon-01.png" width="26" height="26"> chromaticity-color-utilities | ||
# <img src="https://reiniiriarios.github.io/chromaticity-color-utilities/assets/images/chromaticity-icon-01.png" width="26" height="26"> chromaticity-color-utilities | ||
@@ -34,7 +34,7 @@ Color utilities for Node.js. | ||
let color6 = Color.from('hex', 'ff00ff').to('lab') | ||
let color6 = Color.from('hex', '#ff00ff').to('lab') | ||
// defaulting to sRGB color space with a D65 standard illuminant reference white | ||
// lab { l: 95, a: 142, b: -88 } | ||
let color6 = Color.from('hex', 'ff00ff').to('lab',{ | ||
let color6 = Color.from('hex', 0xFF00FF).to('lab',{ | ||
colorSpace: 'AdobeRGB', | ||
@@ -41,0 +41,0 @@ referenceWhite: 'D50' |
258329
6075