File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1748,7 +1748,7 @@ PubSub implementation
17481748 If only one, first argument is given,
17491749 treats the value as gray-scale color value.
17501750
1751- @param {Number } r Red channel color value in range 0-255
1751+ @param {Number } r Red channel color value in range 0-255 or {String} r color value in hexadecimal, example: '#FFFFFF'
17521752 @param {Number } g Green channel color value in range 0-255
17531753 @param {Number } b Blue channel color value in range 0-255
17541754 @function
@@ -1757,6 +1757,15 @@ PubSub implementation
17571757 @name setTextColor
17581758 */
17591759 API . setTextColor = function ( r , g , b ) {
1760+ var patt = / # [ 0 - 9 A - F a - f ] { 6 } / ;
1761+ if ( ( typeof r == 'string' ) && patt . test ( r ) ) {
1762+ var hex = r . replace ( '#' , '' ) ;
1763+ var bigint = parseInt ( hex , 16 ) ;
1764+ r = ( bigint >> 16 ) & 255 ;
1765+ g = ( bigint >> 8 ) & 255 ;
1766+ b = bigint & 255 ;
1767+ }
1768+
17601769 if ( ( r === 0 && g === 0 && b === 0 ) || ( typeof g === 'undefined' ) ) {
17611770 textColor = f3 ( r / 255 ) + ' g' ;
17621771 } else {
You can’t perform that action at this time.
0 commit comments