Fix TS error and prevent extra string conversion
This commit is contained in:
@@ -2076,9 +2076,10 @@ function whenParser(node, objectStack) {
|
|||||||
function writeColorTextNode(node, color) {
|
function writeColorTextNode(node, color) {
|
||||||
const rgba = asArray(color);
|
const rgba = asArray(color);
|
||||||
const opacity = (rgba.length == 4) ? rgba[3] : 1;
|
const opacity = (rgba.length == 4) ? rgba[3] : 1;
|
||||||
|
/** @type {Array<string|number>} */
|
||||||
const abgr = [opacity * 255, rgba[2], rgba[1], rgba[0]];
|
const abgr = [opacity * 255, rgba[2], rgba[1], rgba[0]];
|
||||||
for (let i = 0; i < 4; ++i) {
|
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;
|
abgr[i] = (hex.length == 1) ? '0' + hex : hex;
|
||||||
}
|
}
|
||||||
writeStringTextNode(node, abgr.join(''));
|
writeStringTextNode(node, abgr.join(''));
|
||||||
|
|||||||
Reference in New Issue
Block a user