circle tests
This commit is contained in:
parent
91938021ce
commit
4c643a02f1
|
@ -424,6 +424,10 @@ uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_u
|
|||
#define U8G2_DRAW_LOWER_LEFT 0x04
|
||||
#define U8G2_DRAW_LOWER_RIGHT 0x08
|
||||
#define U8G2_DRAW_ALL (U8G2_DRAW_UPPER_RIGHT|U8G2_DRAW_UPPER_LEFT|U8G2_DRAW_LOWER_RIGHT|U8G2_DRAW_LOWER_LEFT)
|
||||
void u8g2_DrawCircle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option);
|
||||
void u8g2_DrawDisc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option);
|
||||
void u8g2_DrawEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option);
|
||||
void u8g2_DrawFilledEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option);
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
|
|
|
@ -77,18 +77,12 @@ void u8g2_DrawCircle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t r
|
|||
/* check for bounding box */
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
{
|
||||
u8g2_uint_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( u8g2_IsIntersection(u8g2, x0-radp, y0-radp, radp2, radp2) == 0 )
|
||||
return;
|
||||
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
|
||||
return;
|
||||
}
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
|
||||
/* draw circle */
|
||||
u8g2_draw_circle(u8g2, x0, y0, rad, option);
|
||||
}
|
||||
|
@ -169,15 +163,8 @@ void u8g2_DrawDisc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad
|
|||
/* check for bounding box */
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
{
|
||||
u8g2_uint_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( u8g2_IsIntersection(u8g2, x0-radp, y0-radp, radp2, radp2) == 0 )
|
||||
return;
|
||||
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
|
||||
return;
|
||||
}
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
|
@ -314,20 +301,7 @@ void u8g2_DrawEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t
|
|||
/* check for bounding box */
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
{
|
||||
u8g2_uint_t rxp, rxp2;
|
||||
u8g2_uint_t ryp, ryp2;
|
||||
|
||||
rxp = rx;
|
||||
rxp++;
|
||||
rxp2 = rxp;
|
||||
rxp2 *= 2;
|
||||
|
||||
ryp = ry;
|
||||
ryp++;
|
||||
ryp2 = ryp;
|
||||
ryp2 *= 2;
|
||||
|
||||
if ( u8g2_IsIntersection(u8g2, x0-rxp, y0-ryp, rxp2, ryp2) == 0 )
|
||||
if ( u8g2_IsIntersection(u8g2, x0-rx, y0-ry, x0-rx+1, y0-ry+1) == 0 )
|
||||
return;
|
||||
}
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
@ -460,20 +434,7 @@ void u8g2_DrawFilledEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_u
|
|||
/* check for bounding box */
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
{
|
||||
u8g2_uint_t rxp, rxp2;
|
||||
u8g2_uint_t ryp, ryp2;
|
||||
|
||||
rxp = rx;
|
||||
rxp++;
|
||||
rxp2 = rxp;
|
||||
rxp2 *= 2;
|
||||
|
||||
ryp = ry;
|
||||
ryp++;
|
||||
ryp2 = ryp;
|
||||
ryp2 *= 2;
|
||||
|
||||
if ( u8g2_IsIntersection(u8g2, x0-rxp, y0-ryp, rxp2, ryp2) == 0 )
|
||||
if ( u8g2_IsIntersection(u8g2, x0-rx, y0-ry, x0-rx+1, y0-ry+1) == 0 )
|
||||
return;
|
||||
}
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
CC = gcc
|
||||
|
||||
CFLAGS = -g -W -Wall -Wextra -Wcast-qual -Wno-overlength-strings -Wno-unused-parameter -I../../../csrc/.
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_utf8: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o u8g2_utf8
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_utf8
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
#include "u8g2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
u8g2_t u8g2;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0);
|
||||
|
||||
|
||||
u8g2_InitDisplay(&u8g2);
|
||||
u8g2_SetPowerSave(&u8g2, 0);
|
||||
|
||||
u8g2_SetFont(&u8g2, u8g2_font_6x13_tf);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
|
||||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
u8g2_DrawCircle(&u8g2, 11, 11, 5, U8G2_DRAW_ALL);
|
||||
u8g2_DrawStr(&u8g2, 30, 10, "Circle&Disk");
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
utf8_show();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue