Skip to content

Commit 5502399

Browse files
committed
Merge pull request parallax#135 from MrRio/pr/134
Pr/134
2 parents d38db1e + 0231299 commit 5502399

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

jspdf.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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-9A-Fa-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 {

0 commit comments

Comments
 (0)