Translation A Rectangle In 2-D

09:21 0 Comments A+ a-

PROGRAM:




#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
void main()
{
clrscr();
int gd=DETECT,gm,x1,x2,x3,x4,y1,y2,y3,y4,tx,ty;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cout<<"Enter x1 & y1: ";
cin>>x1>>y1;
cout<<"Enter x2 & y2: ";
cin>>x2>>y2;
rectangle(x1,y1,x2,y2);
cout<<"Enter the translation in x and y diraction: ";
cin>>tx>>ty;
x3=x1+tx;
y3=y1+ty;
x4=x2+tx;
y4=y2+ty;
delay(100);
rectangle(x3,y3,x4,y4);
//closegraph();
getch();
}