0% found this document useful (0 votes)
344 views

CGMA-Practical File

The document is a practical file on graphics submitted by a B.C.A. final year student, Pooja, detailing various graphics programs and their applications. It includes an introduction to computer graphics, its applications in fields like education, medicine, and entertainment, along with multiple programming examples for drawing shapes and figures. Acknowledgments are made to the college, faculty, and university for their support in the completion of the practical file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
344 views

CGMA-Practical File

The document is a practical file on graphics submitted by a B.C.A. final year student, Pooja, detailing various graphics programs and their applications. It includes an introduction to computer graphics, its applications in fields like education, medicine, and entertainment, along with multiple programming examples for drawing shapes and figures. Acknowledgments are made to the college, faculty, and university for their support in the completion of the practical file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Practical File

Of
“Graphics”

Submitted to Submitted by
Mrs.Reena Bajaj Pooja
B.C.A.(Final year)

______________________________
Master Tara Singh College For Women
Near Old Sabzi Mandi,Ludhiana.
CONTENTS

DESCRIPTION REMARKS
➢ INTRODUCTION TO GRAPHICS
➢ APPLICATIONS OF GRAPHICS
▪ PROGRAM TO DRAW A CIRCLE
▪ PROGRAM TO DRAW AN ARC
▪ PROGRAM TO DRAW AN ELLIPSE
▪ PROGRAM TO DRAW A RECTANGLE
▪ PROGRAM TO DRAW A TRIANGLE
▪ PROGRAM TO DRAW CONCENTRIC
CIRCLES
▪ PROGRAM TO DRAW JOKER WITH CAP
▪ PROGRAM TO DRAW SIN WAVES
▪ PROGRAM TO DRAW A HISTOGRAM
▪ PROGRAM TO DRAW A BAR CHART
▪ PROGRAM TO DRAW A HUT
▪ PROGRAM TO DRAW A FILLELLIPSE
▪ PROGRAM TO DRAW A SMILING FACE
▪ PROGRAM TO DRAW A SAD HUMAN FACE
▪ PROGRAM TO DRAW A CONCENTRIC
CIRCLES WITH FOR LOOP
▪ PROGRAM TO DRAW A SQUARE
▪ PROGRAM TO DRAW NUMBER OF
BALLOONS
▪ PROGRAM TO DRAW A SIN WAVE
WITH FOR LOOP
▪ PROGRAM TO DRAW A CYCLE
▪ PROGRAM TO DRAW A CAR
▪ PROGRAM TO DRAW A SCENERY
▪ PROGRAM TO DRAW A STAR
▪ PROGRAM TO DRAW DIFFERENT LINE STYLES
▪ PROGRAM TO DRAW ALL GRAPHICS
FUNCTIONS
Acknowledgement
To matter what accomplishment we achieve somebody
helps us. For every accomplishment we need the
cooperation and help of others. As knowledge advances by
steps not by leaps. So, ability advances by encouragement
and guidance. Although you have ability and knowledge
but it is worthless, unless and until you can develop it if
somebody encourage you.

First of all we would to thank Panjab University for


providing an opportunity of bachelor degree in Computer
Application that is B.C.AIII year. We wish to thank to our
worthy Principal Mrs.Surinder kaur Atwal and college
management for putting the necessary hardware at our
disposal.

I am also thankful to Mrs.Reena Bajaj, who gives me very


useful and important tips to make the practical file of
Graphics.

I am also thankful to the staff of department of computer


science in Master Tara Singh Memorial College for
Women, Ludhiana.
Introduction

About

