DrawFrame: Draw corners just once, fixes XOR mode.

This commit is contained in:
Rudo Thomas 2020-04-02 16:23:07 +02:00
parent 21f5a74dff
commit 0324a95051
1 changed files with 12 additions and 9 deletions

View File

@ -57,8 +57,6 @@ void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g
/*
draw a frame (empty box)
restriction: does not work for w = 0 or h = 0
ToDo:
pixel in the corners are drawn twice. This could be optimized.
*/
void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
{
@ -70,13 +68,18 @@ void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u
#endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, w, 0);
u8g2_DrawHVLine(u8g2, x, y, h, 1);
x+=w;
x--;
u8g2_DrawHVLine(u8g2, x, y, h, 1);
y+=h;
y--;
u8g2_DrawHVLine(u8g2, xtmp, y, w, 0);
if (h >= 2) {
h-=2;
y++;
if (h > 0) {
u8g2_DrawHVLine(u8g2, x, y, h, 1);
x+=w;
x--;
u8g2_DrawHVLine(u8g2, x, y, h, 1);
y+=h;
}
u8g2_DrawHVLine(u8g2, xtmp, y, w, 0);
}
}