C语言生成Bezier曲线程序

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include
void bezier_3(int color, double p[4][2])
{
double t,t1,t2,xt,yt;
int rate=200,x,y;
setcolor(color);
moveto(p[0][0],p[0][1]);
for (t=0;t<=1;t+=1.0/rate)
{
yt=1-t;
t1=yt*yt;
t2=3*yt*t;
xt=p[0][0]*t1*yt+p[1][0]*t2*yt+p[2][0]*t2*t+p[3][0]*t*t*t;
yt=p[0][1]*yt*t1+p[1][1]*t2*yt+p[2][1]*t2*t+p[3][1]*t*t*t;
x=(int)(xt);
y=(int)(yt);
lineto(x,y);
}
}
void main()
{
static double p[4][2]={50,400,140,20,400,40,635,420};
const NO=3; /*特征顶点数*/
int i;
int driver=DETECT,mode;
initgraph(&driver,&mode,"C://tools/tc2.0");
cleardevice();
setcolor(BLUE);
moveto(p[0][0],p[0][1]);
for (i=1;ilineto(p[i][0],p[i][1]);
bezier_3(LIGHTRED,p);
getch(); /*按ESC键退出*/
closegraph();
}

相关文档
最新文档