Write a Program for 2D Shearing in C

/*
    2D Shearing
*/
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
int x1,y1,x2,y2,x,y;
int main(void)
{
int gdriver = DETECT, gmode;
clrscr();

initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");

cout<<"enter the top left coordinates:";
cin>>x1>>y1;

cout<<"enter the bottom right coordinates:";
cin>>x2>>y2;

cout<<"enter the values of shearing coordinate for x_shear:\n";
cin>>x;

cout<<"enter the values of shearing coordinate for y_shear:\n";
cin>>y;

cleardevice();

rectangle(x1,y1,x2,y2);

cout<<"now hit a key to see shear in x_axis:";

getch();

rectangle(x1,y1,x2*x,y2);

cout<<"\nnow hit a key to see shear in y_axis:";

getch();

rectangle(x1,y1,x2,y2*y);

getch();
closegraph();
}

Previous
Next Post »