Friday 27 September 2013

2D Transformation - Scaling | Computer Graphics Lab Manual | IT department | Final Year





#include
#include
#include
void main()
{
int gd=DETECT,gm;
int x1=0,x2=0,y1=0,y2=0;
int a,b,x,y,i,j;
int sx=0,sy=0;
char q[10];
int maxx,maxy;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
clrscr();
printf("\n\t2D Transformation-Scaling");
printf("\nEnter values for (x1,y1) and (x2,y2):\t");
scanf("%d%d%d%d",&x1,&y1,&x1,&y2);
printf("\nEnter the shearing factor:");
scanf("%d%d",&sx,&sy);
cleardevice();
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
line(50,maxy-35,maxx-50,maxy-35);
outtextxy(600,400,"x");
line(50,10,50,maxy-35);
outtextxy(30,10,"y");
for(i=30;i<=320;i+=30)
{
sprintf(q,"%3d",i);
outtextxy(40+i,450,q);
}
for(j=30;j<=450;j+=30)
{
sprintf(q,"%3d",j);
outtextxy(25,450-j,q);
}
x=x1+50;
y=450-y1;
  a=x2+50;
b=450-y2;
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
gotoxy(20,1);
rectangle(x,y,a,b);
x1*=sx;
y1*=sy;
x2*=sx;
y2*=sy;
x1=x1+50;
y1=450-y1;
x2=x2+50;
y2=450-y2;
setlinestyle(DOTTED_LINE,0,2);
rectangle(x1,y1,x2,y2);
getch();
closegraph();
}




No comments:

Don't You Think this Awesome Post should be shared ??
| 2D Transformation - Scaling | Computer Graphics Lab Manual | IT department | Final Year |
Back To Top Related Posts Plugin for WordPress, Blogger...