Computer Graphics
Computer Graphics
Computer graphics studies the manipulation of visual and
geometric information using computational techniques. It is
a branch of computer science that deals with theory and
implementation of computerized image generation.
Computer graphics have been in use since the development
of computers and over the past few years, there have been
great advancement in the use of computer graphics.
Computer graphics are being used in every sphere of life
such as in science, engineering, business, medical science,
education, training and entertainment. Computer graphics
can be seen in work in film special effects, simulation and
training, TV commercial advertisements, games, animation,
medical imagery, flying logos, etc.
Computer graphics have been a key
technology ion communicating in ideas and data and
present in an interactive way. Earlier, information was
rendered in textual form only. But nowadays, it can be
displayed on the graphical devices in textual and graphical
forms for better interpretation and experience.
Computer graphics is nothing but creation,
storage, manipulation of pictures and drawing using digital
computer. It enhances the power of communication
between the computer and user. The facilities of graphics
depend upon its hardware and software.
In graphics mode the CRT screen is divided
in to a meshes of individual dots called pixels. The
measurement of pixels are called resolution of the monitor.
Applications of Computer Graphics

As computers became more affordable, the application


areas of computer graphics have gradually expanded.
Before moving further, there are some application areas in
which we use computer graphics are:-
• Computer aided design(CAD)
• Graphical user interface(GUI)
• Entertainment
• Education and training
• Presentation graphics
• Computer art
• Visualization
• Image
processing
• Medicine

Computer Aided
Design:- An
important use of
computer graphics
can be seen in the
field of science and
engineering for design
applications. In recent
years, almost all
products are now
being designed using
Computer-Aided
Design (CAD) applications. CAD is the use of computer
technology to aid in the design and drawing a part or
product. It is both a visual and symbol-based method of
communication whose conventions are particular to a
specific technical field.

Graphical User Interfaces (GUI):- Graphical User


Interface (GUI) is a type
of user interface which
allows people to interact
with a system, mostly
electronic devices like
computers, handheld
devices, household
appliances and office
equipment. Almost every
software package now
comes with a graphical
interface through which
we can use it. A very
good example of GUI is
Windows operating
system by Microsoft Inc.
Not only with software packages, but
GUI comes with lot other kinds of devices also. Like
configuring the settings of your T.V, using and operating a
mobile phone or ATM machine, Kiosks, electronic
equipments, etc. A GUI interface now a days is inherent in
almost every device to use.
Entertainment:- Computer graphics can be commonly
seen in motion pictures, motion videos, computer games
and commercial advertisements. Computer graphics is
having a vast impact on the entertainment and advertising
industries. The first use of computer graphics could be seen
in the Future World released in 1976 and now, the world
has been seduced by computer animation, special effects,
and photorealistic imagery of virtual environments. From
‘Chhota Chetan’, ‘Jurassic Park’ ‘Star-wars’ movies,
‘Hanuman’, ‘Ice-Age’, ‘Bal-Ganesha’ to similar rides at
Disney World.
Education and Training:- Earlier education and training
was rendered using pen/pencil/paper or chalk-board style of
teaching. But nowadays, with the help of computer
graphics, computer-generated models of physical, financial
and economic systems are often used as educational aids.
Computer graphics can be used to design images, videos
through which education or training can be given away in a
graphical form which would be easier to interpret and
understand for the trainees. E.g. instead of a text-book
diagram of human body, if an animated model could be
shown on the screen with various anabolic and metabolic
activities of the body depicted in the form of moving

objects, then the students can learn the functioning of


human body in a better way. To science students, the
instructors or trainers can also use computer graphics to
generate images in order to demonstrate how the solar
system works.

Presentation Graphics:- Computer graphics is in


presentation methods. Various kinds of presentation
graphics are available these days, that can be used to
produce illustrations for reports or other facts and figures
that can be easy to interpret and analyze. Presentation
graphics are commonly used to summaries financial,
statistical, mathematical, scientific and economic. For
example, if instead of mere facts and figures, these data are
depicted and presented in the form of pie-charts or bar
charts, then the ideas can be delivered in a more effective
way. Similarly, the variations in sensex in stock-exchange
or swings in voter-population on news channels during
election days.
Computer Art:- Computer graphics techniques and
methods are commonly used in both Fine Art and
Commercial Art applications. These days, logos, marriage
cards, posters, pamphlets, visiting cards, book-designing,
billboard advertisements are all designed on computer
itself. Even a newspaper is also designed on a computer
itself. A very good advantage of Computer Graphics Art
Applications is that you do not need to throw away a design
if even a small mistake is made on it and create a new one,
as traditionally it was done using a pencil/brush and paper.
You can now undo and continue work on it and even create
as many copies of it as you need. ‘Paintbrush’ with
Windows Operating System is a common graphics
application to use. Some other popular graphics packages
are Adobe Photoshop, Illustrator, Corel Draw, Corel Paint,
PostScript, Quark Express, etc.

