Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. function cgColorToHex(cgcolor) {
  2.                
  3.     //get 0,255 color type and turn them to hex
  4.     r = (cgcolor[0] * 255).toString(16);
  5.     g = (cgcolor[1] * 255).toString(16);
  6.     b = (cgcolor[2] * 255).toString(16);
  7.     //if r,g,b values are 1 digit we need to add a zero
  8.     //in order to compose the right hex string
  9.     if (r.length == 1) {
  10.         r = '0' + r
  11.     };
  12.     if (g.length == 1) {
  13.         g = '0' + g
  14.     };
  15.     if (b.length == 1) {
  16.         b = '0' + b
  17.     };
  18.     hex = '#' + r + g + b;
  19.     return (hex);
  20. }