多边形颜色渐变填充C语言,画并填充一个多边形
发布日期:2021-06-24 13:39:27 浏览次数:2 分类:技术文章

本文共 1045 字,大约阅读时间需要 3 分钟。

[c]代码库#include

#include

#include

#include

int main ( void )

{

/* request auto detection */

int gdriver = DETECT, gmode, errorcode;

int i, maxx, maxy;

/* our polygon array */

int poly[8];

/* initialize graphics, local variables */

initgraph ( &gdriver, &gmode, "" );

/* read result of initialization */

errorcode = graphresult();

if ( errorcode != grOk )

/* an error occurred */

{

printf ( "Graphics error: %s\n",

grapherrormsg ( errorcode ) );

printf ( "Press any key to halt:" );

getch();

exit ( 1 );

/* terminate with an error code */

}

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;

/*

4th vertex. fillpoly automatically

closes the polygon.

*/

poly[6] = maxx / 2;

poly[7] = maxy / 2;

/* loop through the fill patterns */

for ( i=EMPTY_FILL; i

{

/* set fill pattern */

setfillstyle ( i, getmaxcolor() );

/* draw a filled polygon */

fillpoly ( 4, poly );

getch();

}

/* clean up */

closegraph();

return 0;

}

694748ed64b9390909c0d88230893790.png

转载地址:https://blog.csdn.net/weixin_33218985/article/details/117191989 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:如何Python语言格式化c盘,怎么Black自由格式化Python?
下一篇:c 程序语言设计游戏,程序设计c语言设计游戏 程序设计.doc

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月28日 07时56分44秒