#define PutPixel putpixel
/* 八分法 */
void CirclePoints(int x, int y, int t, int s, color mycolor)
{
PutPixel(t+x, s+y, mycolor);
PutPixel(t-x, s+y, mycolor);
PutPixel(t+x, s-y, mycolor);
PutPixel(t-x, s-y, mycolor);
}
/* 画圆 */
void DrawCircle(int centreX, int centreY, int R, color mycolor)
{
int x, y, delt, dHD, deltV, next;
x = 0;
y = R;
delt = 2 * (1-R);
while(y >= 0)
{
CirclePoints(x, y, centreX, centreY, mycolor);
if(delt < 0)
{
dHD = 2 * (delt + y) - 1;
if(dHD <= 0)
{
next = 0;
}
else
{
next = 1;
}
}
else if(delt > 0)
{
deltV = 2 * (delt - x) - 1;
if(deltV <= 0)
{
next = 1;
}
else
{
next = 2;
}
}
else
{
next = 1;
}
switch(next)
{
case 0: x++;
delt += 2 * x + 1;
break;
case 1: x++;
y--;
delt += 2 * (x - y + 1);
break;
case 2:y--;
delt += -2 * y + 1;
break;
}
}
}
/* 八分法 */
void CirclePoints(int x, int y, int t, int s, color mycolor)
{
PutPixel(t+x, s+y, mycolor);
PutPixel(t-x, s+y, mycolor);
PutPixel(t+x, s-y, mycolor);
PutPixel(t-x, s-y, mycolor);
}
/* 画圆 */
void DrawCircle(int centreX, int centreY, int R, color mycolor)
{
int x, y, delt, dHD, deltV, next;
x = 0;
y = R;
delt = 2 * (1-R);
while(y >= 0)
{
CirclePoints(x, y, centreX, centreY, mycolor);
if(delt < 0)
{
dHD = 2 * (delt + y) - 1;
if(dHD <= 0)
{
next = 0;
}
else
{
next = 1;
}
}
else if(delt > 0)
{
deltV = 2 * (delt - x) - 1;
if(deltV <= 0)
{
next = 1;
}
else
{
next = 2;
}
}
else
{
next = 1;
}
switch(next)
{
case 0: x++;
delt += 2 * x + 1;
break;
case 1: x++;
y--;
delt += 2 * (x - y + 1);
break;
case 2:y--;
delt += -2 * y + 1;
break;
}
}
}