Skip to content

Improve accuracy and steadiness of fill levels shown in battery icons

A while ago I started wondering why my battery seemed to drain faster than expected somewhere between 50% and 20%. When looking into this I noticed that it was just an impression generated by the fill level of the battery shown as battery icon, while the numerical presentation of the percentage was just fine. I got that impression, because the icon for a battery capacity of 40% showed a battery with a fill level of ~45%, while the icon for 30% showed a fill level of ~26%. So instead of showing a drop of 10% from a fill level of 40% to a fill level of 30%, it showed a drop of nearly 20% instead! To make that better visible I created an animation of the behavior using the icons present in the repository (scaled up for better visibility):

battery-icons-32-original.webp

As you can see, there is that mentioned big jump between the icons 30% and 40%. I then looked into the 32px SVG-files and started to wonder if it's possible to improve this. Turns out it is. So here is an animation after my changes:

battery-icons-32-fixed.webp

Aside from fixing that big jump, the adjusted icons also offer a much more steady increase and decrease of values and better represent the percentages they should represent. To put that into numbers: While the average deviation of the fill level of the battery in the icon compared to what it should represent was ~3.7% and the maximum deviation was at ~5.2%, after my changes it's at an average of ~0.9% and a maximum of ~1.9%.

Once done with the 32px icons, I went on to look at the other resolutions. While the 16px icons are fine, given the constraints the available number of pixels imposes there, I noticed a problem with the 22px icons as well: Every other step is larger than the other steps. To show that in an animation again:

battery-icons-22-original.webp

It's notable, but not as bad as the problem with the 32px icons. Nevertheless I went on to fix that as well and here is what I got:

battery-icons-22-fixed.webp

As you can see the steps are much more steady now. To put that into numbers as well: While the average deviation from the desired value was ~2.5% before with a maximum of ~8.3%, it's now at an average of ~0.75% with a maximum of ~1.7%.

This merge request contains the changes I made to make the difference in the fill levels of the battery icons more accurate and steady as shown in the animations with the fixed icons. Included are the changes for the regular icons, as well as the dark variants of the icons.

Merge request reports