 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how to display Polygon in different colors and styles. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app Techimage that is available on Google Play. You can connect with me by following these details which are available in front of you. Now coming on to the topic. For demonstration, I have included two header files, Graphics.h and Cognor.h. Inside main function, three variables are declared GD, GM and I. GD stands for graphics driver which is initialized with detect. It will automatically detect the graphics drivers. Then GM is for graphics mode and I is for loop counter. Then an integer array points is declared which is having different coordinates of polygon. So here five pairs are available. This is first pair, then second pair, then this is third pair, then fourth pair and this is fifth pair. So total five points will be plotted on X and Y axis. You can see first and last points are same. So on console, four points will be displayed because two points are same. So four lines will be drawn. They will join four different points. So to draw polygon, this array will be used before that init graph function is called which is having three arguments GD, GM and a path. GD is for graphics driver, GM is for graphics mode and this path is for graphics library which is C, TC and BGI. After initializing graph, first I am demonstrating you how you can display polygons with different colors. So I am implementing a for loop starting from 0 to 15. Inside this for loop, I am calling a function setColor and I am passing I inside it. This loop will repeat 16 times. So each time setColor function will be receiving different numerical values and it will apply different color. Then drawPoly function. Inside drawPoly function, I am passing two arguments, number of points and then points array. Points array is containing all the coordinates of points. Then I am calling getCH function and I am closing for loop. After for loop, I have implemented or you can say call closeGraph function and then return0 statement is available. This loop will repeat and color will be changed and different colors polygon will be drawn on console. If I want to change the color of polygon, then I have to press enter key because I have implemented getCH function. So this execution will be manual. If I want to convert it into automated process, then I have to use delay function. So first I am executing it manually. Then I will convert into automatic process. Before that, I also want to show the colors which are available so that you can understand that we can use numerical values for colors. You can see color constants are available here and these numerical values are written in front of these colors. So I have used numerical values instead of their names. Now I am executing this code. Now I am pressing enter key. As I press enter key, color of polygon is changing. You can see it. You will be feeling this when you will be implementing this code at your own because right now you can't see that I am pressing any key. So if you will be implementing this code, you have to press enter key if you want to change the color of polygon. Now I am replacing getCH function with delay and I am passing a time in milliseconds. This time I don't have to press any key. It will change the color of polygon automatically. This also you can feel while you will be implementing this. So right now colors of polygon are changing automatically. So if you want to change the colors manually, then you have to use getCH. If you want that this task will be done automatically, then you can use delay. Now till now this polygon was empty. Now I will be filling this with the help of set fill style. Now we have to check all the fill styles which are predefined in graphics. So this is the list of fill styles which are predefined. You can use any particular fill style from this list. I will be using bk slash underscore fill style and for colors I will be using I. So this single fill style will be applied on each polygon with different colors. I is for color and this bk slash underscore fill is the particular style and this draw poly function will be converted into fill poly. So I am executing this code. You will see a single fill style will be applied on poly one in different colors and this will be changing automatically because I am using delay function. You can see different colors are applied on single fill style. Fill style is not changing. Only colors are changing and this is doing automatically. Now if you want to apply different different fill styles with different colors, so you can remove this bk slash underscore fill and you can apply only I. These fill styles are defined using enum. So in enum each fill style is having a numerical values starting from zero. So that's why I'm using I now I will be executing this code again and you can see different different fill styles in different colors will be applied on this polygon now. You can see it different styles with different colors and these are changing automatically because I have used delay function. So friends I have demonstrated two functions. First one was to draw poly and second one is fill poly draw poly draws empty polygons on console, whereas fill poly draws filled polygons on console with the help of set fill style and you can display different different polygons in different colors automatically or manually automatically with the help of delay and manually with the help of get ch function. I hope you have understood all the demonstration which I have demonstrated in this video. If you want to watch more programming related videos, you can subscribe my YouTube channel. Keep connected with me. Thank you for watching this video.