diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2022-05-30 13:35:00 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2022-06-02 12:17:43 +0200 |
commit | fea27dd2b781685869301e397ff309476a304202 (patch) | |
tree | e00799573439620301206c67014f118b31f65cbc | |
parent | 6b351f52954bd7ec078c08b15b8ec97d5db7c41f (diff) | |
download | skin-nopacity-fea27dd2b781685869301e397ff309476a304202.tar.gz skin-nopacity-fea27dd2b781685869301e397ff309476a304202.tar.bz2 |
Volume bar gradient optimization
The volume bar was not rendered with a linear gradient.
The gradient is now linear and the number of steps depends on the bar
width.
-rw-r--r-- | displayvolume.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/displayvolume.c b/displayvolume.c index 9a8fe4f..997a6fc 100644 --- a/displayvolume.c +++ b/displayvolume.c @@ -103,29 +103,30 @@ tColor cNopacityDisplayVolume::DrawProgressbarBackground(int left, int top, int tColor clr1 = Theme.Color(clrProgressBar); tColor clr2 = Theme.Color(clrProgressBarBlend); tColor clr = 0x00000000; - int step = width / 256; - int alpha = 0x0; - int alphaStep; - int maximum = 0; - if (step == 0) { //width < 256 - step = 1; - alphaStep = 256 / width; - maximum = width; - } else { //width > 256 - alphaStep = 0x1; - maximum = 256; + + int alpha = 0x0; // 0...255 + int alphaStep = 0x1; + int maximumsteps = 256; // alphaStep * maximumsteps <= 256 + int factor = 2; // max. 128 steps + + double step = width / maximumsteps; + if (width < 128) { // width < 128 + factor = 4 * factor; // 32 steps + } else if (width < 256) { // width < 256 + factor = 2 * factor; // 64 steps } - int x = 0; - for (int i = 0; i < maximum; i++) { - x = left + i*step; + + step = step * factor; + alphaStep = alphaStep * factor; + maximumsteps = maximumsteps / factor; + + int x = left + height / 2; + for (int i = 0; i < maximumsteps; i++) { + x = left + height / 2 + i * step; clr = AlphaBlend(clr1, clr2, alpha); - pixmapProgressBar->DrawRectangle(cRect(x,top,step,height), clr); + pixmapProgressBar->DrawRectangle(cRect(x, top, step + 1, height), clr); alpha += alphaStep; } - if (step > 0) { - int rest = width - step*256; - pixmapProgressBar->DrawRectangle(cRect(left+step*256, top, rest, height), clr); - } return clr; } |