Date:2013-01-31 08:03:31 (10 years 8 months ago)
Author:Werner Almesberger
Commit:f26fd3564a2664fe3deea5b86bd46e8dad8209ac
Message: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.
Files: ubb-la/gui.c (2 diffs)

Change Details

ubb-la/gui.c
177177    int w = nibbles-skip;
178178    int m = (nibbles+skip) >> 1;
179179    int scale = 0;
180    int x0, x1;
180181
181182    while (w >= XWIDTH/2) {
182183        w >>= 1;
...... 
184185    }
185186    boxColor(surf, XCENTER-(w >> 1), MAP_BUF_Y0,
186187        XCENTER+(w >> 1), MAP_BUF_Y1, MAP_BUF_RGBA);
187    rectangleColor(surf, (s0-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y0,
188        (s1-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y1, MAP_VIEW_RGBA);
188    x0 = (s0-m+(XCENTER << scale)) >> scale;
189    x1 = x0+((s1-s0) >> scale);
190    rectangleColor(surf, x0, MAP_VIEW_Y0, x1, MAP_VIEW_Y1, MAP_VIEW_RGBA);
189191}
190192
191193

Archive Download the corresponding diff file

Branches:
master



interactive