Code:
# include<graphics.h>
# include<conio.h>
# include<math.h>
# include<stdio.h>
# include<process.h>
# include<iostream.h>
# include<dos.h>
float x1=40,y1=360,x2=80,y2=360,x3=60,y3=260;
void dgrid(void);
void draw_image(int ,int ,int,int,int,int);
void info(void);
void trans(void);
void scale(void);
void rotate();
int main()
{
int gd=0,gm=0;
initgraph(&gd,&gm,"e:\\tc\\bgi");
char ch;
int flag=0;
cleardevice();
draw_image(x1,y1,x2,y2,x3,y3);
info();
do
{
ch=getch();
switch(ch)
{
case 'T' | 't':
outtextxy(80,447,"Translate");
trans();
break;
case 'R' | 'r':
outtextxy(340,447," Roatating");
rotate();
break;
case 'S' | 's':
outtextxy(240,447,"Scaling");
scale();
break;
case 'e' | 'E':
flag=1;
break;
default :
float tone[7]={130.81,146.83,164.81,174.61,196,220,246.94};
for(int i=0;i<=7;i++)
{
sound(tone[i]*7);
delay(30);
}
nosound();
}
}while(flag==0);
closegraph();
restorecrtmode();
return(0);
}
void dgrid(void)
{
setfillstyle(SOLID_FILL,RED);
circle(30,400,4);
floodfill(31,399,15);
line(30,0,30,420);
line(10,400,636,400);
setfillstyle(HATCH_FILL,GREEN);
floodfill(120,100,WHITE);
outtextxy(12,370,"Y");
outtextxy(632,410,"X");
outtextxy(7,50,"50");
outtextxy(7,100,"100");
outtextxy(7,150,"150");
outtextxy(7,200,"200");
outtextxy(7,250,"250");
outtextxy(7,300,"300");
outtextxy(7,350,"350");
}
void draw_image(int a,int b,int c,int d,int e,int f)
{
cleardevice();
dgrid();
line(a,b,c,d);
line(c, d, e, f);
line( a, b, e, f);
}
void info()
{
outtextxy(59,467,"T : Translate S : Scale R : Rotate E : Exit");
}
void trans(void)
{
//works
}
void scale(void)
{
//works
}
void rotate()
{
int angle;
outtextxy(340,410,"Enter Angle");
cin>>angle;
angle=(angle*3.14)/180;
x1=x1*cos(angle)+y1*sin(angle);
y1=-x1*sin(angle)+y1*cos(angle);
x2=x2*cos(angle)+y2*sin(angle);
y2=-x2*sin(angle)+y2*cos(angle);
x3=x3*cos(angle)+y3*sin(angle);
y3=-x3*sin(angle)+y3*cos(angle);
draw_image(x1,y1,x2,y2,x3,y3);
info();
}