New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



2d geometry using Turbo C Graphics


Posted Date:     Total Responses: 0    Posted By: Vikram Narayan C   Member Level: Silver   Points/Cash: 3   


#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;
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: To search a file n update the item using c++
Previous Project: Calculator Program in C using Graphics

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.