introduced asymetric intersection check

This commit is contained in:
olikraus 2016-04-19 21:26:09 +02:00
parent a50e75b59d
commit 516b8efc56
4 changed files with 53 additions and 15 deletions

View File

@ -203,7 +203,7 @@ void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len
void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
{
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+len-1, y) == 0 )
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 0);
@ -212,7 +212,7 @@ void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
{
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x, y+len-1) == 0 )
if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 1);

View File

@ -46,6 +46,7 @@
#ifdef U8G2_WITH_INTERSECTION
#ifdef OLD_VERSION_WITH_SYMETRIC_BOUNDARIES
/*
intersection assumptions:
@ -70,7 +71,6 @@
assert( u8g2_is_intersection_decision_tree(7, 9, 4, 6) == 0 );
*/
//static uint8_t U8G2_ALWAYS_INLINE u8g2_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
static uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
{
@ -112,6 +112,55 @@ static uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1
}
}
#endif /* OLD_VERSION_WITH_SYMETRIC_BOUNDARIES */
/*
version with asymetric boundaries.
a1 and v1 are excluded
v0 == v1 is not support end return 1
*/
uint8_t u8g2_is_intersection_decision_tree(uint8_t a0, uint8_t a1, uint8_t v0, uint8_t v1)
{
if ( v0 < a1 ) // v0 <= a1
{
if ( v1 > a0 ) // v1 >= a0
{
return 1;
}
else
{
if ( v0 > v1 ) // v0 > v1
{
return 1;
}
else
{
return 0;
}
}
}
else
{
if ( v1 > a0 ) // v1 >= a0
{
if ( v0 > v1 ) // v0 > v1
{
return 1;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
}
/* usually upper limits are not included, however this intersection check INCLUDES the limits */
uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1)

View File

@ -108,9 +108,6 @@ void u8g2_update_dimension_r0(u8g2_t *u8g2)
u8g2->user_y0 = u8g2->buf_y0;
u8g2->user_y1 = u8g2->buf_y1;
u8g2->user_x1--;
u8g2->user_y1--;
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
@ -128,9 +125,6 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2)
u8g2->user_y0 = 0;
u8g2->user_y1 = u8g2->pixel_buf_width;
u8g2->user_x1--;
u8g2->user_y1--;
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
@ -145,9 +139,6 @@ void u8g2_update_dimension_r2(u8g2_t *u8g2)
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
u8g2->user_x1--;
u8g2->user_y1--;
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
@ -165,9 +156,6 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2)
u8g2->user_y0 = 0;
u8g2->user_y1 = u8g2->pixel_buf_width;
u8g2->user_x1--;
u8g2->user_y1--;
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}

View File

@ -209,6 +209,7 @@ uint8_t u8g_is_intersection_math(uint8_t a0, uint8_t a1, uint8_t v0, uint8_t v1)
/*
version with asymetric boundaries.
a1 and v1 are excluded
v0 == v1 is not support end return 1
*/
uint8_t u8g_is_intersection_decision_tree(uint8_t a0, uint8_t a1, uint8_t v0, uint8_t v1)
{