Hello friends in this tutorial we are going to learn about How to fill colour in shapes using graphics C language.
The Colour Table in Graphics C.
Colour | Int Value |
---|---|
Black | 0 |
Blue | 1 |
Green | 2 |
Cyan | 3 |
Red | 4 |
Magenta | 5 |
Brown | 6 |
Light Gray | 7 |
Dark Gray | 8 |
Light Blue | 9 |
Light Green | 10 |
Light Cyan | 11 |
Light Red | 12 |
Light Magenta | 13 |
Yellow | 14 |
White | 15 |
The Pattern Table in Graphics C.
Pattern | Int Value |
---|---|
EMPTY_FILL | 0 |
SOLID_FILL | 1 |
LINE_FILL | 2 |
LTSLASH_FILL | 3 |
SLASH_FILL | 4 |
BKSLASH_FILL | 5 |
LTBKSLASH_FILL | 6 |
HATCH_FILL | 7 |
XHATCH_FILL | 8 |
INTERLEAVE_FILL | 9 |
WIDE_DOT_FILL | 10 |
CLOSE_DOT_FILL | 11 |
USER_FILL | 12 |
In Graphics C setfillstyle() & floodfill() function used to fills colour in shapes.
Syntax of setfillstyle() & floodfill().
setfillstyle(pattern name/value,color name /value);
floodfill(int x, int y, border_color);
Program :
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
{
int gd=DETECT, gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
setfillstyle(SOLID_FILL, RED); //setfillstyle(1,4);
circle(320,240,50);
floodfill(320,240,WHITE); //floodfill(320,240,15);
getch();
}
So, in this tutorial we learnt about how to fills colour in shapes using graphics C. I hope it was useful for you .
Share with your friends 💌
Thankyou So much !!
0 Comments