Write a program to use 2D Translation technique...
#include <graphics.h>
#include <stdlib.h>#include <stdio.h>
#include <conio.h>
int main()
{
int gdriver = DETECT, gmode, errorcode;
int ax,ay,bx,by;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
printf("\n Enter the x and y value to draw a line");
scanf("%d",&ax);
scanf("%d",&ay);
bx=ax+40;
by=ay+140;
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
setcolor(getmaxcolor());
line(ax,ay, bx, by);
getch();
setcolor(5);
line(ax+40,ay,bx+40,by);
getch();
closegraph();
return 0;
}
Output:


No comments:
Post a Comment