client/js/main.js
changeset 459 98cae534083d
parent 444 19f0b7803aed
child 461 48235ed6b07d
equal deleted inserted replaced
458:423bdf56d103 459:98cae534083d
   559             _selector.css({
   559             _selector.css({
   560                 left: (_options.tooltip_padding + Math.min(_left, _right)),
   560                 left: (_options.tooltip_padding + Math.min(_left, _right)),
   561                 top: (_options.tooltip_padding + _top)
   561                 top: (_options.tooltip_padding + _top)
   562             });
   562             });
   563             return _path;
   563             return _path;
       
   564         },
       
   565         // from http://stackoverflow.com/a/6444043
       
   566         increaseBrightness: function (hex, percent){
       
   567             // strip the leading # if it's there
       
   568             hex = hex.replace(/^\s*#|\s*$/g, '');
       
   569 
       
   570             // convert 3 char codes --> 6, e.g. `E0F` --> `EE00FF`
       
   571             if(hex.length === 3){
       
   572                 hex = hex.replace(/(.)/g, '$1$1');
       
   573             }
       
   574 
       
   575             var r = parseInt(hex.substr(0, 2), 16),
       
   576                 g = parseInt(hex.substr(2, 2), 16),
       
   577                 b = parseInt(hex.substr(4, 2), 16);
       
   578 
       
   579             return '#' +
       
   580                ((0|(1<<8) + r + (256 - r) * percent / 100).toString(16)).substr(1) +
       
   581                ((0|(1<<8) + g + (256 - g) * percent / 100).toString(16)).substr(1) +
       
   582                ((0|(1<<8) + b + (256 - b) * percent / 100).toString(16)).substr(1);
   564         }
   583         }
   565     };
   584     };
   566 })(window);
   585 })(window);
   567 
   586 
   568 /* END main.js */
   587 /* END main.js */