Index: S.No. Program No. Signature
Index: S.No. Program No. Signature
S.No.
Program
Page
No.
1.
Line
2.
3.
4.
Animated Text
5.
Bouncing Ball
6.
Wheel
7.
Circle
8.
Ellipse
10
9.
Rotation
13
10.
Translation
17
Signature
if(p<0)
{
p=p+2*dy;
}
else
{
y++;
p=p+(2*dy)-(2*dx);
}
putpixel(x,y,15);
}
getch();
}
}
ellipseplotpoint(xc,yc,x,y);
}
p=ROUND(ry2*(x+0.5)*(x+0.25)+rx2*(y-1)*(y-1)-rx2*ry2);
while(y>0)
{
y--;
py-=tworx2;
if(p>0)
p+=rx2-py;
else
{
x++;
px+=twory2;
p+=rx2-py+px;
}
ellipseplotpoint(xc,yc,x,y);
}
getch();
}
void ellipseplotpoint(int xc,int yc,long x,long y)
{
putpixel(xc+x,yc+y,12);
delay(10);
putpixel(xc-x,yc+y,12);
delay(10);
putpixel(xc+x,yc-y,12);
delay(10);
putpixel(xc-x,yc-y,12);
delay(10);
}
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm=DETECT;
int x,y=0,j,t=400,c=1;
initgraph(&gd,&gm,"");
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
for(x=40;x<602;x++)
{
cleardevice();
circle(x,y,30);
floodfill(x,y,RED);
delay(40);
if(y>=400)
{
c=0;
t-=20;
}
if(y<=(400-t))
c=1;
y=y+(c?15:-15);
}
getch();
}
#include<conio.h>
#include<graphics.h>
#include<math.h>
int L=0;
void ddaline(int x1,int y1,int x2,int y2)
{
int s,dx,dy,m,c=0;
float xi,yi,x,y;
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
s=abs(dx);
else
s=abs(dy);
xi=dx/(float)s;
yi=dy/(float)s;
x=x1;
y=y1;
putpixel(x1+0.5,y1+0.5,15);
for(m=0;m<s;m++)
{
x+=xi;
y+=yi;
if(getpixel(x+0.5,y+0.5)==4)
{
c++;
continue;
}
if(c%2==0)
{
putpixel(x+0.5,y+0.5,15);
}
}
}
else
{
y--;
p+=2*(x-y)+1;
}
}
}
void main()
{
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm,"");
mcircle(300,250,20,1);
mcircle(300,250,100,0);
getch();
}
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <math.h>
float x1,y1,x2,y2,x,y,x3,y3,x4,y4,a;
int ch;
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
clrscr();
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
do
{
cout<<" #############MAIN-MENU###############\n";
cout<<" ROTATION\n";
cout<<" 1.LINE\n";
cout<<" 2.RECTANGLE\n";
cout<<" 3.TRIANGLE\n";
cout<<"enter your choice:0 for exit:\n";
cin>>ch;
switch(ch)
{
case 1: cout<<"enter the values of line coordinates:";
cin>>x1>>y1>>x2>>y2;
cout<<"enter the value for angle of rotation:";
cin>>a;
cleardevice();
line(x1,y1,x2,y2);
a=a*(3.14/180);
x1=(x1*cos(a))-(y1*sin(a));
y1=(x1*sin(a))+(y1*cos(a));
x2=(x2*cos(a))-(y2*sin(a));
y2=(x2*sin(a))+(y2*cos(a));
cout<<"now hit a key to see rotation:";
getch();
line(x1,y1,x2,y2);
break;
x1=(x1*cos(a))-(y1*sin(a));
y1=(x1*sin(a))+(y1*cos(a));
x2=(x2*cos(a))-(y2*sin(a));
y2=(x2*sin(a))+(y2*cos(a));
x3=(x3*cos(a))-(y3*sin(a));
y3=(x3*sin(a))+(y3*cos(a));
cout<<"now hit a key to see rotation:";
getch();
moveto(x1,y1);
lineto(x2,y2);
moveto(x2,y2);
lineto(x3,y3);
moveto(x3,y3);
lineto(x1,y1);
break;
case 0: break;
default:cout<<"invalid choice";break;
}}while(ch!=0);
getch();
closegraph();
return 0;
}
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
int x1,y1,x2,y2,x,y,x3,y3,x4,y4,ch;
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
do
{
getch();
cleardevice();
cout<<" #############MAIN-MENU###############\n";
cout<<" TRANSLATION\n";
cout<<" 1.LINE\n";
cout<<" 2.RECTANGLE\n";
cout<<" 3.TRIANGLE\n";
cout<<"enter your choice:0 for exit:\n";
cin>>ch;
switch(ch)
{
case 1: cout<<"enter the values of line coordinates:";
cin>>x1>>y1>>x2>>y2;
cout<<"enter the translation coordinates:";cin>>x>>y;
cleardevice();
line(x1,y1,x2,y2);
cout<<"now hit a key to see translation:";
getch();
line(x1+x,y1+y,x2+x,y2+y);
break;
rectangle(x1+x,y1+y,x2+x,y2+y);
break;
case 3: cout<<"enter coordinates of line1:\n";
cin>>x1>>y1>>x2>>y2;
cout<<"enter coordinates for relative line:\n";
cin>>x3>>y3;
cout<<"enter translation coordinates:\n";cin>>x>>y;
cleardevice();
line(x1,y1,x2,y2);
moveto(x2,y2);
lineto(x3,y3);
moveto(x3,y3);
lineto(x1,y1);
cout<<"now hit a key to see translation:";
getch();
moveto(x1+x,y1+y);
lineto(x2+x,y2+y);
moveto(x2+x,y2+y);
lineto(x3+x,y3+y);
moveto(x3+x,y3+y);
lineto(x1+x,y1+y);
break;
case 0: break;
default:cout<<"invalid choice";break;
}}while(ch!=0);
getch();
closegraph();
return 0;}