Draw a Hexagon in Computer Graphics
Here, you will learn as easy way to draw a hexagon in computer graphics on the screen using line(), moveto(), and lineto() functions.
To draw a hexagon in computer graphics, define six vertices and connect them sequentially to form six sides. Use lines or vectors, specifying their coordinates for rendering.
Program code to Draw a Hexagon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //How to draw Hexagon in Computer Graphics #include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); setcolor(RED); moveto(100,100); lineto(75,120); lineto(100,140); lineto(140,140); lineto(165,120); lineto(140,100); lineto(100,100); setfillstyle(SOLID_FILL,BLUE); floodfill(150,120,RED); getch(); } |
Output