function cgColorToHex(cgcolor) {
//get 0,255 color type and turn them to hex
r = (cgcolor[0] * 255).toString(16);
g = (cgcolor[1] * 255).toString(16);
b = (cgcolor[2] * 255).toString(16);
//if r,g,b values are 1 digit we need to add a zero
//in order to compose the right hex string
if (r.length == 1) {
r = '0' + r
};
if (g.length == 1) {
g = '0' + g
};
if (b.length == 1) {
b = '0' + b
};
hex = '#' + r + g + b;
return (hex);
}