C 语言中的 fillpoly() 函数
概念
现在,头文件 graphics.h 包含 fillpoly() 函数,它用于绘制并填充多边形,如三角形、矩形、五边形、六边形等。因此,该函数需要与 drawpoly() 相同的参数。
语法
void fillpoly( int number, int *polypoints );
在这种情况下,number 表示 (n + 1) 个点,其中 n 是多边形中顶点的数量,polypoints 指向 (n*2) 个整数序列。
输入
arr[] = {320, 150, 400, 250, 250, 350, 320, 150};输出

说明
因此,fillpoly() 的声明包含两个参数:number 指定 (n + 1) 个点,其中 n 表示多边形中顶点的数量。第二个参数,例如 polypoints,指向 (n * 2) 个整数的序列。因此,每对整数提供多边形上一个点的 x 和 y 坐标。我们表示 (n + 1) 个点,因为第一个点坐标应等于 (n + 1) 个点以绘制完整图形。
范例
// C Implementation for fillpoly()
#include <graphics.h>
// driver code
intmain(){
// Here gm1 is Graphics mode which is a computer display mode that
// produces image using pixels. DETECT is a macro defined in
// "graphics.h" header file
intgd1 = DETECT, gm1;
// Different coordinates for polygon
intarr1[] = {320, 150, 400, 250, 250, 350, 320, 150};
// Here initgraph initializes the
// graphics system by loading a
// graphics driver from disk
initgraph(&gd1, &gm1, "");
// fillpoly function
fillpoly(4, arr1);
getch();
// Here closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();
return0;
}输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP