How To Draw Indian Flag In C++ (Computer Graphics)
PROJECT BY (SIMPLIFY LEARN PROGRAMMING)
ON
INDIAN FLAG
Source Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd,gm;
int r,i,a,b,x,y;
float PI=3.14;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TC\\BGI");
settextstyle(7,HORIZ_DIR,1);
outtextxy(300,150,"HAPPY INDEPENDENCE DAY");
outtextxy(400,200,"VANDE MATARAM");
// DRAW THE RODE RECTANGLE AND COLOR IT
setcolor(LIGHTGRAY);
rectangle(90,100,100,400);
setfillstyle(SOLID_FILL,LIGHTGRAY);
floodfill(91,101,LIGHTGRAY);
// DRAW THE FIRST STAIR AND COLOR IT
setfillstyle(SOLID_FILL,LIGHTGRAY);
line(40,400,150,400);
line(150,400,150,420);
line(150,420,40,420);
line(40,420,40,400);
floodfill(41,401,LIGHTGRAY);
// DRAW THE SECOND STAIR AND COLOR IT
setfillstyle(SOLID_FILL,LIGHTGRAY);
line(20,420,170,420);
line(20,440,170,440);
line(20,420,20,440);
line(170,420,170,440);
floodfill(21,421,LIGHTGRAY);
// DRAW THE TOP RECTANGLE AND COLOR IT
setcolor(LIGHTRED);
rectangle(100,100,250,125);
setfillstyle(SOLID_FILL,LIGHTRED);
floodfill(101,101,LIGHTRED);
// DRAW THE MIDDLE RECTANGLE AND COLOR IT
setcolor(WHITE);
rectangle(100,125,250,150);
setfillstyle(SOLID_FILL,WHITE);
floodfill(101,126,WHITE);
// DRAW THE BOTTOM RECTANGLE AND COLOR IT
setcolor(GREEN);
rectangle(100,150,250,175);
setfillstyle(SOLID_FILL,GREEN);
floodfill(101,151,GREEN);
// DRAW THE CIRCLE
a=175; //CENTER
b=137; //CENTER
r=12; //RADIUS
setcolor(BLUE);
circle(a,b,r);
// SPOKES
for(i=0;i<=360;i=i+15)
{
x=r*cos(i*PI/180);
y=r*sin(i*PI/180);
line(a,b,a+x,b-y);
}
getch();
closegraph();
}
Output:
Comments
Post a Comment