diff options
author | Tectu <joel@unormal.org> | 2012-07-10 01:15:31 +0200 |
---|---|---|
committer | Tectu <joel@unormal.org> | 2012-07-10 01:15:31 +0200 |
commit | ed39db99a579342ad354b00f5639258f43528e6d (patch) | |
tree | 288aec28c6391a3b0dc67e14f82153cc98004bf7 | |
parent | 3e6d376e1eb7f61628ab65b058511a55a9e0f22c (diff) | |
download | uGFX-ed39db99a579342ad354b00f5639258f43528e6d.tar.gz uGFX-ed39db99a579342ad354b00f5639258f43528e6d.tar.bz2 uGFX-ed39db99a579342ad354b00f5639258f43528e6d.zip |
added lcdDrawEllipse() - contributed by Ben William
-rw-r--r-- | glcd.c | 28 | ||||
-rw-r--r-- | glcd.h | 1 | ||||
-rw-r--r-- | lcd.mk | 1 |
3 files changed, 30 insertions, 0 deletions
@@ -319,6 +319,34 @@ 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) { + 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 { + 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) { + dx++; + err += (2*dx+1)*b2; + } + if(e2 > -(2*dy-1)*a2) { + dy--; + err -= (2*dy-1)*a2; + } + } while(dy >= 0); + + while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */ + lcdDrawPixel(x+dx, y, color); /* -> Spitze der Ellipse vollenden */ + lcdDrawPixel(x-dx, y, color); + } +} + void lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) { lld_lcdVerticalScroll(x0,y0,x1,y1,lines); } @@ -67,6 +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); /* 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); @@ -8,6 +8,7 @@ LCDSRC = $(LCDLIB)/glcd.c \ $(LCDLIB)/graph.c \ $(LCDLIB)/gui.c \ $(LCDLIB)/console.c \ + $(LCDLIB)/fastMath.c \ $(LCD_DRIVERS_SRC) LCDINC = $(LCDLIB) \ |