diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 0f76c8f7..16d9d138 100755 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -290,6 +290,41 @@ void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0, } } +void Adafruit_GFX::drawOval(int16_t x0, int16_t y0, int16_t r, + uint16_t color) { + int16_t f = 1 - r; + int16_t ddF_x = 1; + int16_t ddF_y = -2 * r; + int16_t x = 0; + int16_t y = r; + + startWrite(); + writePixel(x0 , y0+r, color); + writePixel(x0 , y0-r, color); + writePixel(x0+2*r, y0 , color); + writePixel(x0-2*r, y0 , color); + + while (x= 0) { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x; + + writePixel(x0 + 2*x, y0 + y, color); + writePixel(x0 - 2*x, y0 + y, color); + writePixel(x0 + 2*x, y0 - y, color); + writePixel(x0 - 2*x, y0 - y, color); + writePixel(x0 + 2*y, y0 + x, color); + writePixel(x0 - 2*y, y0 + x, color); + writePixel(x0 + 2*y, y0 - x, color); + writePixel(x0 - 2*y, y0 - x, color); + } + endWrite(); +} void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) { startWrite(); @@ -504,6 +539,31 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0, // Draw a PROGMEM-resident 1-bit image at the specified (x,y) position, // using the specified foreground color (unset bits are transparent). + + +/**************************************************************************/ +/*! + @brief 画五角星 + @param 五角星重心x坐标 + @param 五角星重心y坐标 + @param l 五角星重心到顶点长度 + @param color 16-bit 5-6-5 Color to draw with +*/ +/**************************************************************************/ +void Adafruit_GFX::drawPentengle(int16_t x0, int16_t y0, int16_t l, uint16_t color) { + int16_t x1,y1,x2,y2,x3,y3,x4,y4,x5,y5; + x1=x0;y1=y0-l; + x2=int16_t(x0+0.95*l);y2=int16_t(y0-0.3*l); + x3=int16_t(x0-0.95*l);y3=int16_t(y0-0.3*l); + x4=int16_t(x0+0.59*l);y4=int16_t(y0+0.8*l); + x5=int16_t(x0-0.59*l);y5=int16_t(y0+0.8*l); + drawLine(x1, y1, x4, y4, color); + drawLine(x1, y1, x5, y5, color); + drawLine(x3, y3, x4, y4, color); + drawLine(x2, y2, x5, y5, color); + drawLine(x2, y2, x3, y3, color); +} + void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color) { diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 73e6b1d1..659db193 100755 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -52,6 +52,9 @@ class Adafruit_GFX : public Print { drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color), + + drawOval(int16_t x0, int16_t y0, int16_t r, uint16_t color), + fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color), @@ -65,6 +68,9 @@ class Adafruit_GFX : public Print { int16_t radius, uint16_t color), fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color), + + void drawPentengle(int16_t x0, int16_t y0, int16_t l, uint16_t color);//五角星 + drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color), drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],