drawEllipse: added a filled option
This commit is contained in:
parent
51f6f84111
commit
578e0db66e
2 changed files with 11 additions and 6 deletions
7
glcd.c
7
glcd.c
|
@ -319,16 +319,21 @@ void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint
|
|||
} while(a <= b);
|
||||
}
|
||||
|
||||
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint16_t color) {
|
||||
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint16_t color, uint8_t filled) {
|
||||
int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */
|
||||
long a2 = a*a, b2 = b*b;
|
||||
long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */
|
||||
|
||||
do {
|
||||
if(filled){
|
||||
lcdDrawLine(x-dx,y+dy,x+dx,y+dy);
|
||||
lcdDrawLine(x-dx,y-dy,x+dx,y-dy);
|
||||
}else{
|
||||
lcdDrawPixel(x+dx, y+dy, color); /* I. Quadrant */
|
||||
lcdDrawPixel(x-dx, y+dy, color); /* II. Quadrant */
|
||||
lcdDrawPixel(x-dx, y-dy, color); /* III. Quadrant */
|
||||
lcdDrawPixel(x+dx, y-dy, color); /* IV. Quadrant */
|
||||
}
|
||||
|
||||
e2 = 2*err;
|
||||
if(e2 < (2*dx+1)*b2) {
|
||||
|
|
2
glcd.h
2
glcd.h
|
@ -67,7 +67,7 @@ void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t co
|
|||
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color);
|
||||
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, font_t font, uint16_t fontColor, uint16_t bkColor);
|
||||
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
|
||||
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint16_t color);
|
||||
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint16_t color, uint8_t filled);
|
||||
|
||||
/* Text Rendering Functions */
|
||||
int lcdDrawChar(uint16_t cx, uint16_t cy, char c, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText);
|
||||
|
|
Loading…
Add table
Reference in a new issue