@@ -312,28 +312,22 @@ void QwGrBufferDevice::draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
312312//
313313// Draw a rectangle on screen.
314314
315- void QwGrBufferDevice::rectangle (uint8_t x0, uint8_t y0, uint8_t x1 , uint8_t y1 , uint8_t clr){
315+ void QwGrBufferDevice::rectangle (uint8_t x0, uint8_t y0, uint8_t width , uint8_t height , uint8_t clr){
316316
317317 // Is this a line?
318- if (x0 == x1 || y0 == y1 ){
318+ if (width <= 1 || height <= 1 ){
319319 // this is a line
320- line (x0, y0, x1, y1 );
320+ line (x0, y0, x0+width- 1 , y0+height- 1 );
321321 return ;
322322 }
323323
324- // Sanity check
325- if (x0 > x1 || y0 > y1){
326- swap_int (x0, x1);
327- swap_int (y0, y1);
328- }
329-
330324 // bounds check
331325 if (x0 >= _viewport.width || y0 >= _viewport.height )
332326 return ; // not on screen
333327
334328 // Send to drawing routine.
335329
336- (*_idraw.draw_rect )(this , x0, y0, x1, y1 , clr);
330+ (*_idraw.draw_rect )(this , x0, y0, width, height , clr);
337331
338332}
339333
@@ -342,11 +336,14 @@ void QwGrBufferDevice::rectangle(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
342336//
343337// Does the actual drawing/logic
344338
345- void QwGrBufferDevice::draw_rect (uint8_t x0, uint8_t y0, uint8_t x1 , uint8_t y1 , uint8_t clr){
339+ void QwGrBufferDevice::draw_rect (uint8_t x0, uint8_t y0, uint8_t width , uint8_t height , uint8_t clr){
346340
347341
348342 // A rect is really just a series of vert and horz lines
349343
344+ uint8_t x1 = x0 + width-1 ;
345+ uint8_t y1 = y0 + height-1 ;
346+
350347 (*_idraw.draw_line_horz )(this , x0, y0, x1, y0, clr);
351348 (*_idraw.draw_line_horz )(this , x0, y1, x1, y1, clr);
352349
@@ -364,37 +361,34 @@ void QwGrBufferDevice::draw_rect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
364361// //////////////////////////////////////////////////////////////////////////////////////
365362// rectangle_fill()
366363
367- void QwGrBufferDevice::rectangle_fill (uint8_t x0, uint8_t y0, uint8_t x1 , uint8_t y1 , uint8_t clr){
364+ void QwGrBufferDevice::rectangle_fill (uint8_t x0, uint8_t y0, uint8_t width , uint8_t height , uint8_t clr){
368365
369366
370- if (x0 == x1 || y0 == y1){
367+ // Is this a line?
368+ if (width <=1 || height <=1 ){
371369 // this is a line
372- line (x0, y0, x1, y1 );
370+ line (x0, y0, x0+width- 1 , y0+height- 1 );
373371 return ;
374372 }
375-
376- // Sanity check
377- if (x0 > x1 || y0 > y1){
378- swap_int (x0, x1);
379- swap_int (y0, y1);
380- }
381-
382373 // bounds check
383374 if (x0 >= _viewport.width || y0 >= _viewport.height )
384375 return ; // not on screen
385376
386377 // Send to drawing routine.
387378
388- (*_idraw.draw_rect_filled )(this , x0, y0, x1, y1 , clr);
379+ (*_idraw.draw_rect_filled )(this , x0, y0, width, height , clr);
389380
390381}
391382// //////////////////////////////////////////////////////////////////////////////////////
392383// draw_rect_fill()
393384//
394385// Does the actual drawing/logic
395386
396- void QwGrBufferDevice::draw_rect_filled (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t clr){
387+ void QwGrBufferDevice::draw_rect_filled (uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, uint8_t clr){
388+
397389
390+ uint8_t x1 = x0 + width-1 ;
391+ uint8_t y1 = y0 + height-1 ;
398392
399393 // Just draw vertical lines
400394 for (int i=x0; i <= x1; i++)
0 commit comments