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函数填充多边形功能的实现代码,希望对大家的学习有所帮助。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下