diff --git a/appIconIndicators.js b/appIconIndicators.js index b9952c1e9..bfeb6e55c 100644 --- a/appIconIndicators.js +++ b/appIconIndicators.js @@ -876,39 +876,35 @@ class UnityIndicator extends IndicatorBase { offsetEnd: defaultValues.offsetEnd ?? 1.0, }; - let hasValue, value1, value2; - - [hasValue, value1] = node.lookup_color(elementName, false); - if (hasValue) { - output.colorStart = value1; + const [hasElementName, elementNameValue] = node.lookup_color(elementName, false); + if (hasElementName) { + output.colorStart = elementNameValue; output.colorEnd = null; } else { - [hasValue, value1] = node.lookup_color(`${elementName}-color-start`, false); - if (hasValue) { - [hasValue, value2] = node.lookup_color(`${elementName}-color-end`, false); - if (hasValue) { - output.colorStart = value1; - output.colorEnd = value2; - } + const [hasColorStart, colorStartValue] = node.lookup_color(`${elementName}-color-start`, false); + const [hasColorEnd, colorEndValue] = node.lookup_color(`${elementName}-color-end`, false); + if (hasColorStart && hasColorEnd) { + output.colorStart = colorStartValue; + output.colorEnd = colorEndValue; } } - [hasValue, value1] = node.lookup_color(`${elementName}-offset-start`, false); - if (hasValue) - output.offsetStart = value1; + const [hasOffsetStart, offsetStartvalue] = node.lookup_color(`${elementName}-offset-start`, false); + if (hasOffsetStart) + output.offsetStart = offsetStartvalue; - [hasValue, value1] = node.lookup_color(`${elementName}-offset-end`, false); - if (hasValue) - output.offsetEnd = value1; + const [hasOffsetEnd, offsetEndValue] = node.lookup_color(`${elementName}-offset-end`, false); + if (hasOffsetEnd) + output.offsetEnd = offsetEndValue; return output; } _readElementData(node, elementName, defaultValues) { - let lineWidth = defaultValues.lineWidth ?? 1.0; - const [hasValue, value1] = node.lookup_double(`${elementName}-line-width`, false); - if (hasValue) - lineWidth = value1; + const defaultLineWidth = defaultValues.lineWidth ?? 1.0; + let [hasValue, lineWidth] = node.lookup_double(`${elementName}-line-width`, false); + if (!hasValue) + lineWidth = defaultLineWidth; return { background: this._readGradientData(node, `${elementName}-background`, defaultValues.background), @@ -918,10 +914,8 @@ class UnityIndicator extends IndicatorBase { } _createGradient(values, x0, y0, x1, y1) { - let gradient; - if (values.colorEnd) { - gradient = new Cairo.LinearGradient(x0, y0, x1, y1); + const gradient = new Cairo.LinearGradient(x0, y0, x1, y1); gradient.addColorStopRGBA(values.offsetStart, values.colorStart.red / 255, values.colorStart.green / 255, @@ -932,13 +926,14 @@ class UnityIndicator extends IndicatorBase { values.colorEnd.green / 255, values.colorEnd.blue / 255, values.colorEnd.alpha / 255); + return gradient; } else { - gradient = Cairo.SolidPattern.createRGBA(values.colorStart.red / 255, + const gradient = Cairo.SolidPattern.createRGBA(values.colorStart.red / 255, values.colorStart.green / 255, values.colorStart.blue / 255, values.colorStart.alpha / 255); + return gradient; } - return gradient; } _drawProgressOverlay(area) {