1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-23 22:11:53 +02:00

ubb-la/gui.c (show_map): keep view rectangle size constant

Before, we had rounding effects that could make the rectangle width vary by
one pixel, depending on position.
This commit is contained in:
Werner Almesberger 2013-01-31 04:03:31 -03:00
parent db133f2cb6
commit f26fd3564a

View File

@ -177,6 +177,7 @@ static void show_map(int skip, int nibbles, int s0, int s1)
int w = nibbles-skip; int w = nibbles-skip;
int m = (nibbles+skip) >> 1; int m = (nibbles+skip) >> 1;
int scale = 0; int scale = 0;
int x0, x1;
while (w >= XWIDTH/2) { while (w >= XWIDTH/2) {
w >>= 1; w >>= 1;
@ -184,8 +185,9 @@ static void show_map(int skip, int nibbles, int s0, int s1)
} }
boxColor(surf, XCENTER-(w >> 1), MAP_BUF_Y0, boxColor(surf, XCENTER-(w >> 1), MAP_BUF_Y0,
XCENTER+(w >> 1), MAP_BUF_Y1, MAP_BUF_RGBA); XCENTER+(w >> 1), MAP_BUF_Y1, MAP_BUF_RGBA);
rectangleColor(surf, (s0-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y0, x0 = (s0-m+(XCENTER << scale)) >> scale;
(s1-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y1, MAP_VIEW_RGBA); x1 = x0+((s1-s0) >> scale);
rectangleColor(surf, x0, MAP_VIEW_Y0, x1, MAP_VIEW_Y1, MAP_VIEW_RGBA);
} }