drawCircle and drawFilledCircle re-added
This commit is contained in:
+51
-26
@@ -211,32 +211,57 @@ void BitmapBuffer::drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, ui
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//void BitmapBuffer::drawCircle(int x0, int y0, int radius)
|
|
||||||
//{
|
void BitmapBuffer::drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags)
|
||||||
// int x = radius;
|
{
|
||||||
// int y = 0;
|
int x1 = radius;
|
||||||
// int decisionOver2 = 1 - x;
|
int y1 = 0;
|
||||||
//
|
int decisionOver2 = 1 - x1;
|
||||||
// while (y <= x) {
|
pixel_t color = lcdColorTable[COLOR_IDX(flags)];
|
||||||
// drawPixel(x+x0, y+y0, WHITE);
|
|
||||||
// drawPixel(y+x0, x+y0, WHITE);
|
APPLY_OFFSET();
|
||||||
// drawPixel(-x+x0, y+y0, WHITE);
|
|
||||||
// drawPixel(-y+x0, x+y0, WHITE);
|
while (y1 <= x1) {
|
||||||
// drawPixel(-x+x0, -y+y0, WHITE);
|
drawPixel(x1 + x, y1 + y, color);
|
||||||
// drawPixel(-y+x0, -x+y0, WHITE);
|
drawPixel(y1 + x, x1 + y, color);
|
||||||
// drawPixel(x+x0, -y+y0, WHITE);
|
drawPixel(-x1 + x, y1 + y, color);
|
||||||
// drawPixel(y+x0, -x+y0, WHITE);
|
drawPixel(-y1 + x, x1 + y, color);
|
||||||
// y++;
|
drawPixel(-x1 + x, -y1 + y, color);
|
||||||
// if (decisionOver2 <= 0) {
|
drawPixel(-y1 + x, -x1 + y, color);
|
||||||
// decisionOver2 += 2*y + 1;
|
drawPixel(x1 + x, -y1 + y, color);
|
||||||
// }
|
drawPixel(y1 + x, -x1 + y, color);
|
||||||
// else {
|
y1++;
|
||||||
// x--;
|
if (decisionOver2 <= 0) {
|
||||||
// decisionOver2 += 2 * (y-x) + 1;
|
decisionOver2 += 2 * y1 + 1;
|
||||||
// }
|
}
|
||||||
// }
|
else {
|
||||||
//}
|
x1--;
|
||||||
//
|
decisionOver2 += 2 * (y1 - x1) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags)
|
||||||
|
{
|
||||||
|
coord_t imax = ((coord_t)((coord_t)radius * 707)) / 1000 + 1;
|
||||||
|
coord_t sqmax = (coord_t)radius * (coord_t)radius + (coord_t)radius / 2;
|
||||||
|
coord_t x1 = radius;
|
||||||
|
drawSolidHorizontalLine(x - radius, y, radius * 2, flags);
|
||||||
|
for (coord_t i = 1; i <= imax; i++) {
|
||||||
|
if ((i * i + x1 * x1) > sqmax) {
|
||||||
|
// Draw lines from outside
|
||||||
|
if (x1 > imax) {
|
||||||
|
drawSolidHorizontalLine(x - i + 1, y + x1, (i - 1) * 2, flags);
|
||||||
|
drawSolidHorizontalLine(x - i + 1, y - x1, (i - 1) * 2, flags);
|
||||||
|
}
|
||||||
|
x1--;
|
||||||
|
}
|
||||||
|
// Draw lines from inside (center)
|
||||||
|
drawSolidHorizontalLine(x - x1, y + i, x1 * 2, flags);
|
||||||
|
drawSolidHorizontalLine(x - x1, y - i, x1 * 2, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//bool evalSlopes(int * slopes, int startAngle, int endAngle)
|
//bool evalSlopes(int * slopes, int startAngle, int endAngle)
|
||||||
//{
|
//{
|
||||||
// if (startAngle >= 360 || endAngle <= 0)
|
// if (startAngle >= 360 || endAngle <= 0)
|
||||||
|
|||||||
+3
-1
@@ -354,7 +354,9 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
|||||||
|
|
||||||
void invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags = 0);
|
void invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags = 0);
|
||||||
|
|
||||||
void drawCircle(int x0, int y0, int radius);
|
void drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags = 0);
|
||||||
|
|
||||||
|
void drawFilledCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags = 0);
|
||||||
|
|
||||||
void drawPie(int x0, int y0, int radius, int startAngle, int endAngle);
|
void drawPie(int x0, int y0, int radius, int startAngle, int endAngle);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user