#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include<math.h>
int main()
{
int gm;
int gd=DETECT;
int x1,x2,x3,y1,y2,y3,nx1,nx2,nx3,ny1,ny2,ny3;
int xt,yt;
initwindow(1200,600);
printf("\n\t Enter the three points of a triangle: ");
setcolor(6);
setlinestyle(0,0,3);
scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
setcolor(4);
printf("\n Enter the translation factor");
scanf("%d%d",&xt,&yt);
nx1=x1+xt;
ny1=y1+yt;
nx2=x2+xt;
ny2=y2+yt;
nx3=x3+xt;
ny3=y3+yt;
line(nx1,ny1,nx2,ny2);
line(nx2,ny2,nx3,ny3);
line(nx3,ny3,nx1,ny1);
getch();
closegraph();
}
Tuesday, December 26, 2017
Home »
Computer Graphics
» Program for 2D translation in C (using graphics.h)
0 comments:
Post a Comment