Pages

Wednesday, May 18, 2011

SHEARING OF LINE

#include <graphics.h>
#include <stdio.h>
#include <conio.h>
void main( )
{
/* request auto detection */
int gdriver = DETECT, gmode;
int x1,y1,x2,y2,a,b;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
printf("Enter the value of line coordinates:");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
printf("Enter the value of x-shearing factor:");
scanf("%d",&a);
printf("Enter the value of y-shearing factor:");
scanf("%d",&b);
cleardevice( );
outtextxy(200,20,"LINE BEFORE SHEARING");
line(x1,y1,x2,y2);
x1 = x1+a*y1;
y1 = b*x1+y1;
x2 = x2+a*y2;
y2 = b*x2+y2;
getch( );
cleardevice( );
outtextxy(200,20,"LINE AFTER SHEARING");
line(x1,y1,x2,y2);
getch( );
closegraph( );
restorecrtmode( );
}
/*   OUTPUT

Enter the value of line coordinates:
20
20
100
100
Enter the value of x-shearing factor:1
Enter the value of y-shearing:1




*/

No comments:

Post a Comment