Visualization:- The analysis of large amount of


information to study the behavior of certain processes using
traditional means by scientists, engineers and business
analysts has remained a tough job. For example, the census
results and trends can be analyzed and displayed
graphically using computer applications. Business
visualization tools are available that can be used to draw
results of various experiments.
Image Processing:- Image processing is any form of
signal processing for which the input is an image such as
photo-graphs or frames of video and the output of image
processing can be either an image or a set of characteristics
or parameters related to the image. Image processing is
used to enhance or modify existing images as compared to
generating new ones as in computer graphics. This means,
image processing can be used to enhance picture quality or
machine perception of image information etc, of an already
existing image. Image processing usually refers to digital
image processing, but optical and analog image processing
are also possible. Medical practitioners use image
processing techniques in X-ray photography etc.
Medicine:- An important application area of computer
graphics is in Medical field. These days, the results of most
of the medical-tests can be seen on the computer screen
itself for better visualization and diagnostics. Graphics
techniques can be used in medicine to model and study
physical functions to design artificial limbs, to plan and
practice surgery and for patient-monitoring activities.
Medical and Pharmaceutical researchers are also using
graphical systems to study the effects of a medicine on
parts of a human body or other creatures. You can see a
number of graphical screens if you visit an Intensive Care
Unit in a hospital.
Introduction

Of

Graphics Programs
Write a Program to draw a circle

#include<graphics>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"\\tc\\");
circle(250,250,100);
getch();
closegraph();
}
The output is:
Write a Program to draw an arc

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
arc(300,200,0,180,90);
getch();
closegraph();
}
The output is:
Write a Program to draw an ellipse

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
ellipse(300,200,0,360,50,30);
getch();
closegraph();
}
The output is:
Write a Program in graphics of rectangle
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
rectangle(100,100,300,200);
getch();
closegraph();
}
The output is:
Write a Program in graphics of triangle
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
int x,y;
initgraph(&gd,&gm,"//tc//");
line(200,200,400,200);
line(200,200,300,100);
line(400,200,300,100);
getch();
closegraph();
}
The output is:
Write a Program to draw concentric circle
#include<graphics.h>
#include<conio.h>
void main()
{
int i,r=0;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
circle(250,200,80);
circle(250,200,70);
circle(250,200,60);
circle(250,200,50);
circle(250,200,40);
circle(250,200,30);
circle(250,200,20);
circle(250,200,10);
circle(250,200,5);
circle(250,200,0);
getch();
closegraph();
}
The output is:
Write a Program to draw a joker with cap
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
int triangle[]={320,140,420,240,220,240,320,140};
initgraph(&gd,&gm,"//tc//");
drawpoly(4,triangle);
setfillstyle(5,4);
floodfill(320,150,15);
arc(320,240,180,0,100);
circle(270,270,10);
circle(370,270,10);
line(320,280,320,290);
arc(320,300,180,0,20);
setcolor(4);
fillellipse(320,295,5,4);
getch();
closegraph();
}
The output is:
Write a Program to draw a sin waves
#include<graphics.h>
#include<conio.h>
void main()
{
int i,r=0;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
arc(100,200,180,360,30);
arc(160,200,360,180,30);
arc(220,200,180,360,30);
arc(280,200,360,180,30);
arc(340,200,180,360,30);
arc(400,200,360,180,30);
arc(460,200,180,360,30);
getch();
closegraph();
}
The output is:
Write a Program to draw a histogram

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
line(100,400,370,400);
line(100,100,100,400);
line(130,100,130,400);
line(100,100,130,100);
line(170,150,170,400);
line(190,150,190,400);
line(170,150,190,150);
line(230,200,230,400);
line(250,200,250,400);
line(230,200,250,200);
line(290,250,290,400);
line(310,250,310,400);
line(290,250,310,250);
line(350,300,350,400);
line(370,300,370,400);
line(350,300,370,300);
getch();
closegraph();
}
The output is:
Write a Program in graphics of bar chart

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
line(100,350,310,350);
line(100,100,100,350);
line(130,100,130,350);
line(100,100,130,100);
line(130,120,160,120);
line(160,120,160,350);
line(160,140,190,140);
line(190,140,190,350);
line(190,160,220,160);
line(220,160,220,350);
line(220,180,250,180);
line(250,180,250,350);
line(250,200,280,200);
line(280,200,280,350);
line(280,220,310,220);
line(310,220,310,350);
getch();
closegraph();
}
The output is:
Write a Program in graphics of hut

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
setbkcolor(7);
setcolor(6);
line(200,120,160,200);
line(200,120,240,200);
line(200,120,390,120);
line(390,120,430,200);
line(160,200,430,200);
line(430,200,430,300);
line(160,200,160,300);
line(240,200,240,300);
line(240,300,430,300);
circle(200,170,10);
line(180,300,160,380);
line(220,300,200,380);
line(160,300,180,300);
line(220,300,240,300);
setcolor(2);
line(260,230,260,280);
line(300,230,300,280);
line(260,280,300,280);
arc(280,230,0,180,20);
line(260,230,300,230);
line(360,230,360,280);
line(400,230,400,280);
line(360,280,400,280);
arc(380,230,0,180,20);
line(360,230,400,230);
line(180,230,180,300);
line(220,230,220,300);
line(180,230,220,230);
arc(200,230,0,180,20);
getch();
closegraph();
}
The output is:
Write a Program in graphics of fillellipse

