chromaticity-color-utilities
Advanced tools
Comparing version 0.2.9-alpha to 0.3.0-alpha
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -69,3 +69,3 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
if (hex.charAt(0) == '#') { | ||
hex = hex.substr(1); | ||
hex = hex.substring(1); | ||
} | ||
@@ -76,3 +76,8 @@ if (!/[0-9A-Fa-f]/g.test(hex)) { | ||
if (hex.length == 3) { | ||
hex = hex.split('').map(function (hex) { return hex + hex; }).join(''); | ||
hex = hex | ||
.split('') | ||
.map(function (hex) { | ||
return hex + hex; | ||
}) | ||
.join(''); | ||
} | ||
@@ -104,3 +109,3 @@ else if (hex.length != 6) { | ||
_this.valueRangeCheck(bitDepth, 1, false, 'Bit depth must be a positive number greater than 1'); | ||
var max = (Math.pow(2, bitDepth)) - 1; | ||
var max = Math.pow(2, bitDepth) - 1; | ||
if (typeof a == 'undefined') | ||
@@ -140,3 +145,3 @@ a = max; | ||
} | ||
var max = (Math.pow(2, bitDepth)) - 1; | ||
var max = Math.pow(2, bitDepth) - 1; | ||
// this.valueRangeCheck(r, 0, max) | ||
@@ -186,3 +191,3 @@ // this.valueRangeCheck(g, 0, max) | ||
} | ||
var max = (Math.pow(2, bitDepth)) - 1; | ||
var max = Math.pow(2, bitDepth) - 1; | ||
// this.valueRangeCheck(r, 0, max) | ||
@@ -446,5 +451,5 @@ // this.valueRangeCheck(g, 0, max) | ||
var _this = _super.call(this) || this; | ||
_this.valueRangeCheck(x, 0, 1, 'XYZ values must be between 0 and 1'); | ||
_this.valueRangeCheck(y, 0, 1, 'XYZ values must be between 0 and 1'); | ||
_this.valueRangeCheck(z, 0, 1, 'XYZ values must be between 0 and 1'); | ||
// this.valueRangeCheck(x, 0, 1, 'XYZ values must be between 0 and 1') | ||
// this.valueRangeCheck(y, 0, 1, 'XYZ values must be between 0 and 1') | ||
// this.valueRangeCheck(z, 0, 1, 'XYZ values must be between 0 and 1') | ||
_this.x = x; | ||
@@ -585,3 +590,6 @@ _this.y = y; | ||
ypbpr.prototype.toycbcr = function (args) { | ||
if (typeof args.yLower === 'undefined' || typeof args.yUpper === 'undefined' || typeof args.cLower === 'undefined' || typeof args.cUpper === 'undefined') { | ||
if (typeof args.yLower === 'undefined' || | ||
typeof args.yUpper === 'undefined' || | ||
typeof args.cLower === 'undefined' || | ||
typeof args.cUpper === 'undefined') { | ||
throw new Error('Missing arguments yLower, yUpper, cLower, cUpper'); | ||
@@ -588,0 +596,0 @@ } |
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -126,3 +126,3 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
cUpper: this.cUpper, | ||
gamma: this.gamma | ||
gamma: this.gamma, | ||
}; | ||
@@ -271,3 +271,3 @@ var ogalpha = this.a; | ||
cUpper: this.cUpper, | ||
gamma: this.gamma | ||
gamma: this.gamma, | ||
}; | ||
@@ -309,3 +309,6 @@ var ogalpha = this.a; | ||
} | ||
distance = typeof args.distanceToBlack === 'undefined' ? args.distance : args.distanceToBlack; | ||
distance = | ||
typeof args.distanceToBlack === 'undefined' | ||
? args.distance | ||
: args.distanceToBlack; | ||
intScheme = Harmony_1.default.shade(this.to('hsl', { round: false }), args.colors, distance); | ||
@@ -319,3 +322,6 @@ break; | ||
} | ||
distance = typeof args.distanceToWhite === 'undefined' ? args.distance : args.distanceToWhite; | ||
distance = | ||
typeof args.distanceToWhite === 'undefined' | ||
? args.distance | ||
: args.distanceToWhite; | ||
intScheme = Harmony_1.default.tint(this.to('hsl', { round: false }), args.colors, distance); | ||
@@ -332,3 +338,6 @@ break; | ||
} | ||
distance = typeof args.distanceToWhite === 'undefined' ? args.distance : args.distanceToWhite; | ||
distance = | ||
typeof args.distanceToWhite === 'undefined' | ||
? args.distance | ||
: args.distanceToWhite; | ||
intScheme = Harmony_1.default.shadetint(this.to('hsl', { round: false }), args.colors, distance, args.distanceToBlack); | ||
@@ -376,2 +385,3 @@ break; | ||
colorType.prototype.torgb = function (args) { | ||
// always override | ||
var rgbOverridden = new Colors.rgb(0, 0, 0); | ||
@@ -454,3 +464,4 @@ return rgbOverridden; | ||
args = {}; | ||
else if (typeof args.bitDepth === 'undefined' && typeof args.bitRate !== 'undefined') { | ||
else if (typeof args.bitDepth === 'undefined' && | ||
typeof args.bitRate !== 'undefined') { | ||
args.bitDepth = args.bitRate; | ||
@@ -473,6 +484,9 @@ } | ||
} | ||
if (lowerLimit !== false && upperLimit !== false && lowerLimit >= upperLimit) { | ||
if (lowerLimit !== false && | ||
upperLimit !== false && | ||
lowerLimit >= upperLimit) { | ||
throw new Error('Invalid range (lower limit must exceed upper limit)'); | ||
} | ||
if ((lowerLimit !== false && value < lowerLimit) || (upperLimit !== false && value > upperLimit)) { | ||
if ((lowerLimit !== false && value < lowerLimit) || | ||
(upperLimit !== false && value > upperLimit)) { | ||
throw new Error(typeof msg !== 'undefined' ? msg : 'Color value out of range'); | ||
@@ -479,0 +493,0 @@ } |
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -58,6 +58,3 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
var hueComplement = Modify_1.default.hueShift(hsv.h, 180); | ||
return [ | ||
hsv, | ||
new Colors.hsv(hueComplement, hsv.s, hsv.v) | ||
]; | ||
return [hsv, new Colors.hsv(hueComplement, hsv.s, hsv.v)]; | ||
}; | ||
@@ -121,3 +118,3 @@ /** | ||
new Colors.hsv(hue3, hsv.s, hsv.v), | ||
new Colors.hsv(hue4, hsv.s, hsv.v) | ||
new Colors.hsv(hue4, hsv.s, hsv.v), | ||
]; | ||
@@ -150,3 +147,3 @@ }; | ||
for (var i = 0; i < colors; i++) { | ||
var nextL = Math.max(hsl.l - (separation * i), 0); | ||
var nextL = Math.max(hsl.l - separation * i, 0); | ||
hsls.push(new Colors.hsl(hsl.h, hsl.s, nextL)); | ||
@@ -168,6 +165,6 @@ } | ||
var start = hsl.l; | ||
var end = hsl.l + ((100 - hsl.l) * Math.min(Math.max(distanceToWhite, 0), 1)); | ||
var end = hsl.l + (100 - hsl.l) * Math.min(Math.max(distanceToWhite, 0), 1); | ||
var separation = (end - start) / (colors - 1); | ||
for (var i = 0; i < colors; i++) { | ||
var nextL = Math.min(hsl.l + (separation * i), 100); | ||
var nextL = Math.min(hsl.l + separation * i, 100); | ||
hsls.push(new Colors.hsl(hsl.h, hsl.s, nextL)); | ||
@@ -192,3 +189,3 @@ } | ||
if (100 - hsl.l < hsl.l) { | ||
tEnd = hsl.l + ((100 - hsl.l) * Math.min(Math.max(distance, 0), 1)); | ||
tEnd = hsl.l + (100 - hsl.l) * Math.min(Math.max(distance, 0), 1); | ||
tSeparation = (tEnd - hsl.l) / colors; | ||
@@ -206,3 +203,3 @@ sSeparation = tSeparation; | ||
else { | ||
tEnd = hsl.l + ((100 - hsl.l) * Math.min(Math.max(distance, 0), 1)); | ||
tEnd = hsl.l + (100 - hsl.l) * Math.min(Math.max(distance, 0), 1); | ||
tSeparation = (tEnd - hsl.l) / colors; | ||
@@ -213,3 +210,3 @@ sEnd = hsl.l * (1 - Math.min(Math.max(distanceShade, 0), 1)); | ||
for (var i = 0; i < colors; i++) { | ||
var nextL = Math.max(sEnd + (sSeparation * i), 0); | ||
var nextL = Math.max(sEnd + sSeparation * i, 0); | ||
hsls.push(new Colors.hsl(hsl.h, hsl.s, nextL)); | ||
@@ -219,3 +216,3 @@ } | ||
for (var i = 1; i <= colors; i++) { | ||
var nextL = Math.min(hsl.l + (tSeparation * i), 100); | ||
var nextL = Math.min(hsl.l + tSeparation * i, 100); | ||
hsls.push(new Colors.hsl(hsl.h, hsl.s, nextL)); | ||
@@ -222,0 +219,0 @@ } |
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -50,3 +50,4 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
args = {}; | ||
if (typeof args.bitDepth === 'undefined' && typeof args.bitRate !== 'undefined') { | ||
if (typeof args.bitDepth === 'undefined' && | ||
typeof args.bitRate !== 'undefined') { | ||
args.bitDepth = args.bitRate; | ||
@@ -86,3 +87,3 @@ } | ||
if (typeof value[3] === 'undefined') | ||
value[3] = (Math.pow(2, args.bitDepth)) - 1; | ||
value[3] = Math.pow(2, args.bitDepth) - 1; | ||
return new Colors.rgb(value[0], value[1], value[2], value[3], args.bitDepth); | ||
@@ -96,3 +97,3 @@ case 'rec709': | ||
if (typeof value[3] === 'undefined') | ||
value[3] = (Math.pow(2, args.bitDepth)) - 1; | ||
value[3] = Math.pow(2, args.bitDepth) - 1; | ||
return new Colors.rec709rgb(value[0], value[1], value[2], value[3], args.bitDepth); | ||
@@ -106,3 +107,3 @@ case 'rec2020': | ||
if (typeof value[3] === 'undefined') | ||
value[3] = (Math.pow(2, args.bitDepth)) - 1; | ||
value[3] = Math.pow(2, args.bitDepth) - 1; | ||
return new Colors.rec2020rgb(value[0], value[1], value[2], value[3], args.bitDepth); | ||
@@ -155,2 +156,2 @@ case 'hsv': | ||
}()); | ||
module.exports = new Color; | ||
module.exports = new Color(); |
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -75,6 +75,6 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
amount = Math.min(Math.max(amount, 0), 1); | ||
var r3 = rgb1.r + ((rgb2.r - rgb1.r) * amount); | ||
var g3 = rgb1.g + ((rgb2.g - rgb1.g) * amount); | ||
var b3 = rgb1.b + ((rgb2.b - rgb1.b) * amount); | ||
var a3 = rgb1.a + ((rgb2.a - rgb1.a) * amount); | ||
var r3 = rgb1.r + (rgb2.r - rgb1.r) * amount; | ||
var g3 = rgb1.g + (rgb2.g - rgb1.g) * amount; | ||
var b3 = rgb1.b + (rgb2.b - rgb1.b) * amount; | ||
var a3 = rgb1.a + (rgb2.a - rgb1.a) * amount; | ||
if (round) { | ||
@@ -111,5 +111,5 @@ r3 = Math.round(r3); | ||
var h3 = this.hueShift(hsv1.h, hueDiff); | ||
var s3 = hsv1.s + ((hsv2.s - hsv1.s) * amount); | ||
var v3 = hsv1.v + ((hsv2.v - hsv1.v) * amount); | ||
var a3 = hsv1.a + ((hsv2.a - hsv1.a) * amount); | ||
var s3 = hsv1.s + (hsv2.s - hsv1.s) * amount; | ||
var v3 = hsv1.v + (hsv2.v - hsv1.v) * amount; | ||
var a3 = hsv1.a + (hsv2.a - hsv1.a) * amount; | ||
if (round) { | ||
@@ -136,3 +136,3 @@ h3 = Math.round(h3); | ||
var realAmount = Math.min(Math.max(amount, 0), 1); | ||
var vLighter = hsl.l + ((100 - hsl.l) * realAmount); | ||
var vLighter = hsl.l + (100 - hsl.l) * realAmount; | ||
if (round) | ||
@@ -155,3 +155,3 @@ vLighter = Math.round(vLighter); | ||
var realAmount = Math.min(Math.max(amount, 0), 1); | ||
var pLighter = hsp.p + ((100 - hsp.p) * realAmount); | ||
var pLighter = hsp.p + (100 - hsp.p) * realAmount; | ||
if (round) | ||
@@ -174,3 +174,3 @@ pLighter = Math.round(pLighter); | ||
var realAmount = 1 - Math.min(Math.max(amount, 0), 1); | ||
var sMore = hsl.s + ((100 - hsl.s) * realAmount); | ||
var sMore = hsl.s + (100 - hsl.s) * realAmount; | ||
if (round) | ||
@@ -193,3 +193,3 @@ sMore = Math.round(sMore); | ||
var realAmount = 1 - Math.min(Math.max(amount, 0), 1); | ||
var sMore = hsv.s + ((100 - hsv.s) * realAmount); | ||
var sMore = hsv.s + (100 - hsv.s) * realAmount; | ||
if (round) | ||
@@ -196,0 +196,0 @@ sMore = Math.round(sMore); |
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -49,342 +49,342 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
exports.stdIlluminants = { | ||
'a': { | ||
'ref': 'Incandescent / Tungsten', | ||
'k': 2856, | ||
'hue': 30, | ||
'rgb': [255, 175, 95], | ||
'chrom': { | ||
a: { | ||
ref: 'Incandescent / Tungsten', | ||
k: 2856, | ||
hue: 30, | ||
rgb: [255, 175, 95], | ||
chrom: { | ||
'2d': { | ||
'x': 0.44757, | ||
'y': 0.40745 | ||
x: 0.44757, | ||
y: 0.40745, | ||
}, | ||
'10d': { | ||
'x': 0.45117, | ||
'y': 0.40594 | ||
} | ||
x: 0.45117, | ||
y: 0.40594, | ||
}, | ||
}, | ||
'vector': [1.09850, 1, 0.35585], | ||
vector: [1.0985, 1, 0.35585], | ||
}, | ||
'b': { | ||
'ref': 'Direct Sunlight at Noon', | ||
'k': 4874, | ||
'hue': 27, | ||
'rgb': [255, 226, 199], | ||
'chrom': { | ||
b: { | ||
ref: 'Direct Sunlight at Noon', | ||
k: 4874, | ||
hue: 27, | ||
rgb: [255, 226, 199], | ||
chrom: { | ||
'2d': { | ||
'x': 0.34842, | ||
'y': 0.35161 | ||
x: 0.34842, | ||
y: 0.35161, | ||
}, | ||
'10d': { | ||
'x': 0.34980, | ||
'y': 0.35270 | ||
} | ||
x: 0.3498, | ||
y: 0.3527, | ||
}, | ||
}, | ||
'vector': [0.99072, 1, 0.85223], | ||
vector: [0.99072, 1, 0.85223], | ||
}, | ||
'c': { | ||
'ref': 'Average / North Sky Daylight', | ||
'k': 6774, | ||
'hue': 276, | ||
'rgb': [248, 245, 255], | ||
'chrom': { | ||
c: { | ||
ref: 'Average / North Sky Daylight', | ||
k: 6774, | ||
hue: 276, | ||
rgb: [248, 245, 255], | ||
chrom: { | ||
'2d': { | ||
'x': 0.31006, | ||
'y': 0.31616 | ||
x: 0.31006, | ||
y: 0.31616, | ||
}, | ||
'10d': { | ||
'x': 0.31039, | ||
'y': 0.31905 | ||
} | ||
x: 0.31039, | ||
y: 0.31905, | ||
}, | ||
}, | ||
'vector': [0.98074, 1, 1.18232], | ||
vector: [0.98074, 1, 1.18232], | ||
}, | ||
'd50': { | ||
'ref': 'Horizon Light / ICC profile PCS', | ||
'k': 5003, | ||
'hue': 35, | ||
'rgb': [255, 228, 205], | ||
'chrom': { | ||
d50: { | ||
ref: 'Horizon Light / ICC profile PCS', | ||
k: 5003, | ||
hue: 35, | ||
rgb: [255, 228, 205], | ||
chrom: { | ||
'2d': { | ||
'x': 0.34567, | ||
'y': 0.35850 | ||
x: 0.34567, | ||
y: 0.3585, | ||
}, | ||
'10d': { | ||
'x': 0.34773, | ||
'y': 0.35952 | ||
} | ||
x: 0.34773, | ||
y: 0.35952, | ||
}, | ||
}, | ||
// 0.82 or 1.82 ?? >_> | ||
'vector': [0.96422, 1, 0.82521], | ||
vector: [0.96422, 1, 0.82521], | ||
}, | ||
'd55': { | ||
'ref': 'Mid-morning / Mid-afternoon Daylight', | ||
'k': 5503, | ||
'hue': 36, | ||
'rgb': [255, 236, 223], | ||
'chrom': { | ||
d55: { | ||
ref: 'Mid-morning / Mid-afternoon Daylight', | ||
k: 5503, | ||
hue: 36, | ||
rgb: [255, 236, 223], | ||
chrom: { | ||
'2d': { | ||
'x': 0.33242, | ||
'y': 0.34743, | ||
x: 0.33242, | ||
y: 0.34743, | ||
}, | ||
'10d': { | ||
'x': 0.33411, | ||
'y': 0.34877, | ||
x: 0.33411, | ||
y: 0.34877, | ||
}, | ||
}, | ||
'vector': [0.95682, 1, 0.92149], | ||
vector: [0.95682, 1, 0.92149], | ||
}, | ||
'd65': { | ||
'ref': 'Noon Daylight / Television / sRGB', | ||
'k': 6504, | ||
'hue': false, | ||
'rgb': [255, 249, 255], | ||
'chrom': { | ||
d65: { | ||
ref: 'Noon Daylight / Television / sRGB', | ||
k: 6504, | ||
hue: false, | ||
rgb: [255, 249, 255], | ||
chrom: { | ||
'2d': { | ||
'x': 0.31271, | ||
'y': 0.32902, | ||
x: 0.31271, | ||
y: 0.32902, | ||
}, | ||
'10d': { | ||
'x': 0.31382, | ||
'y': 0.33100, | ||
x: 0.31382, | ||
y: 0.331, | ||
}, | ||
}, | ||
'vector': [0.95047, 1, 1.08883], | ||
vector: [0.95047, 1, 1.08883], | ||
}, | ||
'd75': { | ||
'ref': 'North Sky Daylight', | ||
'k': 7504, | ||
'hue': 217, | ||
'rgb': [232, 236, 255], | ||
'chrom': { | ||
d75: { | ||
ref: 'North Sky Daylight', | ||
k: 7504, | ||
hue: 217, | ||
rgb: [232, 236, 255], | ||
chrom: { | ||
'2d': { | ||
'x': 0.29902, | ||
'y': 0.31485, | ||
x: 0.29902, | ||
y: 0.31485, | ||
}, | ||
'10d': { | ||
'x': 0.29968, | ||
'y': 0.31740, | ||
x: 0.29968, | ||
y: 0.3174, | ||
}, | ||
}, | ||
'vector': [0.94972, 1, 1.22638], | ||
vector: [0.94972, 1, 1.22638], | ||
}, | ||
'e': { | ||
'ref': 'Equal Energy', | ||
'k': 5454, | ||
'hue': 10, | ||
'rgb': [255, 235, 221], | ||
'chrom': { | ||
e: { | ||
ref: 'Equal Energy', | ||
k: 5454, | ||
hue: 10, | ||
rgb: [255, 235, 221], | ||
chrom: { | ||
'2d': { | ||
'x': 1 / 3, | ||
'y': 1 / 3, | ||
x: 1 / 3, | ||
y: 1 / 3, | ||
}, | ||
'10d': { | ||
'x': 1 / 3, | ||
'y': 1 / 3, | ||
x: 1 / 3, | ||
y: 1 / 3, | ||
}, | ||
}, | ||
'vector': [1, 1, 1], | ||
vector: [1, 1, 1], | ||
}, | ||
'f1': { | ||
'ref': 'Daylight Fluorescent', | ||
'k': 6430, | ||
'hue': 111, | ||
'rgb': [255, 248, 253], | ||
'chrom': { | ||
f1: { | ||
ref: 'Daylight Fluorescent', | ||
k: 6430, | ||
hue: 111, | ||
rgb: [255, 248, 253], | ||
chrom: { | ||
'2d': { | ||
'x': 0.31310, | ||
'y': 0.33727, | ||
x: 0.3131, | ||
y: 0.33727, | ||
}, | ||
'10d': { | ||
'x': 0.31811, | ||
'y': 0.33559, | ||
x: 0.31811, | ||
y: 0.33559, | ||
}, | ||
}, | ||
}, | ||
'f2': { | ||
'ref': 'Cool White FLuorescent', | ||
'k': 4230, | ||
'hue': 33, | ||
'rgb': [255, 213, 171], | ||
'chrom': { | ||
f2: { | ||
ref: 'Cool White FLuorescent', | ||
k: 4230, | ||
hue: 33, | ||
rgb: [255, 213, 171], | ||
chrom: { | ||
'2d': { | ||
'x': 0.37208, | ||
'y': 0.37529, | ||
x: 0.37208, | ||
y: 0.37529, | ||
}, | ||
'10d': { | ||
'x': 0.37925, | ||
'y': 0.36733, | ||
x: 0.37925, | ||
y: 0.36733, | ||
}, | ||
}, | ||
'vector': [0.99186, 1, 1.67393], | ||
vector: [0.99186, 1, 1.67393], | ||
}, | ||
'f3': { | ||
'ref': 'White Fluorescent', | ||
'k': 3450, | ||
'hue': 32, | ||
'rgb': [255, 194, 131], | ||
'chrom': { | ||
f3: { | ||
ref: 'White Fluorescent', | ||
k: 3450, | ||
hue: 32, | ||
rgb: [255, 194, 131], | ||
chrom: { | ||
'2d': { | ||
'x': 0.40910, | ||
'y': 0.39430, | ||
x: 0.4091, | ||
y: 0.3943, | ||
}, | ||
'10d': { | ||
'x': 0.41761, | ||
'y': 0.38324, | ||
x: 0.41761, | ||
y: 0.38324, | ||
}, | ||
}, | ||
}, | ||
'f4': { | ||
'ref': 'Warm White FLuorescent', | ||
'k': 2940, | ||
'hue': 30, | ||
'rgb': [255, 177, 101], | ||
'chrom': { | ||
f4: { | ||
ref: 'Warm White FLuorescent', | ||
k: 2940, | ||
hue: 30, | ||
rgb: [255, 177, 101], | ||
chrom: { | ||
'2d': { | ||
'x': 0.44018, | ||
'y': 0.40329, | ||
x: 0.44018, | ||
y: 0.40329, | ||
}, | ||
'10d': { | ||
'x': 0.44920, | ||
'y': 0.39074, | ||
x: 0.4492, | ||
y: 0.39074, | ||
}, | ||
}, | ||
}, | ||
'f5': { | ||
'ref': 'Daylight FLuorescent', | ||
'k': 6350, | ||
'hue': 106, | ||
'rgb': [255, 247, 250], | ||
'chrom': { | ||
f5: { | ||
ref: 'Daylight FLuorescent', | ||
k: 6350, | ||
hue: 106, | ||
rgb: [255, 247, 250], | ||
chrom: { | ||
'2d': { | ||
'x': 0.31379, | ||
'y': 0.34531, | ||
x: 0.31379, | ||
y: 0.34531, | ||
}, | ||
'10d': { | ||
'x': 0.31975, | ||
'y': 0.34246, | ||
x: 0.31975, | ||
y: 0.34246, | ||
}, | ||
}, | ||
}, | ||
'f6': { | ||
'ref': 'Lite White Fluorescent', | ||
'k': 4150, | ||
'hue': 38, | ||
'rgb': [255, 212, 168], | ||
'chrom': { | ||
f6: { | ||
ref: 'Lite White Fluorescent', | ||
k: 4150, | ||
hue: 38, | ||
rgb: [255, 212, 168], | ||
chrom: { | ||
'2d': { | ||
'x': 0.37790, | ||
'y': 0.38835, | ||
x: 0.3779, | ||
y: 0.38835, | ||
}, | ||
'10d': { | ||
'x': 0.38660, | ||
'y': 0.37847, | ||
x: 0.3866, | ||
y: 0.37847, | ||
}, | ||
}, | ||
}, | ||
'f7': { | ||
'ref': 'D65 Simulator, Daylight Simulator', | ||
'k': 6500, | ||
'hue': false, | ||
'rgb': [255, 249, 255], | ||
'chrom': { | ||
f7: { | ||
ref: 'D65 Simulator, Daylight Simulator', | ||
k: 6500, | ||
hue: false, | ||
rgb: [255, 249, 255], | ||
chrom: { | ||
'2d': { | ||
'x': 0.31292, | ||
'y': 0.32933, | ||
x: 0.31292, | ||
y: 0.32933, | ||
}, | ||
'10d': { | ||
'x': 0.31569, | ||
'y': 0.32960, | ||
x: 0.31569, | ||
y: 0.3296, | ||
}, | ||
}, | ||
'vector': [0.95041, 1, 1.08747], | ||
vector: [0.95041, 1, 1.08747], | ||
}, | ||
'f8': { | ||
'ref': 'D50 Simulator, Sylvania F40 Design 50', | ||
'k': 5000, | ||
'hue': 35, | ||
'rgb': [255, 228, 204], | ||
'chrom': { | ||
f8: { | ||
ref: 'D50 Simulator, Sylvania F40 Design 50', | ||
k: 5000, | ||
hue: 35, | ||
rgb: [255, 228, 204], | ||
chrom: { | ||
'2d': { | ||
'x': 0.34588, | ||
'y': 0.35875, | ||
x: 0.34588, | ||
y: 0.35875, | ||
}, | ||
'10d': { | ||
'x': 0.34902, | ||
'y': 0.35939, | ||
x: 0.34902, | ||
y: 0.35939, | ||
}, | ||
}, | ||
}, | ||
'f9': { | ||
'ref': 'Cool White Deluxe Fluorescent', | ||
'k': 4150, | ||
'hue': 30, | ||
'rgb': [255, 212, 168], | ||
'chrom': { | ||
f9: { | ||
ref: 'Cool White Deluxe Fluorescent', | ||
k: 4150, | ||
hue: 30, | ||
rgb: [255, 212, 168], | ||
chrom: { | ||
'2d': { | ||
'x': 0.37417, | ||
'y': 0.37281, | ||
x: 0.37417, | ||
y: 0.37281, | ||
}, | ||
'10d': { | ||
'x': 0.37829, | ||
'y': 0.37045, | ||
x: 0.37829, | ||
y: 0.37045, | ||
}, | ||
}, | ||
}, | ||
'f10': { | ||
'ref': 'Philips TL85, Ultralume 50', | ||
'k': 5000, | ||
'hue': 36, | ||
'rgb': [255, 228, 204], | ||
'chrom': { | ||
f10: { | ||
ref: 'Philips TL85, Ultralume 50', | ||
k: 5000, | ||
hue: 36, | ||
rgb: [255, 228, 204], | ||
chrom: { | ||
'2d': { | ||
'x': 0.34609, | ||
'y': 0.35986, | ||
x: 0.34609, | ||
y: 0.35986, | ||
}, | ||
'10d': { | ||
'x': 0.35090, | ||
'y': 0.35444, | ||
x: 0.3509, | ||
y: 0.35444, | ||
}, | ||
}, | ||
}, | ||
'f11': { | ||
'ref': 'Philips TL84, Ultralume 40', | ||
'k': 4000, | ||
'hue': 31, | ||
'rgb': [255, 208, 160], | ||
'chrom': { | ||
f11: { | ||
ref: 'Philips TL84, Ultralume 40', | ||
k: 4000, | ||
hue: 31, | ||
rgb: [255, 208, 160], | ||
chrom: { | ||
'2d': { | ||
'x': 0.38052, | ||
'y': 0.37713, | ||
x: 0.38052, | ||
y: 0.37713, | ||
}, | ||
'10d': { | ||
'x': 0.38541, | ||
'y': 0.37123, | ||
x: 0.38541, | ||
y: 0.37123, | ||
}, | ||
}, | ||
'vector': [1.00962, 1, 0.64350], | ||
vector: [1.00962, 1, 0.6435], | ||
}, | ||
'f12': { | ||
'ref': 'Philips TL83, Ultralume 30', | ||
'k': 3000, | ||
'hue': 31, | ||
'rgb': [255, 179, 105], | ||
'chrom': { | ||
f12: { | ||
ref: 'Philips TL83, Ultralume 30', | ||
k: 3000, | ||
hue: 31, | ||
rgb: [255, 179, 105], | ||
chrom: { | ||
'2d': { | ||
'x': 0.43695, | ||
'y': 0.40441, | ||
x: 0.43695, | ||
y: 0.40441, | ||
}, | ||
'10d': { | ||
'x': 0.44256, | ||
'y': 0.39717, | ||
x: 0.44256, | ||
y: 0.39717, | ||
}, | ||
}, | ||
}, | ||
'icc': [0.9642, 1, 0.8249], | ||
icc: [0.9642, 1, 0.8249], | ||
}; | ||
exports.colorSpaces = { | ||
'adobergb1998': { | ||
'name': 'Adobe RGB (1998)', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd65': [ | ||
adobergb1998: { | ||
name: 'Adobe RGB (1998)', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d65: [ | ||
[0.5767309, 0.185554, 0.1881852], | ||
@@ -394,3 +394,3 @@ [0.2973769, 0.6273491, 0.0752741], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.6097559, 0.2052401, 0.149224], | ||
@@ -401,4 +401,4 @@ [0.3111242, 0.625656, 0.0632197], | ||
}, | ||
'xyz2rgb': { | ||
'd65': [ | ||
xyz2rgb: { | ||
d65: [ | ||
[2.041369, -0.5649464, -0.3446944], | ||
@@ -408,3 +408,3 @@ [-0.969266, 1.8760108, 0.041556], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[1.9624274, -0.6105343, -0.3413404], | ||
@@ -416,7 +416,7 @@ [-0.9787684, 1.9161415, 0.033454], | ||
}, | ||
'applergb': { | ||
'name': 'Apple RGB', | ||
'gamma': 1.8, | ||
'rgb2xyz': { | ||
'd65': [ | ||
applergb: { | ||
name: 'Apple RGB', | ||
gamma: 1.8, | ||
rgb2xyz: { | ||
d65: [ | ||
[0.4497288, 0.3162486, 0.1844926], | ||
@@ -426,3 +426,3 @@ [0.2446525, 0.6720283, 0.0833192], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.4755678, 0.3396722, 0.14898], | ||
@@ -433,4 +433,4 @@ [0.2551812, 0.6725693, 0.0722496], | ||
}, | ||
'xyz2rgb': { | ||
'd65': [ | ||
xyz2rgb: { | ||
d65: [ | ||
[2.9515373, -1.2894116, -0.4738445], | ||
@@ -440,3 +440,3 @@ [-1.0851093, 1.9908566, 0.0372026], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[2.8510695, -1.3605261, -0.4708281], | ||
@@ -448,7 +448,7 @@ [-1.092768, 2.0348871, 0.0227598], | ||
}, | ||
'bestrgb': { | ||
'name': 'Best RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd50': [ | ||
bestrgb: { | ||
name: 'Best RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.6326696, 0.2045558, 0.1269946], | ||
@@ -459,4 +459,4 @@ [0.2284569, 0.7373523, 0.0341908], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[1.7552599, -0.4836786, -0.253], | ||
@@ -468,7 +468,7 @@ [-0.5441336, 1.5068789, 0.0215528], | ||
}, | ||
'betargb': { | ||
'name': 'Beta RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd50': [ | ||
betargb: { | ||
name: 'Beta RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.6712537, 0.1745834, 0.1183829], | ||
@@ -479,4 +479,4 @@ [0.3032726, 0.6637861, 0.0329413], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[1.683227, -0.4282363, -0.2360185], | ||
@@ -488,7 +488,7 @@ [-0.7710229, 1.7065571, 0.04469], | ||
}, | ||
'brucergb': { | ||
'name': 'Bruce RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd65': [ | ||
brucergb: { | ||
name: 'Bruce RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d65: [ | ||
[0.4674162, 0.2944512, 0.1886026], | ||
@@ -498,3 +498,3 @@ [0.2410115, 0.6835475, 0.075441], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.4941816, 0.3204834, 0.149555], | ||
@@ -505,4 +505,4 @@ [0.2521531, 0.6844869, 0.06336], | ||
}, | ||
'xyz2rgb': { | ||
'd65': [ | ||
xyz2rgb: { | ||
d65: [ | ||
[2.7454669, -1.1358136, -0.4350269], | ||
@@ -512,3 +512,3 @@ [-0.969266, 1.8760108, 0.041556], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[2.6502856, -1.2014485, -0.4289936], | ||
@@ -520,7 +520,7 @@ [-0.9787684, 1.9161415, 0.033454], | ||
}, | ||
'ciergb': { | ||
'name': 'CIE RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'e': [ | ||
ciergb: { | ||
name: 'CIE RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
e: [ | ||
[0.488718, 0.3106803, 0.2006017], | ||
@@ -530,3 +530,3 @@ [0.1762044, 0.8129847, 0.0108109], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.486887, 0.3062984, 0.1710347], | ||
@@ -537,4 +537,4 @@ [0.1746583, 0.8247541, 0.0005877], | ||
}, | ||
'xyz2rgb': { | ||
'e': [ | ||
xyz2rgb: { | ||
e: [ | ||
[2.3706743, -0.9000405, -0.4706338], | ||
@@ -544,3 +544,3 @@ [-0.513885, 1.4253036, 0.0885814], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[2.3638081, -0.867603, -0.4988161], | ||
@@ -552,7 +552,7 @@ [-0.500594, 1.3962369, 0.1047562], | ||
}, | ||
'colormatchrgb': { | ||
'name': 'ColorMatch RGB', | ||
'gamma': 1.8, | ||
'rgb2xyz': { | ||
'd50': [ | ||
colormatchrgb: { | ||
name: 'ColorMatch RGB', | ||
gamma: 1.8, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.5093439, 0.3209071, 0.1339691], | ||
@@ -563,4 +563,4 @@ [0.274884, 0.6581315, 0.0669845], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[2.6422874, -1.223427, -0.3930143], | ||
@@ -572,7 +572,7 @@ [-1.1119763, 2.0590183, 0.0159614], | ||
}, | ||
'donrgb4': { | ||
'name': 'Don RGB 4', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd50': [ | ||
donrgb4: { | ||
name: 'Don RGB 4', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.6457711, 0.1933511, 0.1250978], | ||
@@ -583,4 +583,4 @@ [0.2783496, 0.6879702, 0.0336802], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[1.7603902, -0.4881198, -0.2536126], | ||
@@ -592,7 +592,7 @@ [-0.7126288, 1.6527432, 0.0416715], | ||
}, | ||
'ecirgb': { | ||
'name': 'ECI RGB v2', | ||
ecirgb: { | ||
name: 'ECI RGB v2', | ||
// gamma = L* | ||
'rgb2xyz': { | ||
'd50': [ | ||
rgb2xyz: { | ||
d50: [ | ||
[0.6502043, 0.1780774, 0.1359384], | ||
@@ -603,4 +603,4 @@ [0.3202499, 0.6020711, 0.0776791], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[1.7827618, -0.4969847, -0.2690101], | ||
@@ -612,7 +612,7 @@ [-0.9593623, 1.9477962, -0.0275807], | ||
}, | ||
'ektaspaceps5': { | ||
'name': 'Ekta Space PS5', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd50': [ | ||
ektaspaceps5: { | ||
name: 'Ekta Space PS5', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.5938914, 0.2729801, 0.0973485], | ||
@@ -623,4 +623,4 @@ [0.2606286, 0.7349465, 0.0044249], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[2.0043819, -0.7304844, -0.2450052], | ||
@@ -632,7 +632,7 @@ [-0.7110285, 1.6202126, 0.0792227], | ||
}, | ||
'ntscrgb': { | ||
'name': 'NTSC RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'c': [ | ||
ntscrgb: { | ||
name: 'NTSC RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
c: [ | ||
[0.6068909, 0.1735011, 0.200348], | ||
@@ -642,3 +642,3 @@ [0.2989164, 0.586599, 0.1144845], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.6343706, 0.1852204, 0.144629], | ||
@@ -649,4 +649,4 @@ [0.3109496, 0.5915984, 0.097452], | ||
}, | ||
'xyz2rgb': { | ||
'c': [ | ||
xyz2rgb: { | ||
c: [ | ||
[1.9099961, -0.5324542, -0.2882091], | ||
@@ -656,3 +656,3 @@ [-0.9846663, 1.999171, -0.0283082], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[1.8464881, -0.5521299, -0.2766458], | ||
@@ -664,7 +664,7 @@ [-0.982663, 2.0044755, -0.0690396], | ||
}, | ||
'palsecamrgb': { | ||
'name': 'PAL/SECAM RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd65': [ | ||
palsecamrgb: { | ||
name: 'PAL/SECAM RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d65: [ | ||
[0.430619, 0.3415419, 0.1783091], | ||
@@ -674,3 +674,3 @@ [0.2220379, 0.7066384, 0.0713236], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.4552773, 0.36755, 0.1413926], | ||
@@ -681,4 +681,4 @@ [0.2323025, 0.7077956, 0.0599019], | ||
}, | ||
'xyz2rgb': { | ||
'd65': [ | ||
xyz2rgb: { | ||
d65: [ | ||
[3.0628971, -1.3931791, -0.4757517], | ||
@@ -688,3 +688,3 @@ [-0.969266, 1.8760108, 0.041556], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[2.9603944, -1.4678519, -0.4685105], | ||
@@ -696,14 +696,14 @@ [-0.9787684, 1.9161415, 0.033454], | ||
}, | ||
'prophotorgb': { | ||
'name': 'ProPhoto RGB', | ||
'gamma': 1.8, | ||
'rgb2xyz': { | ||
'd50': [ | ||
prophotorgb: { | ||
name: 'ProPhoto RGB', | ||
gamma: 1.8, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.7976749, 0.1351917, 0.0313534], | ||
[0.2880402, 0.7118741, 8.57E-5], | ||
[0.2880402, 0.7118741, 8.57e-5], | ||
[0, 0, 0.82521], | ||
], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[1.3459433, -0.2556075, -0.0511118], | ||
@@ -715,7 +715,7 @@ [-0.5445989, 1.5081673, 0.0205351], | ||
}, | ||
'smptecrgb': { | ||
'name': 'SMPTE-C RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd65': [ | ||
smptecrgb: { | ||
name: 'SMPTE-C RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d65: [ | ||
[0.3935891, 0.3652497, 0.1916313], | ||
@@ -725,3 +725,3 @@ [0.2124132, 0.7010437, 0.0865432], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.416329, 0.3931464, 0.1547446], | ||
@@ -732,4 +732,4 @@ [0.2216999, 0.7032549, 0.0750452], | ||
}, | ||
'xyz2rgb': { | ||
'd65': [ | ||
xyz2rgb: { | ||
d65: [ | ||
[3.505396, -1.7394894, -0.543964], | ||
@@ -739,3 +739,3 @@ [-1.0690722, 1.9778245, 0.0351722], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[3.392194, -1.8264027, -0.5385522], | ||
@@ -747,12 +747,12 @@ [-1.0770996, 2.0213975, 0.0207989], | ||
}, | ||
'srgb': { | ||
'name': 'sRGB', | ||
srgb: { | ||
name: 'sRGB', | ||
// sRGB companding / ~=2.2 | ||
'rgb2xyz': { | ||
'd65': [ | ||
rgb2xyz: { | ||
d65: [ | ||
[0.4124564, 0.3575761, 0.1804375], | ||
[0.2126729, 0.7151522, 0.0721750], | ||
[0.0193339, 0.1191920, 0.9503041], | ||
[0.2126729, 0.7151522, 0.072175], | ||
[0.0193339, 0.119192, 0.9503041], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[0.4360747, 0.3850649, 0.1430804], | ||
@@ -763,11 +763,11 @@ [0.2225045, 0.7168786, 0.0606169], | ||
}, | ||
'xyz2rgb': { | ||
'd65': [ | ||
xyz2rgb: { | ||
d65: [ | ||
[3.2404542, -1.5371385, -0.4985314], | ||
[-0.9692660, 1.8760108, 0.0415560], | ||
[-0.969266, 1.8760108, 0.041556], | ||
[0.0556434, -0.2040259, 1.0572252], | ||
], | ||
'd50': [ | ||
d50: [ | ||
[3.1338561, -1.6168667, -0.4906146], | ||
[-0.9787684, 1.9161415, 0.0334540], | ||
[-0.9787684, 1.9161415, 0.033454], | ||
[0.0719453, -0.2289914, 1.4052427], | ||
@@ -777,7 +777,7 @@ ], | ||
}, | ||
'widegamutrgb': { | ||
'name': 'Wide Gamut RGB', | ||
'gamma': 2.2, | ||
'rgb2xyz': { | ||
'd50': [ | ||
widegamutrgb: { | ||
name: 'Wide Gamut RGB', | ||
gamma: 2.2, | ||
rgb2xyz: { | ||
d50: [ | ||
[0.7161046, 0.1009296, 0.1471858], | ||
@@ -788,4 +788,4 @@ [0.2581874, 0.7249378, 0.0168748], | ||
}, | ||
'xyz2rgb': { | ||
'd50': [ | ||
xyz2rgb: { | ||
d50: [ | ||
[1.4628067, -0.1840623, -0.2743606], | ||
@@ -809,8 +809,8 @@ [-0.5217933, 1.4472381, 0.0677227], | ||
r: [0.64, 0.33], | ||
g: [0.29, 0.60], | ||
g: [0.29, 0.6], | ||
b: [0.15, 0.06], | ||
w: [0.3127, 0.3291] | ||
w: [0.3127, 0.3291], | ||
}, | ||
vectors: [ | ||
[0.0014, 0.0000, 0.0065], | ||
[0.0014, 0.0, 0.0065], | ||
[0.0022, 0.0001, 0.0105], | ||
@@ -823,76 +823,76 @@ [0.0042, 0.0001, 0.0201], | ||
[0.0776, 0.0022, 0.3713], | ||
[0.1344, 0.0040, 0.6456], | ||
[0.1344, 0.004, 0.6456], | ||
[0.2148, 0.0073, 1.0391], | ||
[0.2839, 0.0116, 1.3856], | ||
[0.3285, 0.0168, 1.6230], | ||
[0.3483, 0.0230, 1.7471], | ||
[0.3285, 0.0168, 1.623], | ||
[0.3483, 0.023, 1.7471], | ||
[0.3481, 0.0298, 1.7826], | ||
[0.3362, 0.0380, 1.7721], | ||
[0.3187, 0.0480, 1.7441], | ||
[0.2908, 0.0600, 1.6692], | ||
[0.3362, 0.038, 1.7721], | ||
[0.3187, 0.048, 1.7441], | ||
[0.2908, 0.06, 1.6692], | ||
[0.2511, 0.0739, 1.5281], | ||
[0.1954, 0.0910, 1.2876], | ||
[0.1954, 0.091, 1.2876], | ||
[0.1421, 0.1126, 1.0419], | ||
[0.0956, 0.1390, 0.8130], | ||
[0.0580, 0.1693, 0.6162], | ||
[0.0320, 0.2080, 0.4652], | ||
[0.0956, 0.139, 0.813], | ||
[0.058, 0.1693, 0.6162], | ||
[0.032, 0.208, 0.4652], | ||
[0.0147, 0.2586, 0.3533], | ||
[0.0049, 0.3230, 0.2720], | ||
[0.0049, 0.323, 0.272], | ||
[0.0024, 0.4073, 0.2123], | ||
[0.0093, 0.5030, 0.1582], | ||
[0.0093, 0.503, 0.1582], | ||
[0.0291, 0.6082, 0.1117], | ||
[0.0633, 0.7100, 0.0782], | ||
[0.0633, 0.71, 0.0782], | ||
[0.1096, 0.7932, 0.0573], | ||
[0.1655, 0.8620, 0.0422], | ||
[0.1655, 0.862, 0.0422], | ||
[0.2257, 0.9149, 0.0298], | ||
[0.2904, 0.9540, 0.0203], | ||
[0.2904, 0.954, 0.0203], | ||
[0.3597, 0.9803, 0.0134], | ||
[0.4334, 0.9950, 0.0087], | ||
[0.5121, 1.0000, 0.0057], | ||
[0.5945, 0.9950, 0.0039], | ||
[0.4334, 0.995, 0.0087], | ||
[0.5121, 1.0, 0.0057], | ||
[0.5945, 0.995, 0.0039], | ||
[0.6784, 0.9786, 0.0027], | ||
[0.7621, 0.9520, 0.0021], | ||
[0.7621, 0.952, 0.0021], | ||
[0.8425, 0.9154, 0.0018], | ||
[0.9163, 0.8700, 0.0017], | ||
[0.9163, 0.87, 0.0017], | ||
[0.9786, 0.8163, 0.0014], | ||
[1.0263, 0.7570, 0.0011], | ||
[1.0567, 0.6949, 0.0010], | ||
[1.0622, 0.6310, 0.0008], | ||
[1.0263, 0.757, 0.0011], | ||
[1.0567, 0.6949, 0.001], | ||
[1.0622, 0.631, 0.0008], | ||
[1.0456, 0.5668, 0.0006], | ||
[1.0026, 0.5030, 0.0003], | ||
[1.0026, 0.503, 0.0003], | ||
[0.9384, 0.4412, 0.0002], | ||
[0.8544, 0.3810, 0.0002], | ||
[0.7514, 0.3210, 0.0001], | ||
[0.6424, 0.2650, 0.0000], | ||
[0.5419, 0.2170, 0.0000], | ||
[0.4479, 0.1750, 0.0000], | ||
[0.3608, 0.1382, 0.0000], | ||
[0.2835, 0.1070, 0.0000], | ||
[0.2187, 0.0816, 0.0000], | ||
[0.1649, 0.0610, 0.0000], | ||
[0.1212, 0.0446, 0.0000], | ||
[0.0874, 0.0320, 0.0000], | ||
[0.0636, 0.0232, 0.0000], | ||
[0.0468, 0.0170, 0.0000], | ||
[0.0329, 0.0119, 0.0000], | ||
[0.0227, 0.0082, 0.0000], | ||
[0.0158, 0.0057, 0.0000], | ||
[0.0114, 0.0041, 0.0000], | ||
[0.0081, 0.0029, 0.0000], | ||
[0.0058, 0.0021, 0.0000], | ||
[0.0041, 0.0015, 0.0000], | ||
[0.0029, 0.0010, 0.0000], | ||
[0.0020, 0.0007, 0.0000], | ||
[0.0014, 0.0005, 0.0000], | ||
[0.0010, 0.0004, 0.0000], | ||
[0.0007, 0.0002, 0.0000], | ||
[0.0005, 0.0002, 0.0000], | ||
[0.0003, 0.0001, 0.0000], | ||
[0.0002, 0.0001, 0.0000], | ||
[0.0002, 0.0001, 0.0000], | ||
[0.0001, 0.0000, 0.0000], | ||
[0.0001, 0.0000, 0.0000], | ||
[0.0001, 0.0000, 0.0000], | ||
[0.0000, 0.0000, 0.0000] | ||
] | ||
[0.8544, 0.381, 0.0002], | ||
[0.7514, 0.321, 0.0001], | ||
[0.6424, 0.265, 0.0], | ||
[0.5419, 0.217, 0.0], | ||
[0.4479, 0.175, 0.0], | ||
[0.3608, 0.1382, 0.0], | ||
[0.2835, 0.107, 0.0], | ||
[0.2187, 0.0816, 0.0], | ||
[0.1649, 0.061, 0.0], | ||
[0.1212, 0.0446, 0.0], | ||
[0.0874, 0.032, 0.0], | ||
[0.0636, 0.0232, 0.0], | ||
[0.0468, 0.017, 0.0], | ||
[0.0329, 0.0119, 0.0], | ||
[0.0227, 0.0082, 0.0], | ||
[0.0158, 0.0057, 0.0], | ||
[0.0114, 0.0041, 0.0], | ||
[0.0081, 0.0029, 0.0], | ||
[0.0058, 0.0021, 0.0], | ||
[0.0041, 0.0015, 0.0], | ||
[0.0029, 0.001, 0.0], | ||
[0.002, 0.0007, 0.0], | ||
[0.0014, 0.0005, 0.0], | ||
[0.001, 0.0004, 0.0], | ||
[0.0007, 0.0002, 0.0], | ||
[0.0005, 0.0002, 0.0], | ||
[0.0003, 0.0001, 0.0], | ||
[0.0002, 0.0001, 0.0], | ||
[0.0002, 0.0001, 0.0], | ||
[0.0001, 0.0, 0.0], | ||
[0.0001, 0.0, 0.0], | ||
[0.0001, 0.0, 0.0], | ||
[0.0, 0.0, 0.0], | ||
], | ||
}; |
"use strict"; | ||
// chromaticity-color-utilities | ||
// Copyright (C) 2021 Emma Litwa-Vulcu | ||
// | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
@@ -9,3 +9,3 @@ // it under the terms of the GNU General Public License as published by | ||
// (at your option) any later version. | ||
// | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
@@ -15,3 +15,3 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// GNU General Public License for more details. | ||
// | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
@@ -37,3 +37,5 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
if (round === void 0) { round = true; } | ||
var valueTo = (Math.min(maxFrom, Math.max(minFrom, value)) - minFrom) * ((maxTo - minTo) / (maxFrom - minFrom)) + minTo; | ||
var valueTo = (Math.min(maxFrom, Math.max(minFrom, value)) - minFrom) * | ||
((maxTo - minTo) / (maxFrom - minFrom)) + | ||
minTo; | ||
if (round) { | ||
@@ -66,3 +68,4 @@ valueTo = Math.round(valueTo); | ||
var cy = rowN == 2 ? 1 : 2; | ||
minors[rowN][colN] = matrix[ax][ay] * matrix[dx][dy] - matrix[bx][by] * matrix[cx][cy]; | ||
minors[rowN][colN] = | ||
matrix[ax][ay] * matrix[dx][dy] - matrix[bx][by] * matrix[cx][cy]; | ||
if (flip_sign) { | ||
@@ -87,3 +90,5 @@ cofactors[rowN][colN] = minors[rowN][colN] * -1; | ||
// Calculate determinant of matrix | ||
var determinant = minors[0][0] * cofactors[0][0] + minors[0][1] * cofactors[0][1] + minors[0][2] * cofactors[0][2]; | ||
var determinant = minors[0][0] * cofactors[0][0] + | ||
minors[0][1] * cofactors[0][1] + | ||
minors[0][2] * cofactors[0][2]; | ||
// Calculate inverse matrix | ||
@@ -139,3 +144,3 @@ var inverse = []; | ||
[1, 1, 1], | ||
[(1 - xr - yr) / yr, (1 - xg - yg) / yg, (1 - xb - yb) / yb] | ||
[(1 - xr - yr) / yr, (1 - xg - yg) / yg, (1 - xb - yb) / yb], | ||
]; | ||
@@ -151,3 +156,3 @@ var inverse = this.matrix3x3inverse(xyzrgb); | ||
[sr * xyzrgb[1][0], sg * xyzrgb[1][1], sb * xyzrgb[1][2]], | ||
[sr * xyzrgb[2][0], sg * xyzrgb[2][1], sb * xyzrgb[2][2]] | ||
[sr * xyzrgb[2][0], sg * xyzrgb[2][1], sb * xyzrgb[2][2]], | ||
]; | ||
@@ -202,3 +207,3 @@ return m; | ||
y: w['y'], | ||
z: z | ||
z: z, | ||
}; | ||
@@ -210,16 +215,16 @@ }; | ||
var conform = { | ||
'adobe': 'adobergb1998', | ||
'adobergb': 'adobergb1998', | ||
'ntsc': 'ntscrgb', | ||
'palsecam': 'palsecamrgb', | ||
'pal': 'palsecamrgb', | ||
'palrgb': 'palsecamrgb', | ||
'secam': 'palsecamrgb', | ||
'secamrgb': 'palsecamrgb', | ||
'prophoto': 'prophotorgb', | ||
'smpte': 'smptecrgb', | ||
'smptec': 'smptecrgb', | ||
'widegamut': 'widegamutrgb', | ||
'ecirgbv2': 'ecirgb', | ||
'ektaspace': 'ektaspaceps5' | ||
adobe: 'adobergb1998', | ||
adobergb: 'adobergb1998', | ||
ntsc: 'ntscrgb', | ||
palsecam: 'palsecamrgb', | ||
pal: 'palsecamrgb', | ||
palrgb: 'palsecamrgb', | ||
secam: 'palsecamrgb', | ||
secamrgb: 'palsecamrgb', | ||
prophoto: 'prophotorgb', | ||
smpte: 'smptecrgb', | ||
smptec: 'smptecrgb', | ||
widegamut: 'widegamutrgb', | ||
ecirgbv2: 'ecirgb', | ||
ektaspace: 'ektaspaceps5', | ||
}; | ||
@@ -260,3 +265,3 @@ if (typeof conform[colorSpace] == 'string') { | ||
} | ||
var tmp2 = (x % y); | ||
var tmp2 = x % y; | ||
if (p < -100 || p > 20) { | ||
@@ -263,0 +268,0 @@ // toFixed will give an out of bound error so we fix it like this: |
{ | ||
"name": "chromaticity-color-utilities", | ||
"version": "0.2.9-alpha", | ||
"version": "0.3.0-alpha", | ||
"description": "Color utilities for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
100
README.md
# <img src="https://reiniiriarios.github.io/chromaticity-color-utilities/assets/images/chromaticity-icon-01.png" width="26" height="26"> chromaticity-color-utilities | ||
![](https://img.shields.io/npm/dt/chromaticity-color-utilities) ![](https://img.shields.io/npm/types/chromaticity-color-utilities) ![](https://img.shields.io/badge/license-GPLv3-green) | ||
![downloads](https://img.shields.io/npm/dt/chromaticity-color-utilities) | ||
![types: Typescript](https://img.shields.io/badge/types-Typescript-blue) | ||
![license: GPL-3.0-or-later](https://img.shields.io/badge/license-GPL--3.0--or--later-blueviolet) | ||
[![npm version](https://img.shields.io/npm/v/chromaticity-color-utilities)](https://www.npmjs.com/package/chromaticity-color-utilities) | ||
[![code style: prettier](https://img.shields.io/badge/code%20style-prettier-ff69b4)](https://github.com/prettier/prettier#readme) | ||
Color utilities for Node.js. | ||
Conversion, modification, and color schemes of: RGB (at any bit depth), HSV, HSL, HSI, HSP, CYMK, YIQ, XYZ, xyY, L\*a\*b\*, L\*u\*v\*, Y'PbPr, Y'CbCr, and more. | ||
```ts | ||
const Color = require('chromaticity-color-utilities') | ||
let color1 = Color.from('rgb',[255,128,0]).to('hsv') | ||
let color1 = Color.from('rgb', [255, 128, 0]).to('hsv') | ||
let scheme1 = Color.from('hex',0x9A237F).modify('desaturate',{amount:0.2}).to('lab',{ | ||
colorSpace: 'AdobeRGB', | ||
referenceWhite: 'D50' | ||
}).scheme('gradient',{ | ||
with: Color.from('hsl',[300,50,45]), | ||
colors: 5 | ||
}) | ||
let scheme1 = Color.from('hex', 0x9a237f) | ||
.modify('desaturate', { amount: 0.2 }) | ||
.to('lab', { | ||
colorSpace: 'AdobeRGB', | ||
referenceWhite: 'D50', | ||
}) | ||
.scheme('gradient', { | ||
with: Color.from('hsl', [300, 50, 45]), | ||
colors: 5, | ||
}) | ||
``` | ||
@@ -26,3 +32,3 @@ | ||
`npm install --save chromaticity-color-utilities` | ||
`npm i chromaticity-color-utilities` | ||
@@ -52,47 +58,56 @@ ## Status | ||
let color1 = Color.from('rgb',[255,128,0]).to('hsv') | ||
const color1 = Color.from('rgb', [255, 128, 0]).to('hsv') | ||
// hsv { h: 34, s: 100, v: 88, a: 100 } | ||
let color2 = Color.from('hex','ff3201').to('rec709rgb', { bitRate: 10 }) | ||
const color2 = Color.from('hex', 'ff3201').to('rec709rgb', { bitRate: 10 }) | ||
// rec709rgb { r: 940, g: 298, b: 67, a: 940, bitDepth: 10, max: 1023 } | ||
let color6 = Color.from('hex', '#ff00ff').to('lab') | ||
const 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', 0xFF00FF).to('lab',{ | ||
const color6 = Color.from('hex', 0xff00ff).to('lab', { | ||
colorSpace: 'AdobeRGB', | ||
referenceWhite: 'D50' | ||
referenceWhite: 'D50', | ||
}) | ||
// lab { l: 100, a: 150, b: -49 } | ||
let red = Color.from('hsl',[280,80,90]).to('rgb').r | ||
const red = Color.from('hsl', [280, 80, 90]).to('rgb').r | ||
// 250 | ||
let color7 = Color.from('hsl',[300,100,50]).to('ypbpr',{kb:0.0722, kr:0.2126}) | ||
const color7 = Color.from('hsl', [300, 100, 50]).to('ypbpr', { | ||
kb: 0.0722, | ||
kr: 0.2126, | ||
}) | ||
// ypbpr { y: 0.2848, pb: 0.3854278939426601, pr: 0.45415290830581667 } | ||
let color3 = Color.from('rgb',[255,0,0]).modify('blend', {with: Color.from('rgb',[0,255,0])}) | ||
const color3 = Color.from('rgb', [255, 0, 0]).modify('blend', { | ||
with: Color.from('rgb', [0, 255, 0]), | ||
}) | ||
// rgb { r: 128, g: 128, b: 0, a: 255, bitDepth: 8, max: 255 } | ||
let color4 = Color.from('rgb',[255,0,0]).modify('blend', { | ||
with: Color.from('hex','00ff00'), | ||
amount: 0.4 | ||
const color4 = Color.from('rgb', [255, 0, 0]).modify('blend', { | ||
with: Color.from('hex', '00ff00'), | ||
amount: 0.4, | ||
}) | ||
// rgb { r: 153, g: 102, b: 0, a: 255, bitDepth: 8, max: 255 } | ||
let color5 = Color.from('hex','ee5432').modify('blend', { | ||
with: Color.from('rgb',[234, 100, 20, 64]), | ||
amount: 1/3 | ||
}).to('hsv') | ||
const color5 = Color.from('hex', 'ee5432') | ||
.modify('blend', { | ||
with: Color.from('rgb', [234, 100, 20, 64 /* alpha */]), | ||
amount: 1 / 3, | ||
}) | ||
.to('hsv') | ||
// hsv { h: 15, s: 83, v: 93, a: 75 } | ||
let scheme1 = Color.from('rgb',[200, 180, 0]).scheme('splitComplement') | ||
const scheme1 = Color.from('rgb', [200, 180, 0]).scheme('splitComplement') | ||
// [ | ||
// rgb { r: 200, g: 180, b: 0, a: 255, bitDepth: 8, max: 255 }, | ||
// rgb { r: 0, g: 120, b: 200, a: 255, bitDepth: 8, max: 255 }, | ||
// rgb { r: 80, g: 0, b: 200, a: 255, bitDepth: 8, max: 255 } | ||
// rgb { r: 80, g: 0, b: 200, a: 255, bitDepth: 8, max: 255 } | ||
// ] | ||
let scheme2 = Color.from('hsl',[180, 80, 48]).scheme('tetradic', { angle: 40 }) | ||
const scheme2 = Color.from('hsl', [180, 80, 48]).scheme('tetradic', { | ||
angle: 40, | ||
}) | ||
// [ | ||
@@ -108,17 +123,18 @@ // hsl { h: 180, s: 80, l: 48, a: 100 }, | ||
`git clone https://github.com/reiniiriarios/chromaticity-color-utilities.git` | ||
``` | ||
git clone https://github.com/reiniiriarios/chromaticity-color-utilities.git | ||
cd chromaticity-color-utilities | ||
npm i | ||
tsc | ||
``` | ||
`cd chromaticity-color-utilities` | ||
(Typescript not added as dependency, install with `npm i -g typescript`.) | ||
`npm install` | ||
`tsc` | ||
## To Do List | ||
* YUV | ||
* Gamma adjustment modification | ||
* Auto-gamma adjustment and conversion for rec709, rec2020, and jpeg to/from ypbpr | ||
* note to self: rec709 does gamma conversion before while rec2020 does gamma conversion after when converting to ypbpr (I think) | ||
* Write more documentation wrt mathematics. | ||
* Integrate my references better. :) | ||
- YUV | ||
- Gamma adjustment modification | ||
- Auto-gamma adjustment and conversion for rec709, rec2020, and jpeg to/from ypbpr | ||
- note to self: rec709 does gamma conversion before while rec2020 does gamma conversion after when converting to ypbpr (I think) | ||
- Write more documentation wrt mathematics. | ||
- Integrate my references better. :) |
Sorry, the diff of this file is too big to display
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
263528
23
6218
138