-
Notifications
You must be signed in to change notification settings - Fork 25
/
yes.js
51 lines (39 loc) · 847 Bytes
/
yes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* YES color space
* http://www.atlantis-press.com/php/download_paper.php?id=198
*
* @module color-space/yes
*/
import rgb from './rgb.js';
var yes = {
name: 'yes',
min: [0,0,0],
max: [1,1,1],
channel: ['luminance', 'e-factor', 's-factor']
};
yes.rgb = function(arg){
var y = arg[0], e = arg[1], s = arg[2];
var m = [
1, 1.431, .126,
1, -.569, .126,
1, .431, -1.874
];
var r = y * m[0] + e * m[1] + s * m[2],
g = y * m[3] + e * m[4] + s * m[5],
b = y * m[6] + e * m[7] + s * m[8];
return [r*255, g*255, b*255];
};
rgb.yes = function(arg) {
var r = arg[0] / 255, g = arg[1] / 255, b = arg[2] / 255;
var m = [
.253, .684, .063,
.500, -.50, .0,
.250, .250, -.5
];
return [
r * m[0] + g * m[1] + b * m[2],
r * m[3] + g * m[4] + b * m[5],
r * m[6] + g * m[7] + b * m[8]
];
};
export default yes;