diff --git a/package/contents/ui/CompactRepresentation.qml b/package/contents/ui/CompactRepresentation.qml index 58d06d8..2006016 100644 --- a/package/contents/ui/CompactRepresentation.qml +++ b/package/contents/ui/CompactRepresentation.qml @@ -29,7 +29,7 @@ Item { anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom - color: Helper.interpolateColor(parseFloat("." + batteryPercent), [ colorEmpty, colorHalf, colorFull ]) + color: Helper.interpolateColor(batteryPercent / 100, [ colorEmpty, colorHalf, colorFull ]) width: parent.width * Math.max(0, Math.min(batteryPercent, 100)) / 100 } Kirigami.Icon { // headphones icon diff --git a/package/contents/ui/lib/helper.js b/package/contents/ui/lib/helper.js index 307f6bb..9dec12c 100644 --- a/package/contents/ui/lib/helper.js +++ b/package/contents/ui/lib/helper.js @@ -14,7 +14,7 @@ const rgb2Hex = rgb => "#" + ((1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b). const interpolateColor = (f, c) => { if(!f) return "transparent"; if(f >= 1) return c.pop(); - if(f <= 0) return c[0]; + if(f <= 0) return c.shift(); f *= c.length - 1; const i = ~~f;