程序:罗健军
程序中var32表示有符号32位数,var16表示有符号16位数。x0,y0为圆心坐标,r为半径。PutPixel为画点函数。
曾经长年的使用这段程序,而未向罗健军大师表示感谢,真是感到惭愧!在这里,请各位代表我向他表示感谢。
double SIN45=0.707106781186548;
void Circle(var16 x0,var16 y0,uvar16 r)
{
var32 tn;
var16 x,y;
var16 xmax;
y=r;x=0; xmax=var16(r*SIN45); tn=(1-r*2);
while(x<=xmax)
{
if(tn>=0)
{
tn+=(6+((x-y)<<2));
y--;
}
else
tn+=((x<<2)+2);
PutPixel(x0+y,y0+x); PutPixel(x0+x,y0+y); PutPixel(x0-x,y0+y); PutPixel(x0-y,y0+x); PutPixel(x0-y,y0-x); PutPixel(x0-x,y0-y); PutPixel(x0+x,y0-y); PutPixel(x0+y,y0-x); x++; }
PutPixel(x0+y,y0+x); PutPixel(x0+x,y0+y); PutPixel(x0-x,y0+y); PutPixel(x0-y,y0+x); PutPixel(x0-y,y0-x); PutPixel(x0-x,y0-y); PutPixel(x0+x,y0-y); PutPixel(x0+y,y0-x); }
1698

被折叠的 条评论
为什么被折叠?



