Merge pull request #8758 from schmidtk/ts-kml-color-node

Fix TS error and prevent extra string conversion
This commit is contained in:
Andreas Hocevar
2018-10-01 15:45:32 +02:00
committed by GitHub

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(''));