#include
#include
#include
void main()
{
int gm,gd=DETECT;
int ch,draw,paint,text;//choices
int x1,y1,x2,y2,r,sa,ea,xr,yr,poly[10],v,i,midx,midy,res[10],year[10];
char str[10];
initgraph(&gd,&gm,"c:\\tc\\bgi");
while(1)
{
x: cleardevice();
printf("\nGraphics Editor");
printf("\n1.DRAW\n2.TEXT\n3.PAINT\n4.EXIT\nEnter choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
while(1)
{
cleardevice();
printf("\nDrawing Different Polygons");
printf("\n1.Pixel\n2.Line\n3.Circle\n4.Ellipse\n5.Polygon");
printf("\n6.Line Styles\n7.Bar Graphs\n8.Pai Charts\n9.Histogram\n0.Main Menu\nEnter Choice: ");
scanf("%d",&draw);
switch(draw)
{
case 1://pixel
printf("\nenter x1,y1: ");
scanf("%d%d",&x1,&y1);
putpixel(x1,y1,15);
getch();
break;
case 2://line
printf("\nenter (x1,y1) and (x2,y2): ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
line(x1,y1,x2,y2);
getch();
break;
case 3://circle
// setaspectratio(10000,8000);
printf("\nEnter (x1,y1) and Radius: ");
scanf("%d%d%d",&x1,&y1,&r);
circle(x1,y1,r);
getch();
break;
case 4:
printf("\nEnter (x1,y1),SA,EA,XR,YR:");
scanf("%d%d%d%d%d%d",&x1,&y1,&sa,&ea,&xr,&yr);
putpixel(x1,y1,15);
ellipse(x1,y1,sa,ea,xr,yr);
getch();
break;
case 5: //poly
printf("\nHow many vertices: ");
scanf("%d",&v);
printf("Enter vertices (x,y): ");
for(i=0;i scanf("%d",&poly[i]);
poly[i]=poly[0];
poly[i+1]=poly[1];
drawpoly(v+1,poly);
getch();
setfillstyle(1,GREEN);
floodfill(poly[0]+60,poly[1]+10,15);
// fillpoly(v+1,poly);
getch();
break;
case 6:
printf("\nenter (x1,y1) and (x2,y2): ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
for (i=0; i<=4; i++)
{
setlinestyle(i, 1, 1);
line(x1, y1,x2,y2);
getch();
cleardevice();
}
break;
case 7:
midx=getmaxx()/2;
midy=getmaxy()/2;
line(150,midx,500,midy); //hor
line(200,10,200,midy+50); //ver
//bar
x1=250;
printf("\nEnter Year and Result for 4 years: ");
for(i=0;i<4;i++)//accept year and result
{
printf("Year: ");
scanf("%d",&year[i]);
printf("Result: ");
scanf("%d",&res[i]);
itoa(res[i],str,10);
outtextxy(170,(midy-res[i]),str);
settextstyle(0,1,1);
outtextxy(150,midy-50,"RESULT");
settextstyle(0,0,1);
line(195,midy-res[i],205,midy-res[i]);
setfillstyle(1,i+1);
bar(x1,midy-res[i],x1+50,midy);
itoa(year[i],str,10);
outtextxy(x1,midy+10,str);
outtextxy(300,midy+20,"ACADEMIC YEAR");
x1=x1+70;
}
getch();
break;
case 8: //pai chart
printf("\nEnter (x1,y1),SA,EA,Radius: ");
scanf("%d%d%d%d%d",&x1,&y1,&sa,&ea,&r);
setfillstyle(1,x2);
pieslice(x1,y1,sa,ea,r);
getch();
break;
case 0:goto x;
}//end switch
}//end while
case 2: //TEXT
while(1)
{
printf("\n1.Input Text\n2.color\n3.color pallete\n4.text style\n5.justification\n0.Main menu\nChoice: ");
scanf("%d",&text);
switch(text)
{
case 1:
printf("\nEnter text: ");
flushall();
gets(str);
break;
case 2:
for(i=0;i<15;i++)
{
setcolor(i);
outtextxy(200,100,str);
getch();
}
break;
case 3:
setcolor(RED);
outtextxy(200,100,str);
setcolor(BLUE);
outtextxy(200,150,str);
setcolor(RED);
outtextxy(200,200,str);
setcolor(RED);
outtextxy(200,220,"PALETTE EFFECT");
getch();
setpalette(RED,YELLOW);
getch();
break;
case 4:
settextstyle(0,0,1);
outtextxy(200,200,str);
getch();
settextstyle(0,1,1);
outtextxy(200,200,str);
getch();
settextstyle(1,0,1);
outtextxy(200,200,str);
getch();
case 5://justification
outtextxy(200,200,str);
getch();
settextjustify(2,0);
outtextxy(200,200,str);
getch();
break;
case 0:
goto x;
}
}
case 3://PAINT
circle(200,200,100);
getch();
floodfill(200,200,2);
getch();
break;
case 4:exit(0);
}
} //while
}
#include
#include
void main()
{
int gm,gd=DETECT;
int ch,draw,paint,text;//choices
int x1,y1,x2,y2,r,sa,ea,xr,yr,poly[10],v,i,midx,midy,res[10],year[10];
char str[10];
initgraph(&gd,&gm,"c:\\tc\\bgi");
while(1)
{
x: cleardevice();
printf("\nGraphics Editor");
printf("\n1.DRAW\n2.TEXT\n3.PAINT\n4.EXIT\nEnter choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
while(1)
{
cleardevice();
printf("\nDrawing Different Polygons");
printf("\n1.Pixel\n2.Line\n3.Circle\n4.Ellipse\n5.Polygon");
printf("\n6.Line Styles\n7.Bar Graphs\n8.Pai Charts\n9.Histogram\n0.Main Menu\nEnter Choice: ");
scanf("%d",&draw);
switch(draw)
{
case 1://pixel
printf("\nenter x1,y1: ");
scanf("%d%d",&x1,&y1);
putpixel(x1,y1,15);
getch();
break;
case 2://line
printf("\nenter (x1,y1) and (x2,y2): ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
line(x1,y1,x2,y2);
getch();
break;
case 3://circle
// setaspectratio(10000,8000);
printf("\nEnter (x1,y1) and Radius: ");
scanf("%d%d%d",&x1,&y1,&r);
circle(x1,y1,r);
getch();
break;
case 4:
printf("\nEnter (x1,y1),SA,EA,XR,YR:");
scanf("%d%d%d%d%d%d",&x1,&y1,&sa,&ea,&xr,&yr);
putpixel(x1,y1,15);
ellipse(x1,y1,sa,ea,xr,yr);
getch();
break;
case 5: //poly
printf("\nHow many vertices: ");
scanf("%d",&v);
printf("Enter vertices (x,y): ");
for(i=0;i
poly[i]=poly[0];
poly[i+1]=poly[1];
drawpoly(v+1,poly);
getch();
setfillstyle(1,GREEN);
floodfill(poly[0]+60,poly[1]+10,15);
// fillpoly(v+1,poly);
getch();
break;
case 6:
printf("\nenter (x1,y1) and (x2,y2): ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
for (i=0; i<=4; i++)
{
setlinestyle(i, 1, 1);
line(x1, y1,x2,y2);
getch();
cleardevice();
}
break;
case 7:
midx=getmaxx()/2;
midy=getmaxy()/2;
line(150,midx,500,midy); //hor
line(200,10,200,midy+50); //ver
//bar
x1=250;
printf("\nEnter Year and Result for 4 years: ");
for(i=0;i<4;i++)//accept year and result
{
printf("Year: ");
scanf("%d",&year[i]);
printf("Result: ");
scanf("%d",&res[i]);
itoa(res[i],str,10);
outtextxy(170,(midy-res[i]),str);
settextstyle(0,1,1);
outtextxy(150,midy-50,"RESULT");
settextstyle(0,0,1);
line(195,midy-res[i],205,midy-res[i]);
setfillstyle(1,i+1);
bar(x1,midy-res[i],x1+50,midy);
itoa(year[i],str,10);
outtextxy(x1,midy+10,str);
outtextxy(300,midy+20,"ACADEMIC YEAR");
x1=x1+70;
}
getch();
break;
case 8: //pai chart
printf("\nEnter (x1,y1),SA,EA,Radius: ");
scanf("%d%d%d%d%d",&x1,&y1,&sa,&ea,&r);
setfillstyle(1,x2);
pieslice(x1,y1,sa,ea,r);
getch();
break;
case 0:goto x;
}//end switch
}//end while
case 2: //TEXT
while(1)
{
printf("\n1.Input Text\n2.color\n3.color pallete\n4.text style\n5.justification\n0.Main menu\nChoice: ");
scanf("%d",&text);
switch(text)
{
case 1:
printf("\nEnter text: ");
flushall();
gets(str);
break;
case 2:
for(i=0;i<15;i++)
{
setcolor(i);
outtextxy(200,100,str);
getch();
}
break;
case 3:
setcolor(RED);
outtextxy(200,100,str);
setcolor(BLUE);
outtextxy(200,150,str);
setcolor(RED);
outtextxy(200,200,str);
setcolor(RED);
outtextxy(200,220,"PALETTE EFFECT");
getch();
setpalette(RED,YELLOW);
getch();
break;
case 4:
settextstyle(0,0,1);
outtextxy(200,200,str);
getch();
settextstyle(0,1,1);
outtextxy(200,200,str);
getch();
settextstyle(1,0,1);
outtextxy(200,200,str);
getch();
case 5://justification
outtextxy(200,200,str);
getch();
settextjustify(2,0);
outtextxy(200,200,str);
getch();
break;
case 0:
goto x;
}
}
case 3://PAINT
circle(200,200,100);
getch();
floodfill(200,200,2);
getch();
break;
case 4:exit(0);
}
} //while
}
Comments
Post a Comment