#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
fillellipse(300,200,50,30);
getch();
closegraph();
}
The output is:
Write a Program in graphics of smiling
human face

#include<graphics.h>
#include<conio.h>
void main()
{
int i;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
circle(250,250,90);
circle(215,230,15);
circle(280,230,15);
line(230,280,265,280);
line(250,250,230,280);
line(250,250,265,280);
arc(250,270,190,350,40);
getch();
closegraph();
}
The output is:
Write a Program in graphics of sad human
face

#include<graphics.h>
#include<conio.h>
void main()
{
int i;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
circle(250,250,90);
circle(215,230,15);
circle(280,230,15);
fillellipse(215,250,2,1);
fillellipse(215,260,1,2);
fillellipse(280,250,2,1);
fillellipse(280,260,1,2);
line(230,280,265,280);
line(250,250,230,280);
line(250,250,265,280);
arc(250,330,20,160,40);
getch();
closegraph();
}
The output is:
Write a Program in graphics of concentric
circles with for loop
#include<graphics.h>
#include<conio.h>
void main()
{
int i,r=0;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
setcolor(6);
for(i=0;i<6;i++)
{
circle(300,250,r);
r+=10;
}
getch();
closegraph();
}
The output is:
Write a Program in graphics of square
#include<graphics.h>
#include<conio.h>
void main()
{
int i;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
line(100,300,300,300);
line(100,300,100,100);
line(100,100,300,100);
line(300,300,300,100);
getch();
closegraph();
}
The output is:
Write a Program in graphics of number of
balloons
#include<graphics.h>
#include<conio.h>
void main()
{
int i,r=0;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
ellipse(140,150,0,360,30,40);
line(140,190,250,350);
ellipse(200,120,0,360,30,50);
line(210,170,250,350);
ellipse(270,140,0,360,30,50);
line(270,190,250,350);
line(340,200,250,350);
ellipse(340,150,0,360,30,50);
arc(250,360,90,270,10);
arc(250,380,270,90,10);
line(250,390,250,440);
getch();
closegraph();
}
The output is:
Write a Program in graphics of sin wave with
for loop

