#include //conio.h #include //stdio.h #include graphics.h void main() { int gd=DETECT,gm,x,y,i; char ch; float r; int x1[5],x2[5]; initgraph(&gd,&gm,"e:\\tcpp\\bgi\\"); cleardevice(); x=getmaxx(); y=getmaxy(); window(0,0,getmaxx(),getmaxy()); setcolor(2); setbkcolor(9); back: gotoxy(20,10); outtextxy(x/3,y/4,"2D GEOMETRY"); setcolor(1); outtextxy(x/4,y/3,"1.Point..."); outtextxy(x/4,y/3+15,"2.Line..."); outtextxy(x/4,y/3+30,"3.Circle..."); outtextxy(x/4,y/3+45,"4.Triangle..."); outtextxy(x/4,y/3+60,"5.Rectangle..."); outtextxy(x/4,y/3+90,"6.Exit..."); setcolor(3); outtextxy(x/4-30,y/3+105,"Enter your Choice..."); ch=getche(); cleardevice(); setcolor(15); line(x/2,0,x/2,y); line(0,y/2,x,y/2); outtextxy(x/2-10,y/2+10,"O"); outtextxy(x-10,y/2+10,"X"); outtextxy(x/2+10,10,"Y"); switch(ch) { case '1': printf("\nEnter the point:"); scanf("%d %d",&x1[0],&x2[0]); setcolor(15); setfillstyle(1,2); circle(x/2+x1[0]*20,y/2-x2[0]*20,2); floodfill(x/2+x1[0]*20,y/2-x2[0]*20,WHITE); break; case '2': printf("\nEnter the two points:"); for(i=0;i<2;i++) { scanf("%d %d",&x1[i],&x2[i]); setcolor(15); setfillstyle(1,2); circle(x/2+x1[i]*20,y/2-x2[i]*20,2); floodfill(x/2+x1[i]*20,y/2-x2[i]*20,WHITE); } line(x/2+x1[0]*20,y/2-x2[0]*20,x/2+x1[1]*20,y/2-x2[1]*20); break; case '3': printf("\nEnter the centre:"); scanf("%d %d",&x1[0],&x2[0]); circle(x/2+x1[0]*20,y/2-x2[0]*20,2); printf("Enter the radius"); scanf("%f",&r); setcolor(15); circle(x/2+20*x1[0],y/2-20*x2[0],20*r); break; case '4': printf("\nEnter the three points:"); for(i=0;i<3;i++) { scanf("%d %d",&x1[i],&x2[i]); circle(x/2+x1[i]*20,y/2-x2[i]*20,1); floodfill(x/2+x1[i]*20,y/2-x2[i]*20,WHITE); } line(x/2+x1[0]*20,y/2-x2[0]*20,x/2+x1[1]*20,y/2-x2[1]*20); line(x/2+x1[1]*20,y/2-x2[1]*20,x/2+x1[2]*20,y/2-x2[2]*20); line(x/2+x1[2]*20,y/2-x2[2]*20,x/2+x1[0]*20,y/2-x2[0]*20); break; case '5': printf("\nEnter the two diagonal points:"); for(i=0;i<2;i++) { scanf("%d %d",&x1[i],&x2[i]); circle(x/2+x1[i]*20,y/2-x2[i]*20,1); floodfill(x/2+x1[i]*20,y/2-x2[i]*20,WHITE); } rectangle(x/2+x1[0]*20,y/2-x2[0]*20,x/2+x1[1]*20,y/2-x2[1]*20); break;
} getch(); cleardevice(); if(ch!='6') goto back; }
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|