drawpoly
程序函数
函数drawpoly用当前绘图色、线型及线宽,画一个给定若干点所定义的多边形。
简介
函数名: drawpoly
第一个参数,是多边形的顶点数
第二个参数,该数组存放着多边形所有顶点(x,y)坐标值,即一系列整数对
用 法: void far drawpoly(int numpoints, int far *polypoints);
程序例
#include <graphics.h>
#include
#include
#include
int main(void)
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy;
/* our polygon array */
int poly[10];
/* initialize graphics and local
variables */
initgraph(&gdriver, &gmode, );
/* read result of initialization */
errorcode = graphresult;
if (errorcode != grOk)
/* an error occurred */
getch;
/* terminate with an error code */
exit(1);
maxx = getmaxx;
maxy = getmaxy;
poly[0] = 20; /* 1st vertext */
poly[1] = maxy / 2;
poly[2] = maxx - 20; /* 2nd */
poly[3] = 20;
poly[4] = maxx - 50; /* 3rd */
poly[5] = maxy - 20;
poly[6] = maxx / 2; /* 4th */
poly[7] = maxy / 2;
/*
drawpoly doesn't automatically close
the polygon, so we close it.
*/
poly[8] = poly[0];
poly[9] = poly[1];
/* draw the polygon */
drawpoly(5, poly);
/* clean up */
getch;
closegraph;
return 0;
参考资料
最新修订时间:2024-02-20 21:24
目录
概述
简介
程序例
参考资料