To apply scaling on a rectangle

//To apply scaling on a rectangle

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int x1,y1,x2,y2,s,g;float sx,sy;
cout<<“\n\t\t\t\*Scaling a rectangle*\n”;
cout<<“\nenter the x1 and x2 coordinates:-\n”;
cin>>x1>>x2;
cout<<“\nenter the y1 and y2 coordinates:-\n”;
cin>>y1>>y2;
cout<<“\nenter the scaling factor to the x-axis:-“;
cin>>sx;
cout<<“\nenter trhe scaling factor to the y-axis:-“;
cin>>sy;
int gd=DETECT,gm;
initgraph(&gd,&gm,””);
setbkcolor(WHITE);
setcolor(8);
line(x1,y1,x2,y1);
line(x2,y2,x1,y2);
line(x2,y1,x2,y2);
line(x1,y2,x1,y1);
s=x2-x1;
g=y2-y1;
x2=x2-int((sx*s)+0.5);
y2=y2-int((sy*g)+0.5);
setcolor(8);
line(x1,y1,x2,y1);
line(x2,y2,x1,y2) ;
line(x2,y1,x2,y2);
line(x1,y2,x1,y1);
setcolor(8);
outtextxy(100,60,”Scaling effect on rectangle”);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *