mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 21:17:31 +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:
parent
db133f2cb6
commit
f26fd3564a
@ -177,6 +177,7 @@ static void show_map(int skip, int nibbles, int s0, int s1)
|
||||
int w = nibbles-skip;
|
||||
int m = (nibbles+skip) >> 1;
|
||||
int scale = 0;
|
||||
int x0, x1;
|
||||
|
||||
while (w >= XWIDTH/2) {
|
||||
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,
|
||||
XCENTER+(w >> 1), MAP_BUF_Y1, MAP_BUF_RGBA);
|
||||
rectangleColor(surf, (s0-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y0,
|
||||
(s1-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y1, MAP_VIEW_RGBA);
|
||||
x0 = (s0-m+(XCENTER << scale)) >> scale;
|
||||
x1 = x0+((s1-s0) >> scale);
|
||||
rectangleColor(surf, x0, MAP_VIEW_Y0, x1, MAP_VIEW_Y1, MAP_VIEW_RGBA);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user