C语言编程 “画圆” 源程序
initgraph(&driver,&mode,&uot;&uot;);
setcolor(15);
line(66,66,88,88);
lineto(100,100);
linerel(36,64);
getch();
restorecrtmode();
}
------------------------------------------------------------------------------------------------------------------------------------------
-
#include <math.h>
#include <graphics.h> /*预定义库函数*/
void circlePoint(int x,int y) /*八分法画圆程序*/
{
circle(320 x*20,240 y*20,3);
circle(320 y*20,240 x*20,3);
circle(320-y*20,240 x*20,3);
circle(320-x*20,240 y*20,3);
circle(320-x*20,240 y*20,3);
circle(320-x*20,240-y*20,3);
circle(320-y*20,240-x*20,3);
circle(320 y*20,240-x*20,3);
circle(320 x*20,240-y*20,3);
}
void MidBresenhamcircle(int r) /* 中点Bresenham算法画圆的程序 */
{
int x,y,d;
x=0;y=r;d=1-r; /* 计算初始值 */
while(x<y)
{ circlePoint(x,y); /* 绘制点(x,y)及其在八分圆中的另外7个对称点 */