Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Adafruit_GFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<y) {
if (f >= 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();
Expand Down Expand Up @@ -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) {

Expand Down
6 changes: 6 additions & 0 deletions Adafruit_GFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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[],
Expand Down