C语言fillpoly函数详解
C语言中,fillpoly函数的功能是画一个多边形,今天我们就来学习学习。
C语言fillpoly函数:填充一个多边形
函数名:fillpoly
功 能:画并填充一个多边形
头文件:#include<graphics.h>
原 型:fillpoly(intnumpoints,intfar*polypoints);
参数说明:numpoints为多边形的边数;far*polypoints为存储各顶点坐标的数组,每两个一组表示一个顶点的X和Y坐标。
实例代码:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
intmain(void)
{
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
inti,maxx,maxy;
/*ourpolygonarray*/
intpoly[8];
/*initializegraphics,localvariables*/
initgraph(&gdriver,&gmode,"");
/*readresultofinitialization*/
errorcode=graphresult();
if(errorcode!=grOk)
/*anerroroccurred*/
{
printf("Graphicserror:%s\n",grapherrormsg(errorcode));
printf("Pressanykeytohalt:");
getch();
exit(1);
/*terminatewithanerrorcode*/
}
maxx=getmaxx();
maxy=getmaxy();
poly[0]=20;/*1stvertext*/
poly[1]=maxy/2;
poly[2]=maxx-20;/*2nd*/
poly[3]=20;
poly[4]=maxx-50;/*3rd*/
poly[5]=maxy-20;
/*
4thvertex.fillpolyautomatically
closesthepolygon.
*/
poly[6]=maxx/2;
poly[7]=maxy/2;
/*loopthroughthefillpatterns*/
for(i=EMPTY_FILL;i<USER_FILL;i++)
{
/*setfillpattern*/
setfillstyle(i,getmaxcolor());
/*drawafilledpolygon*/
fillpoly(4,poly);
getch();
}
/*cleanup*/
closegraph();
return0;
}
注:fillpoly函数是TC编译环境下的函数,VC中无法使用。
以上就是关于fillpoly函数填充多边形功能的实现代码,希望对大家的学习有所帮助。
热门推荐
10 叔叔生日祝福语简短励志
11 诗词文案祝福语简短精辟
12 新年祝福语和语句简短
13 航空公司祝福语简短
14 天气转凉祝福语简短
15 新春进门祝福语大全简短
16 提早庆祝生日祝福语简短
17 求简短的职场祝福语
18 婆婆生日祝福语简短的