#include<graphics.h>
#include<conio.h>
void main()
{
int i,x=100,y=100;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
for(i=0;i<6;i++)
{
if(i%2==0)
{
arc(x,y,0,180,30);
x=x+60;
}
else
{
arc(x,y,180,360,30);
x=x+60;
}
}
getch();
closegraph();
}
The output is:
Write a Program in graphics of cycle
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
circle(400,300,10);
circle(200,300,10);
circle(200,300,50);
circle(400,300,50);
line(200,300,400,300);
line(400,300,300,150);
line(200,300,300,150);
line(200,300,150,150);
line(150,150,300,150);
fillellipse(300,150,40,10);
arc(200,150,85,180,50);
line(400,300,400,180);
line(350,180,450,180);
getch();
closegraph();
}
The output is:
Write a Program in graphics of car
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
line(100,300,450,300);
arc(200,300,180,0,20);
arc(200,300,180,0,30);
arc(350,300,180,0,20);
arc(350,300,180,0,30);
line(100,300,100,250);
line(100,250,130,250);
line(130,250,200,170);
line(200,170,330,170);
line(420,250,330,170);
line(450,300,450,250);
line(450,250,420,250);
rectangle(400,250,420,260);
line(200,197,200,240);
line(200,240,240,240);
arc(190,240,0,60,50);
line(200,197,215,197);
line(255,197,275,197);
line(255,197,255,240);
line(300,240,255,240);
arc(250,240,0,60,50);
circle(330,220,15);
getch();
closegraph();
}
The output is:
Write a Program in graphics of scenery

#include<graphics.h>
#include<conio.h>
void main()
{
int i,r=0;
int gd=DETECT,gm;
initgraph(&gd,&gm,"//tc//");
setbkcolor(7);
setcolor(6);
line(200,120,160,200);
line(200,120,240,200);
line(200,120,390,120);
line(390,120,430,200);
line(160,200,430,200);
line(430,200,430,300);
line(160,200,160,300);
line(240,200,240,300);
line(240,300,430,300);
circle(200,170,10);
line(180,300,160,380);
line(220,300,200,380);
line(160,300,180,300);
line(220,300,240,300);
setcolor(2);
line(260,230,260,280);
line(300,230,300,280);
line(260,280,300,280);
arc(280,230,0,180,20);
line(260,230,300,230);
line(360,230,360,280);
line(400,230,400,280);
line(360,280,400,280);
arc(380,230,0,180,20);
line(360,230,400,230);
line(180,230,180,300);
line(220,230,220,300);
line(180,230,220,230);
arc(200,230,0,180,20);
arc(40,50,180,0,40);
arc(120,50,0,180,40);
arc(200,50,180,0,40);
arc(280,50,0,180,40);
arc(360,50,180,0,40);
arc(440,50,0,180,40);
arc(520,50,180,0,40);
arc(600,50,0,180,40);
arc(360,72,0,180,30);
line(342,50,320,20);
line(336,55,318,40);
line(348,46,340,30);
line(356,44,346,14);
line(363,43,365,25);
line(371,42,378,15);
line(379,47,388,30);
line(382,53,400,40);
getch();
closegraph();
}
The output is:
Write a Program in graphics of star
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"\\tc\\");
line(200,300,400,300);
line(200,300,300,140);
line(400,300,300,140);
line(200,175,400,175);
line(200,175,290,335);
line(290,335,400,175);
getch();
closegraph();
}
The output is:
Write a Program to show different line styles
#include<graphics.h>
#include<conio.h>
void main()
{
int gd =DETECT,gm;
initgraph (&gd,&gm,"//tc//");
setlinestyle(0,SOLID_LINE,1);
line(150,300,400,300);
setlinestyle(1,DOTTED_LINE,1);
line(150,350,400,300);
setlinestyle(3,DASHED_LINE,1);
line(150,400,400,300);
getche();
closegraph();
}
The output is:-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy