draw frame
This commit is contained in:
parent
9fca49da84
commit
c2e377e573
|
@ -416,6 +416,7 @@ uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_u
|
|||
/*==========================================*/
|
||||
/* u8g2_box.c */
|
||||
void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h);
|
||||
void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h);
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
|
|
|
@ -20,3 +20,28 @@ void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g
|
|||
} while( h != 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
u8g2_uint_t xtmp = x;
|
||||
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
||||
return;
|
||||
#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);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,10 @@ int main(void)
|
|||
u8g2_DrawBox(&u8g2, 2, 3, 7, 9);
|
||||
u8g2_DrawBox(&u8g2, 12, 3, 2, 13);
|
||||
u8g2_DrawBox(&u8g2, 12,17, 13, 2);
|
||||
u8g2_DrawFrame(&u8g2, 2,21, 11, 7);
|
||||
u8g2_DrawFrame(&u8g2, 25,24, 27, 5);
|
||||
u8g2_DrawStr(&u8g2, 30, 10, "DrawBox");
|
||||
u8g2_DrawStr(&u8g2, 30, 20, "DrawFrame");
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
utf8_show();
|
||||
|
|
Loading…
Reference in New Issue