You are on page 1of 22

CHIKKANNA GOVERNMENT ARTS COLLEGE

TIRUPUR -641602
(Affiliated to Bharathiar University)

NAME :
REG. NO. :

DEPARTMENT OF COMPUTER SCIENCE

LAB VI - GRAPHICS AND MULTIMEDIA


CHIKKANNA GOVERNMENT ARTS COLLEGE
TIRUPUR -641602
( Affiliated to Bharathiar University)

RECORD OF PRACTICAL WORK

NAME :
REG. NO. :
CLASS : III B.Sc., Computer Science

This is to certified that it is a bonafide record of the practical


work done in GRAPHICS AND MULTIMEDIA LAB of III
B.Sc.,Computer Science degree course during the year 2023 -2024.

Staff In-Charge Head of Department

Submitted for the University Practical Examination held on…………….

Internal Examiner External Examiner


CONTENTS

PAGE
S.No. PROGRAM TITLE DATE
No.

GRAPHICS

1. Rotation of an image

2. Dropping of word one by one

3. Line Drawing using DDA Algorithm

4. Moving a Car

5. Bouncing a Ball

6. Pixel is inside or out side

MULTIMEDIA

7. Drawing a Sun Flower

8. Moving the Plane

9. Plastic Surgery of Nose

10. See Through Text

11. Creating Web Pages

12. Black and White Image to a Color Image


ROTATION OF AN IMAGE

#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x1, y1, x2, y2,ang;
double dr;
initgraph(&gd, &gm, “c:\c_ _~1\bgi”);
circle(200, 180, 40);
circle(250, 180, 20);
printf(“\n Enter the angle : ”);
scanf(”%d”,&ang);
dr=ang*3.14/180;
x1=200+(100)*cos(dr)+100*sin(dr);
y1=200+(100)*sin(dr)+100*cos(dr);
x2=200+(150)*cos(dr)+100*sin(dr);
y2=200+(-150)*sin(dr)+100*cos(dr);
circle(x1,y1,40);
circle(x2,y2,20);
getch();
closegraph();
}
OUTPUT:

Enter the angle: 90


DROPPING OF WORD ONE BY ONE

# include <stdio.h >


# include <conio.h>
# include <graphics.h>
# include <string.h >
void main ( )
{
int gd= DETECT, gm , i, j ,l ;
char m[50] ;
initgraph ( &gd, &gm, “c:\c_ _~1\bgi”);
printf (“Enter the string:”) ;
for ( j=0 ; j <=4; j + +)
{
if (m[ j ] ! = ‘ \ 0 “’ )
{
scanf (“ % s ”, & m) ;
for (i =0 ; i <=300 ; i+ + )
{
cleardevice( ) ;
outtextxy (100, 100 + i , m) ;
if ( m== 0)
getch ( ) ;
}
}
}
getch( ) ;
}
OUTPUT:

Enter the string:

Welcome to multimedia

Welcome

to

multimedia
LINE DRAWING USING DDA ALGORITHM

#include < iostream.h>


#include < conio.h>
#include < graphics.h>
#include < math.h>
void main()
{
int gd=DETECT,gm,i ;
initgraph (&gd,&gm, “c:\c_ _~1\bgi”);
double x,y,xl,y1,x2,y2,xinc,yinc;
double dx,dy,steps;
while (1)
{
cout<<”\n Enter xl & yl: \n”;
cin>>xl >>y1;
if (y1>>14)
{
break;
}
cout <<”/n !!please try again”;
}
while(1)
{
cout <<”/n Enter x2 & y2: \n “;
cin>>x2>>y2;
if(y2>14)
{
break;
}
cout >>”\n !!please try again ”

}
cleardevice();
dx=x2-x1;
dy=y2-y1;
if (abs (dx) > abs (dy) )
steps= abs (dx);
else
steps= abs (dy);
x=x1;
y=y1;
putpixel(x,y, WHITE);
xinc= dx/(steps+0.5);
yinc=dy/(steps+0.5);
for(i=0;i<=steps;i++)
{
x=x+xinc;
y=y+yinc;
putpixel(x,y,WHITE);
}
outextxy(10,5 “DDA ALGORITHM”);
getch();
}
OUTPUT:

Enter x1 & y1: 45


13

!! please try again

Enter x1 & y1: 45


25

Ener x2 & y2:78


6

!! Please try again

Enter x2 & y2: 78


63

DDA ALGORITHM
MOVING A CAR

#include<stdio.h>
#include<alloc.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,x;
initgraph(&gd,&gm, “c:\c_ _~1\bgi”);
x=0;
while(x<640)
{
cleardevice();
line(x+50,300,x+100,300);
line(x+50,305,x+105,305);
line(x+100,300,x+125,275);
line(x+105,305,x+130,280);
line(x+125,275,x+200,275);
line(x+130,305,x+200,280);
line(x+105,305,x+225,305);
line(x+200,275,x+225,300);
line(x+200,280,x+225,305);
line(x+225,300,x+300,300);
line(x+225,305,x+300,305);
line(x+300,300,x+310,325);
line(x+50,325,x+50,325);
line(x+310,325,x+40,325);
line(x+305,320,x+40,320);
line(x+50,300,x+50,325);
line(x+40,320,x+25,320);
line(x+30,320,x+25,320);
circle(x+100,336,10);
circle(x+100,336,5);
circle(x+225,336,10);
circle(x+225,336,5);
x+=5;
delay(75);
sound(3000);
}
getch();
closegraph();
}
OUTPUT:
BOUNCING A BALL

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,i,j;
initgraph(&gd,&gm, “c:\c_ _~1\bgi”);
printf("BOUNCING BALL");
setcolor(5);
circle(50,140,30);
floodfill(50,140,5);
getch();
for(i=0;i<=500;i++)
{
cleardevice();
circle(50+i,140+i,30);
floodfill(50+i,140+i,5);
}
j=500;
for(j=500;j>0;j--)
{
cleardevice();
circle(50+j,140+j,30);
floodfill(50+j,140+j,5);
}
getch();
}
OUTPUT:
PIXEL IS IN OR OUT

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd= DETECT, gm;
int x,y;
intigraph(&gd,&gm, “c:\c_ _~1\bgi”);
rectangle (30,30,70,70);
printf(“\n\n\n\n\n Enter x and y : \n”);
scanf(“%d%d”, &x,&y);
putpixel(x,y,7);
if(x>=30 && y>30 && x<=70&& y<=70)
printf(“\n Inside the pixel”);
else
printf(“\n Outside the pixel”);
getch();
}
OUTPUT:

Enter the x and y:


50
60

Inside the pixel.


1. DRAWING A SUN FLOWER
2. MOVING THE PLANE
3.PLASTIC SURGERY OF NOSE
4.SEE THROUGH TEXT
5. CREATING WEB PAGES
6. BLACK AND WHITE IMAGE TO A COLOR IMAGE

You might also like