//Write a program for the Scaling of Triangle
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x1,x2,x3,y1,y2,y3,sx,sy,i;
initgraph(&gd,&gm,"..\\bgi");
printf("Enter the first co-ordinate:");
scanf("%d%d",&x1,&y1);
printf("Enter the second co-ordinate:");
scanf("%d%d",&x2,&y2);
printf("Enter the third co-ordinate:");
scanf("%d%d",&x3,&y3);
cleardevice();
//printf("Traingle before scaling:\n\n\n");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
cleardevice();
printf("\nProvide value of Scalinf factor:");
scanf("%d%d",&sx,&sy);
x1=x1*sx;
x2=x2*sx;
x3=x3*sx;
y1=y1*sy;
y2=y2*sy;
y3=y3*sy;
cleardevice();
printf("\nTraingle after scaling:");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
closegraph();
}
//This code was compile in turboc.
For Query and any doubt please leave your comments.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x1,x2,x3,y1,y2,y3,sx,sy,i;
initgraph(&gd,&gm,"..\\bgi");
printf("Enter the first co-ordinate:");
scanf("%d%d",&x1,&y1);
printf("Enter the second co-ordinate:");
scanf("%d%d",&x2,&y2);
printf("Enter the third co-ordinate:");
scanf("%d%d",&x3,&y3);
cleardevice();
//printf("Traingle before scaling:\n\n\n");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
cleardevice();
printf("\nProvide value of Scalinf factor:");
scanf("%d%d",&sx,&sy);
x1=x1*sx;
x2=x2*sx;
x3=x3*sx;
y1=y1*sy;
y2=y2*sy;
y3=y3*sy;
cleardevice();
printf("\nTraingle after scaling:");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
closegraph();
}
//This code was compile in turboc.
For Query and any doubt please leave your comments.