aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/fbsplash.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 51ba4729e..bc9ac8fe1 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -213,14 +213,15 @@ static void fb_drawfullrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos,
213 */ 213 */
214static void fb_drawprogressbar(unsigned percent) 214static void fb_drawprogressbar(unsigned percent)
215{ 215{
216 int i, left_x, top_y, width, height; 216 int left_x, top_y, pos_x;
217 unsigned width, height;
217 218
218 // outer box 219 // outer box
219 left_x = G.nbar_posx; 220 left_x = G.nbar_posx;
220 top_y = G.nbar_posy; 221 top_y = G.nbar_posy;
221 width = G.nbar_width - 1; 222 width = G.nbar_width - 1;
222 height = G.nbar_height - 1; 223 height = G.nbar_height - 1;
223 if ((height | width) < 0) 224 if ((int)(height | width) < 0)
224 return; 225 return;
225 // NB: "width" of 1 actually makes rect with width of 2! 226 // NB: "width" of 1 actually makes rect with width of 2!
226 fb_drawrectangle(); 227 fb_drawrectangle();
@@ -230,30 +231,37 @@ static void fb_drawprogressbar(unsigned percent)
230 top_y++; 231 top_y++;
231 width -= 2; 232 width -= 2;
232 height -= 2; 233 height -= 2;
233 if ((height | width) < 0) 234 if ((int)(height | width) < 0)
234 return; 235 return;
235 fb_drawfullrectangle(
236 left_x, top_y,
237 left_x + width, top_y + height,
238 G.nbar_colr, G.nbar_colg, G.nbar_colb);
239 236
237 pos_x = left_x;
240 if (percent > 0) { 238 if (percent > 0) {
239 int y;
240 unsigned i;
241
241 // actual progress bar 242 // actual progress bar
242 width = width * percent / 100; 243 pos_x += (unsigned)(width * percent) / 100;
244
245 y = top_y;
243 i = height; 246 i = height;
244 if (height == 0) 247 if (height == 0)
245 height++; // divide by 0 is bad 248 height++; // divide by 0 is bad
246 while (i >= 0) { 249 while (i >= 0) {
247 // draw one-line thick "rectangle" 250 // draw one-line thick "rectangle"
248 // top line will have gray lvl 200, bottom one 100 251 // top line will have gray lvl 200, bottom one 100
249 unsigned gray_level = 100 + i*100/height; 252 unsigned gray_level = 100 + i*100 / height;
250 fb_drawfullrectangle( 253 fb_drawfullrectangle(
251 left_x, top_y, left_x + width, top_y, 254 left_x, y, pos_x, y,
252 gray_level, gray_level, gray_level); 255 gray_level, gray_level, gray_level);
253 top_y++; 256 y++;
254 i--; 257 i--;
255 } 258 }
256 } 259 }
260
261 fb_drawfullrectangle(
262 pos_x, top_y,
263 left_x + width, top_y + height,
264 G.nbar_colr, G.nbar_colg, G.nbar_colb);
257} 265}
258 266
259 267