Write a program for 2D Scaling in C

/*
    2D Scaling
*/
#include<stdio.h>
#include<conio.h>
#include<graphics.h>

void main()
{
int gd=DETECT,gm;
int i;
int x2,y2,x1,y1,sx,sy;

clrscr();

printf("Enter the 2 line end points:");
printf("\n\n x1,y1,x2,y2: ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

printf("Enter Scaling co-ordinates sx,sy:");
scanf("%d%d",&sx,&sy);

initgraph(&gd,&gm,"c:\\turboc3\\bgi");

outtextxy(x1,y1-20,"Original Line ->");

line(x1,y1,x2,y2);

x1=x1*sx;
y1=y1*sy;
x2=x2*sx;
y2=y2*sy;

outtextxy(x1,y1-20,"After Translate Line -> ");
line(x1,y1,x2,y2);

getch();
closegraph();
}


Previous
Next Post »