Fix TS error and prevent extra string conversion

This commit is contained in:
Kevin Schmidt
2018-10-01 07:29:16 -06:00
parent a2c7eb80fd
commit d6b99a5a25

View File

@@ -2076,9 +2076,10 @@ function whenParser(node, objectStack) {
function writeColorTextNode(node, color) {
const rgba = asArray(color);
const opacity = (rgba.length == 4) ? rgba[3] : 1;
/** @type {Array<string|number>} */
const abgr = [opacity * 255, rgba[2], rgba[1], rgba[0]];
for (let i = 0; i < 4; ++i) {
const hex = parseInt(abgr[i], 10).toString(16);
const hex = Math.floor(/** @type {number} */ (abgr[i])).toString(16);
abgr[i] = (hex.length == 1) ? '0' + hex : hex;
}
writeStringTextNode(node, abgr.join(''));