computer graphivs project
-
Upload
saurabh-photra -
Category
Documents
-
view
215 -
download
0
Transcript of computer graphivs project
-
7/29/2019 computer graphivs project
1/64
-
7/29/2019 computer graphivs project
2/64
-
7/29/2019 computer graphivs project
3/64
Acknowledgement
I would like to take this opportunity to
express my gratitude towards all the people who have
in various ways, helped in the successful completion of
my project.
I must convey my gratitude to Prof.
Shikha Jerath for giving me the constant source of
inspiration and help in preparing the project,
personally correcting my work and providing
encouragement throughout the project.
I also thank all my faculty members
for steering me through the tough as well as easy
phases of the project in a result oriented manner with
concern attention.
Thanking You,
Victor B. Wilson
-
7/29/2019 computer graphivs project
4/64
IntroductionToday there are very few aspects of our lives not
affected by Computers. Practically every cash or
monetary transaction that takes place daily involves
a computer. In many cases, the same is true of
computer graphics. Whether you see them on
television, in newspapers, in weather reports or while
at the doctors surgery, computer images are all
around you. A picture is worth a thousand words is a
well-known saying and highlights the advantages and
benefits of the visual presentation of our data. We are
able to obtain a comprehensive overall view of our
data and also study features and areas of particular
interest.
A well-chosen graph is able to transform a complex
table of numbers into meaningful results. You know
that such graphs are used to illustrate papers, reports
and thesis, as well as providing the basis for
presentation material in the form of slides and
overhead transparencies. A range of tools and facilities
are available to enable users to visualize their data, and
this document provides a brief summary and overview.
Computer graphics can be used in many disciplines.
Charting, Presentations, Drawing, Painting and Design,
-
7/29/2019 computer graphivs project
5/64
Image Processing and Scientific Visualization are some
among them.
In particular, we will emphasize the following
a) Basic concepts of Computer Graphics
b) Different types of Computer Graphics
c) Origin of Computer Graphics
d) Working of an interactive graphics display
e) Importance of speed in displaying pictures
f) The change in size an orientation of pictures
g) Applications of Computer Graphics
Basic Concepts of
Computer Graphics
I hope all of you are fond of video games and you may
be good at playing them. Have you seen the game ofPing-Pong? Its a game played by two people with a
pair video game controller and a home television set.
You can see that when a game is switched on, a small
bright spot, representing a ball, is seen bouncing to and
fro across the screen. Now each player uses his video
game controller to position a paddle to bounce the ball
-
7/29/2019 computer graphivs project
6/64
back to his opponent. The player who hits the ball past
his opponent wins a point and the one who gains 15
points wins the game. Now how did you invent this
video game? This has been done with the aid of
Computer Graphics. Video games represent a major
use in the home of computer graphics. Computer
graphics helps to create and manipulate pictures with
the aid of computers.
Computer graphics is concerned with all aspects of
producing images using a computer. It concerns with
the pictorial synthesis of real or imaginary objects from
their computer-based models.
Different Types ofComputer GraphicsComputer Graphics can be broadly divided into two
categories:
a)Non Interactive Computer Graphics: In Non-Interactive computer graphics otherwise
known as passive computer graphics, the
observer has no control over the image.
Familiar examples of this type of computer
-
7/29/2019 computer graphivs project
7/64
graphics include the titles shown on TV and
other forms of computer art.
b)Interactive Computer Graphics: InteractiveComputer Graphics involves a two way
communication between computer and user.
Here the observer is given some control over
the image by providing him with an input
device for example the video game controller
of the ping pong game. This helps him to
signal his request to the computer. The
computer on receiving signals from the input
device can modify the displayed picture
appropriately. To the user it appears that the
picture is changing instantaneously in
response to his commands. He can give aseries of commands, each one generating a
graphical response from the computer. In this
way he maintains a conversation, or dialogue,
with the computer. Interactive Computer
Graphics affects our lives in a number of
indirect ways. For example, it helps to trainthe pilots of our airplanes. We can create a
flight simulator which may help the pilots to
get trained not in a real aircraft but on the
grounds at the control of the flight simulator.
The flight simulator is a mock-up of an aircraft
flight deck, containing all the usual controls
-
7/29/2019 computer graphivs project
8/64
and surrounded by screens on which we have
the projected computer generated views of
the terrain visible on take-off and landing.
Flight simulators have many advantages over
the real aircrafts for training purposes,
including fuel savings, safety, and the ability to
familiarize the trainee with a large number of
the worlds airports.
Application of
Computer GraphicsAs ancient says a pixel is worth thousand words,
graphics is essential everywhere to understand the
things, concepts, etc. easily. Computer graphics is
useful in almost all part of our life. In the following
sections we are discussing some of the popular areas
of computer graphics.
Design and Drawing: In almost all areas of engineering,
be it civil, mechanical, electronic etc., drawings are of
prime importance. In fact, drawing is said to be the
language of engineers. The ability of computers to
store complex drawings and display them on demand
was one of the major attractions for using computers
-
7/29/2019 computer graphivs project
9/64
in graphic mode. However,
these were further advantages. Most of these drawings
were the result of engineering calculations. In fact,
programs can be written to make these calculations
and the results can be used to draw diagrams on
the screen. If changes are to be made,
one can get back to the design formulae and so
on. Thus, the area of design and drawing was one of
the earliest and most useful applications of graphics.
Animation: But what brought
the computers pretty close to the average individuals is
the concept of
animation moving pictures. It is the well-known
principle of moving pictures that a succession of
related pictures, when flashed with sufficient speedwill make the succession of pictures appears to be
moving. In movies, a sequence of such
pictures is shot and is displayed with sufficient speed
to make them appear moving. Computers can do it in
another way. The properties of the picture can be
modified at a fairly fast rate to make it appear moving.For example, if a hand is to be moved, say, the
successive positions of the hand at different periods
of time can be computed and pictures showing
the position of the hand at these positions can be
flashed on the screen. This led to the concept of
animation or moving pictures. In the initial stages,
-
7/29/2019 computer graphivs project
10/64
animation was mainly used in computer games.
However, this led to a host of other possibilities. As we
see later on in this course, computers not only
allow you to display the figures but also offer you
facilities to manipulate them in various ways you can
enlarge, reduce, rotate, twist, morph (make one
picture gradually change to another like an
Advertisement showing a cheetah changes into
a motor bike) and do a whole lot of other things. Thus,
a whole lot of films made use of computers to generate
tricks. In fact, several advertisement films &
cartoon strips are built with no actors at all only the
computer generated pictures.
Multimedia Applications: The use of sound cards to
make computers produce sound effect led to otheruses of graphics. The concept of virtual reality,
where in one can be taken through an unreal
experience, like going through an un-built house (to
see how it feels inside, once it is built) are possible by
the use of computer graphics technology. In
fact the ability of computers to convert electronicsignals (0 & 1) to data & then on to figures and pictures
has made it possible for us to get photographs of
distant planets like mars being reproduced here on the
earth in almost real time.
-
7/29/2019 computer graphivs project
11/64
Simulation: The other revolutionary change
that graphics made was in the area of simulation.
Basically simulation is a mock-up of an environment
elsewhere to study or experience it. The availability of
easily interactive devices (mouse is one of them, we
are going to see a few other later in the
course) made it possible to build simulators. One
example is of flight simulators, wherein the trainee,
sitting in front of a computer, can operate on
the interactive devices as if he were operating on the
flight controls and the changes he is expected to see
outside his window are made to appear on the screen,
so that he can master the skills of flight operations
before actually trying his hand on the actual flights.
The graphic capabilities of computers are used in avery large variety of areas like criminology (to recreate
faces of victims, assailants etc.) medical fields
(recreating pictures of internal cavities, using
signals sent by miniature cameras), recreation of
Satellite pictures etc.
-
7/29/2019 computer graphivs project
12/64
Program toDraw a Circle
-
7/29/2019 computer graphivs project
13/64
Program:
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
circle(250,250,100);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
14/64
Program to
Draw an Arc
-
7/29/2019 computer graphivs project
15/64
Program:
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
arc(300,200,0,180,90);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
16/64
Program to
Draw an
Ellipse
-
7/29/2019 computer graphivs project
17/64
Program:
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
ellipse(300,200,0,360,50,30);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
18/64
Program to
Draw a
Rectangle
-
7/29/2019 computer graphivs project
19/64
Program:
#include#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
rectangle(100,100,300,200);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
20/64
Program to
Draw a
Square
-
7/29/2019 computer graphivs project
21/64
Program:
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
line(100,300,300,300);
line(100,300,100,100);
line(100,100,300,100);
line(300,300,300,100);
getch();
closegraph(); }
-
7/29/2019 computer graphivs project
22/64
Program toDraw a
Triangle
-
7/29/2019 computer graphivs project
23/64
Program:
#include#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
line(200,200,400,200);
line(200,200,300,100);
line(400,200,300,100);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
24/64
Program toDraw a Hut
-
7/29/2019 computer graphivs project
25/64
Program:
#include
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
line(200,150,170,200);line(200,150,230,200);
rectangle(170,200,400,270);
line(200,150,370,150);
-
7/29/2019 computer graphivs project
26/64
line(370,150,400,200);
line(230,200,230,270);
circle(200,180,5);
rectangle(290,220,340,250);
rectangle(190,220,210,270);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
27/64
Program toDraw a Car
-
7/29/2019 computer graphivs project
28/64
Program:#include
#include
#include
void main(){
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(100,200,WHITE);
setcolor(BLACK);
line(100,200,170,200);
line(170,200,190,150);
line(190,150,290,150);
line(290,150,310,200);
-
7/29/2019 computer graphivs project
29/64
line(310,200,380,200);
line(100,200,100,230);
line(100,230,170,230);
circle(190,230,20);
line(310,230,380,230);
circle(290,230,20);
line(210,230,270,230);
line(380,200,380,230);
rectangle(200,160,230,190);rectangle(250,160,280,190);
line(190,210,190,250);
line(170,230,210,230);
line(290,210,290,250);
line(270,230,310,230);
getch();
closegraph(); }
-
7/29/2019 computer graphivs project
30/64
Program to
Draw
Concentric
Circles
-
7/29/2019 computer graphivs project
31/64
Program:#include
#include
void main()
{
int gd=DETECT,gm;
int i;
initgraph(&gd,&gm,"d:\\tc\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
for(i=0;i
-
7/29/2019 computer graphivs project
32/64
Program toDraw a
Pentagram
-
7/29/2019 computer graphivs project
33/64
Program:
#include
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\TC\\bgi");
setfillstyle(1,WHITE);
floodfill(1,1,WHITE);
setcolor(BLACK);
circle(150,160,63);
line(150,100,100,200);
-
7/29/2019 computer graphivs project
34/64
line(100,200,200,200);
line(200,200,150,100);
line(100,125,200,125);
line(100,125,150,225);
line(150,225,200,125);
getch();
closegraph();
}
-
7/29/2019 computer graphivs project
35/64
Program to
Draw a
Scenery
-
7/29/2019 computer graphivs project
36/64
Program:
#include#include
-
7/29/2019 computer graphivs project
37/64
#include
void tree(int
t,int q)
{
int r=15;
-
7/29/2019 computer graphivs project
38/64
setfillstyle(6,BROWN);
rectangle(150
+t,390+q,170
+t,340+q);
-
7/29/2019 computer graphivs project
39/64
floodfill(151+t,342+q,2);
setfillstyle(11,
GREEN);
fillellipse(142+t,347+q,r,r);
-
7/29/2019 computer graphivs project
40/64
fillellipse(160+t,330+q,r,r);
fillellipse(175
+t,340+q,r,r);
fillellipse(180+t,350+q,r,r);
-
7/29/2019 computer graphivs project
41/64
}
void main()
-
7/29/2019 computer graphivs project
42/64
{int
gd=DETECT,g
m;
int i,j,k,t,q,r;
float x,y;
-
7/29/2019 computer graphivs project
43/64
initgraph(&gd,&gm,"d:\\tc
\\bgi");
setcolor(2);
-
7/29/2019 computer graphivs project
44/64
rectangle(0,0,getmaxx(),get
maxy());
for(i=0;i
-
7/29/2019 computer graphivs project
45/64
{line(i,250,i+60
,170);
line(i+60,170,i
+120,250);
}
-
7/29/2019 computer graphivs project
46/64
t=10;
line(0,400,get
maxx(),350);
B:line(50+t,28
0,50+t,320);
-
7/29/2019 computer graphivs project
47/64
line(50+t,320,60+t,320);
line(60+t,320,
70+t,320);
line(70+t,320,80+t,320);
-
7/29/2019 computer graphivs project
48/64
line(130+t,320,80+t,320);
line(70+t,320,
70+t,300);
line(60+t,300,60+t,320);
-
7/29/2019 computer graphivs project
49/64
line(70+t,300,60+t,300);
line(80+t,320,
80+t,280);
line(130+t,320,130+t,280);
-
7/29/2019 computer graphivs project
50/64
line(80+t,280,130+t,280);
line(50+t,280,
80+t,280);
line(50+t,280,65+t,260);
-
7/29/2019 computer graphivs project
51/64
line(65+t,260,80+t,280);
line(65+t,260,
110+t,260);
line(130+t,280,110+t,260);
-
7/29/2019 computer graphivs project
52/64
setfillstyle(SOLID_FILL,DAR
KGRAY);
floodfill(51+t,
282,2);
-
7/29/2019 computer graphivs project
53/64
setfillstyle(SOLID_FILL,RED);
floodfill(61+t,
302,2);
-
7/29/2019 computer graphivs project
54/64
setfillstyle(SOLID_FILL,YELL
OW);
floodfill(81+t,
282,2);
-
7/29/2019 computer graphivs project
55/64
setfillstyle(SOLID_FILL,MAG
ENTA);
floodfill(66+t,
270,2);
-
7/29/2019 computer graphivs project
56/64
setfillstyle(4,BROWN);
floodfill(100+
t,270,2);
if(t==10)
{
-
7/29/2019 computer graphivs project
57/64
t=320;goto B;
}
tree(0,-10);
tree(100,-20);
tree(30,-100);
-
7/29/2019 computer graphivs project
58/64
tree(350,-60);tree(160,-50);
setfillstyle(SO
LID_FILL,12);
fillellipse(150,
80,35,35);
-
7/29/2019 computer graphivs project
59/64
setfillstyle(2,LIGHTBLUE);
floodfill(10,10,
2);
-
7/29/2019 computer graphivs project
60/64
setfillstyle(SOLID_FILL,CYA
N);
floodfill(1,get
maxy()-1,2);
-
7/29/2019 computer graphivs project
61/64
setfillstyle(SOLID_FILL,LIGH
TGREEN);
floodfill(49,27
0,2);
-
7/29/2019 computer graphivs project
62/64
for(i=36;i
-
7/29/2019 computer graphivs project
63/64
x=150+i*cos(((float)j*3.14)/
180);
y=80+i*sin(((f
loat)j*3.14)/180);
-
7/29/2019 computer graphivs project
64/64
putpixel(x,y,LIGHTRED);
}
getch();
}