Anda di halaman 1dari 4

//Program to draw circle

#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");
circle(200,250,150);
getch();
closegraph();
}

//Color demo
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm,maxx,maxy,x=40,y=40,fst;
char str[40];
char
*pattern[]={ "EMPTY_FILL","SOLID_FILL","LINE_FILL"};
initgraph(&gd,&gm,"c:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
rectangle(0,10,maxx,maxy);
setcolor(WHITE);
outtextxy(175,0,"Pre-defined Fill Style");

/*display different predefined fill s tyles*/


for(fst=0;fst<3;fst++)
{
setfillstyle(fst,MAGENTA);
bar(x,y,x+80,y+80);
rectangle(x,y,x+80,y+80);
itoa(fst,str,10);
outtextxy(x,y+100,str);
outtextxy(x,y+110,pattern[fst]);
x=x+150;
if(x>490)
{
y=y+150;
x=40;
}
}
getch();
closegraph();
restorecrtmode();
}
//Draw Ellipse
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm,x,y;
x=getmaxx();
y=getmaxy();
initgraph(&gd,&gm,"c:\\tc\\bgi");
ellipse(x,y,100,360,100,50);
getch();

closegraph();
}
//Draw line
#include<stdio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
line(100,50,100,350);
getch();
closegraph();
}

//draw shapes
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gm,gd=DETECT,x,y;
initgraph(&gd,&gm,"c:\\tc\\bgi");
x=getmaxx();
y=getmaxy();
line(5,5,50,10);
rectangle(20,40,56,86);
circle(200,200,150);
ellipse(200,200,50,70,0,0);
getch();
closegraph();

Anda mungkin juga menyukai