-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorManagement.js
49 lines (46 loc) · 1.14 KB
/
colorManagement.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
module.exports = {
RGBtoBGRInverted:function(r,b,g)
{
var BGRValue = (b*65536)+(g*256)+r;
return BGRValue;
},
RGBtoBGR:function(r,g,b)
{
var BGRValue = (r*65536)+(g*256)+b;
return BGRValue;
},
componentToHex:function(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
},
rgbToHex:function(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
},
hexToRgb:function(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
}
/*
function RGBtoBGRInverted(r,g,b)
{
var BGRValue = (b*65536)+(g*256)+r;
return BGRValue;
}
function RGBtoBGR(r,g,b)
{
var BGRValue = (r*65536)+(g*256)+b;
return BGRValue;
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
*/