算法如下,具体的算法名称和原理是什么呢
void ST7789_Draw_Circle(uint16_t x0, uint16_t y0, uint8_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;
ST7789_DrawPixel(x0, y0 + r, color);
ST7789_DrawPixel(x0, y0 - r, color);
ST7789_DrawPixel(x0 + r, y0, color);
ST7789_DrawPixel(x0 - r, y0, color);
while (x < y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
ST7789_DrawPixel(x0 + x, y0 + y, color);
ST7789_DrawPixel(x0 - x, y0 + y, color);
ST7789_DrawPixel(x0 + x, y0 - y, color);
ST7789_DrawPixel(x0 - x, y0 - y, color);
ST7789_DrawPixel(x0 + y, y0 + x, color);
ST7789_DrawPixel(x0 - y, y0 + x, color);
ST7789_DrawPixel(x0 + y, y0 - x, color);
ST7789_DrawPixel(x0 - y, y0 - x, color);
}
} |