//在指定位置画一个指定大小的圆
//(x,y):中心点
//r :半径
void Draw_Circle(u16 x0,u16 y0,u8 r)
{
int a,b;
int di;
a=0;b=r;
di=3-(r<<1); //判断下个点位置的标志
while(a<=b)
{
LCD_DrawPoint(x0-b,y0-a); //3
LCD_DrawPoint(x0+b,y0-a); //0
LCD_DrawPoint(x0-a,y0+b); //1
LCD_DrawPoint(x0-b,y0-a); //7
LCD_DrawPoint(x0-a,y0-b); //2
LCD_DrawPoint(x0+b,y0+a); //4
LCD_DrawPoint(x0+a,y0-b); //5
LCD_DrawPoint(x0+a,y0+b); //6
LCD_DrawPoint(x0-b,y0+a);
a++;
//使用Bresenham算法画圆
if(di<0)di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
LCD_DrawPoint(x0+a,y0+b);
}
} |