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