
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
fillpoly() function in C
Concept
Now the header file graphics.h contains fillpoly() function which is implemented to draw and fill a polygon such as triangle, rectangle, pentagon, hexagon etc. So this function require same arguments as drawpoly().
Syntax
void fillpoly( int number, int *polypoints );
In this case,number indicates (n + 1) number of points where, n is the number of vertices in a polygon and polypoints points to a sequence of (n*2) integers.
Input
arr[] = {320, 150, 400, 250, 250, 350, 320, 150};
Output
Explanation
So the declaration of fillpoly() contains two arguments: number specifies (n + 1) number of points where n is indicated as the number of vertices in a polygon.The second argument, such as, polypoints points to a sequence of (n * 2) integers. As a result of this,each pair of integers provides x and y coordinates of a point on the polygon. So we indicate (n + 1) points because first point coordinates should be equal to (n + 1)th for drawing a complete figure.
Example
// 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; }
Output
- Related Articles
- Draw a filled polygon using the OpenCV function fillPoly()
- iswblank() function in C/C++
- iswpunct() function in C/C++
- strchr() function in C/C++
- strtod() function in C/C++
- memmove() function in C/C++
- memcpy() function in C/C++
- atexit() function in C/C++
- raise() function in C/C++
- mbrlen() function in C/C++
- strftime() function in C/C++
- iswlower() function in C/C++
- towupper() function in C/C++
- iswdigit() function in C/C++
- ldexp() function in C/C++
