100% found this document useful (2 votes)
768 views

CGR CH 1

1. The document summarizes the basics of computer graphics, including image and object representation, pixels and resolution, text and graphics modes, and the basic graphics pipeline. 2. Key concepts covered are that computer graphics represents objects as collections of pixels, and discusses text mode which divides the screen into character boxes versus graphics mode. 3. It also provides an overview of the basic graphics pipeline which involves representing real-world objects, projecting them onto a view plane from the viewpoint of a camera, and mapping the objects to a graphic device for display.

Uploaded by

Rupesh Patil
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
100% found this document useful (2 votes)
768 views

CGR CH 1

1. The document summarizes the basics of computer graphics, including image and object representation, pixels and resolution, text and graphics modes, and the basic graphics pipeline. 2. Key concepts covered are that computer graphics represents objects as collections of pixels, and discusses text mode which divides the screen into character boxes versus graphics mode. 3. It also provides an overview of the basic graphics pipeline which involves representing real-world objects, projecting them onto a view plane from the viewpoint of a camera, and mapping the objects to a graphic device for display.

Uploaded by

Rupesh Patil
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/ 22

Second Year Diploma Courses in Computer Science & Engineering

/Computer Engineering/Computer Technology/Information


Technology Branch.

Computer Graphics
As per MSBTE ‘I’ Scheme Syllabus
CGR-22318

Unit-I
Basics of Computer Graphics
Total Marks- 08

Contents:

1.1 Image and Objects, pixel and resolution, Text mode. Graphics mode. Basic Graphics
Pipeline, Bitmap and vector based Graphics, Application of Computer Graphics.
1.2 Display Devices: Raster scan Display, random scan display, Flat Panel Display, LED,
LCD Display, Plasma, Touch screen.
1.3 Output primitives: line, polygon, marker, text.
1.4 Graphics functions and standards
1.5 Latest trends in Computer Graphics: Virtual reality, Augmented reality.

Prof. Gunwant V. Mankar


B.E(IT), M.Tech(CSE), AMIE, MIAEng, MSCI
Assistant Professor,
(Ballarpur Institute of Technology,Ballarpur.)
e-mail:- [email protected]
Website:- www.gunwantmankar.com
Unit-I Basics of Computer Graphics

Unit-I Basics of Computer Graphics

1. Introduction to Computer Graphics

 Computer graphics displays information in the form of graphics objects as windows,


graphs, diagrams etc. Thus, computer graphics express data in pictorial form.
 In computer graphics objects are represented as collection of pixels, where pixel is
smallest addressable point which can be displayed on screen. Pixel can be displayed on
screen by setting its intensity and color.
 A broad classification of major subfields in computer graphics might be:
1. Geometry: Studies ways to represent and process surfaces.
2. Animation: Studies with ways to represent and manipulate motion.
3. Rendering: Studies algorithms to reproduce light transport.
4. Imaging: Studies image acquisition or image editing.

2. Image and Object


 An image is basically representation of a real world object on a computer. It can be an
actual picture display, a stored page in a video memory, or a source code generated by a
program.
 Mathematically, an image is a two dimensional array of data with intensity or a color
value at each element of the array. In simple term, an image is defined by pixels.
 Object are real world entities defined in three dimensional world co-ordinates.

3. Pixel and Resolution


3.1. Pixel
 Pixel stands for picture element. A pixel is the smallest piece of information in an
image.
 In computer graphics objects are represented as collection of pixels, where pixel is
smallest addressable point which can be displayed on screen.
 Pixel can be displayed on screen by setting its intensity and color.
3.2. Resolution
 It is expressed in terms of the number of pixels on the horizontal axis and the number
on the vertical axis.
 In pixel resolution, the term resolution refers to the total no. of count of pixels in an
digital image.

CGR-22318 www.gunwantmankar.com Page 2


Unit-I Basics of Computer Graphics

 For example, if an has M rows and N columns, then its resolution can be defined as
M X N.

4. Text mode and Graphics Mode


 There are basically two types of graphics modes namely, Text mode, and Graphics
mode.
 There are different graphics functions available in these two modes useful for
drawing different effective texts and different types of geometric shapes.

4.1. Text Mode


 In text mode, a display screen is divided into rows and columns of boxes. Each can
contain one character. Text mode is also called character mode.
 All video standards support a text mode that divides the screen into 25 rows and 80
columns.
 Text mode is also known as Character mode or Alphanumeric mode.

4.1.1. Text mode graphics function


1) Window( ):- This function specifies a window on screen. The four integer co-
ordinates of the window are passed as parameters to this function.
Syntax- window(left, top, right, bottom);
2) putch( ): It displays a single character at cursor position.
Syntax – putch( char);
Example- putch(‘A’);
Displays character A at specified cursor position.
3) clrscr( ): It clears the entire screen and locates the cursor in top left corner of
screen i.e(1,1).
Syntax – clrscr( );
4) gotoxy( ): It positions the cursor to the specified location on screen, where location
is specified by x, y co-ordinates of the point.
Syntax – gotoxy(x, y);
Where x, y are co-ordinates of a point where cursor is to be positioned.
Example: gotoxy(3, 4);
It positions cursor to 3rd row, 4th column.

CGR-22318 www.gunwantmankar.com Page 3


Unit-I Basics of Computer Graphics

5) puts( ): It display string at cursor position.


Syntax – puts(s1);
Where, s1 is string to be displayed at specified cursor position. For puts( ) and
putch( ) functions, gotoxy( ) can be used.
Example: gotoxy(3, 4);
puts(“Hello”);
gotoxy(10,10);
putch(‘A’)
Here, Hello is displayed starting from the position 3,4 and ‘A’ is displayed at 10,10.
6) textcolor( ): It sets the colour for the text. Any text displayed after this command
will be displayed in a colour specified by this command. The supported colours are
numbered from 0 to 15.
Colour constant Colour name
0 BLACK
1 BLUE
2 GREEN
3 CYAN
4 RED
5 MAGENTA
6 BROWN
7 LIGHT GRAY
8 DARK GRAY
9 LIGHT BLUE
10 LIGHT GREEN
11 LIGHT CYAN
12 LIGHT RED
13 LIGHT MAGNETA
14 YELLOW
15 WHITE
128 BLINK

Syntax: textcolor (color);


Example: textcolor(‘GREEN’);
Is equivalent to
int col= 2;
textcolor(col);
Above both codes displays subsequent texts in green colour.
7) deline( ): It delets a line specified by cursor position. After deletion, all subsequent
lines will be pushed up by one line.
Syntax: deline( );

CGR-22318 www.gunwantmankar.com Page 4


Unit-I Basics of Computer Graphics

Example: gotoxy(8, 4);


delline( );
Above statement delets 8th line.
8) inline( ): It inserts a blank line at current cursor position.
Syntax: inline( );
Example : gotoxy(8, 4);
inline( );
It inserts a line at 8th row.
9) textbackgroud( ): It changes background colour of text. The valid colour for
CGA(Color Graphics Adapter) are from 0 to 6. They are:
Constant Colour Name
0 BLACK
1 BLUE
2 GREEN
3 CYAN
4 RED
5 MAGENTA
6 BROWN

Syntax: textbackground(color);
Example : int col = 4
textbackground(col);
It sets text’s background colour to red
10) moveto( ): It moves cursor to the location specified by int(x, y) co- ordinates.
Syntax: moveto(x, y);
11) outtextxy( ): (“sentence”)
OR
Outtextxy(x, y, “sentence”)
Where, x, y gives co-ordinates of a point where from to display text.
It displays text within quotation mark at specified position and with latest setcolour
style.

5. Basic Graphics Pipeline.


The fig.1. shown illustrate a 3D graphic pipeline.

CGR-22318 www.gunwantmankar.com Page 5


Unit-I Basics of Computer Graphics

Fig1. 3D graphic pipeline

 The real world objects are represented in world co-ordinates system. It is then
projected onto a view plane. The projection is done from the viewpoint of the
position of a camera or eye.
 There is an associated camera co-ordinate system whose z axis specifies the view
direction when viewed from the viewpoint.
 The infinite volume swept by the rays emerging from the viewpoint and passing
through the window is called as view volume or view pyramid. Clipping planes
(near and far) are used to limit the output of the object.
 The mapping of an object to a graphic device requires the transformation of view
plane co- ordinates to physical device co –ordinates.
 There are two steps involved in this process
o Step 1:- The window to a viewpoint transformation. The viewport is
basically a sub- rectangle of a fixed rectangle known as logical screen.
o Step 2:- The transformation of logical screen co- ordinates to physical
device co –ordinates.

CGR-22318 www.gunwantmankar.com Page 6


Unit-I Basics of Computer Graphics

Transform into Clip against Project to view Transform to


camera view volume plane viewport
co -ordinates

Representation Transform to
of 3D world physical device
objects coordinates

Fig1.1 Sequence of transformation in viewing pipeline.

Representation Clip against Transform to Transform to


of 3D world physical device
window viewport
objects coordinates

Fig1.2. 2D co ordinate system to physical device co ordinates transformation

6. Bitmap and vector based Graphics


 Computer graphics can be classified into two categories namely, Raster or
Bitmap graphics and vector graphics.
6.1.Bitmap Graphics(Raster Graphics):
 It is pixel based graphics.
 Bitmap images (also known as raster images) are made up of pixels in a grid.
Pixels are picture elements (tiny squares of individual color that make up what
you see on your screen.). All these tiny square of color come together to form
the images you see.
 Bitmap images are resolution dependent.
6.2.Vector based Graphics(Vector Graphics):
 The images in vector Graphics are basically mathematically based images.
Unlike bitmaps, vector images are not based on pixel patterns, but instead use
mathematical formulas to draw lines and curves that can be combined to
create an image.
 Vector based images have smooth edges and therefore used to create curves
and shapes. Vector images are edited by manipulating the lines and curves
that make up the image using a program.

CGR-22318 www.gunwantmankar.com Page 7


Unit-I Basics of Computer Graphics

7. Applications of computer graphics


 Now a days computer Graphics is used in variety of field ranging from daily
routing activities to very high end specialized areas.
 Some of major applications of computer graphics are listed below
1. Computer Aided Design/ Drafting(CAD/CADD)
2. Geographical information system(GIS).
3. Desktop publishing(DTP)
4. Graphical User Interface(GUI)
5. Digital Art.
6. Entertainment.
7. Image Processing
8. Education and training
9. Presentation Graphics, Scientific and Engineering Graphics
10. Medical applications.
11. Communication.
12. Simulation

8. Display devices:
 Display device is a device used for presentation of information such as image or text
for visual purpose. i.e to display information.
8.1. Raster Scan Display:
 In a raster scan system, the electron beam is swept across the screen, one row at a
time from top to bottom. As the electron beam moves across each row, the beam
intensity is turned on and off to create a pattern of illuminated spots.

 Picture definition is stored in memory area called the Refresh Buffer or Frame
Buffer. This memory area holds the set of intensity values for all the screen points.
Stored intensity values are then retrieved from the refresh buffer and “painted” on the
screen one row (scan line) at a time as shown in the following illustration.

 Each screen point is referred to as a pixel (picture element) or pel. At the end of
each scan line, the electron beam returns to the left side of the screen to begin
displaying the next scan line.

CGR-22318 www.gunwantmankar.com Page 8


Unit-I Basics of Computer Graphics

8.2. Random Scan (Vector Scan)


 In this technique, the electron beam is directed only to the part of the screen where
the picture is to be drawn rather than scanning from left to right and top to bottom
as in raster scan. It is also called vector display, stroke-writing
display, or calligraphic display.
 Picture definition is stored as a set of line-drawing commands in an area of
memory referred to as the refresh display file. To display a specified picture, the
system cycles through the set of commands in the display file, drawing each
component line in turn. After all the line-drawing commands are processed, the
system cycles back to the first line command in the list.
 Random-scan displays are designed to draw all the component lines of a picture 30
to 60 times each second.

8.3. Flat panel display:


 The term flat panel display refers to a class of video device that have reduced volume,
weight and power requirement as compared to CRT.
 Flat panel display devices are very thinner than CRT. These display devices have low
volume, weight and power requirement as compared to CRT. The many variants of
flat panel displays determine the resolution and quality of picture.
 The main two types of flat panel display are Emissive display and Non- Emissive
Display.
1. Emissive Display: These devices convert electrical energy into light. For example,
Devices – PLASMA PANELS, LIGHT EMITTING DIODES (LED) etc.
2. Non- Emissive Display: They use optical effects to convert sunlight or light from
some other source into graphics patterns. For example, Liquid Crystal Device (LCD)
and Laser Scan Display.

CGR-22318 www.gunwantmankar.com Page 9


Unit-I Basics of Computer Graphics

8.4. Plasma Panels


 Plasma panels also referred as gas-discharge display.
 It consist of two sheets of glass with thin and closed spaced gold electrodes attached to inner
faces and covered with dielectric material.
 These are attached as series of vertical conductors on other glass plate. The space between
two glass plate, is filled with neon based gas and is sealed.
 By applying voltage between electrodes the gas within panel is divided into tiny cells and
each cell is independent of its neighbours.

8.5. Light emitting diodes


 LED is a semiconductor that illuminates when an electrical charge passes through it.
 In this display a matrix of multi-color light emitting diode is arranged to form the pixel
position in the display. And the picture definition is stored in refresh buffer.
 Similar to scan line refreshing of CRT information is read from the refresh buffer and
converted to voltage levels that are applied to the diodes to produce the light pattern on
the display.
 A light emitting diode is made up of a semiconductor chip which is surrounded by a
transparent plastic case. The plastic case allows the light to pass though it.
 The emission of different colors including ultraviolet and infrared light depends on the
semiconductor material which is used in the diode.
8.5.1. Advantages of LED
1. Low power consumption.
2. Better and sharper screen resolution.
8.5.2. Disadvantages of LED
1. High price.

8.6. LCD Display


 LCD is a flat panel display, electronic visual display, or video display that uses
the light modulating properties of liquid crystals.
 This display use nematic (thread like) liquid crystal compounds that tend to
keep the long axes of rod shaped molecules aligned. These nematic compounds
have crystalline arrangement of molecules, yet they flow like a liquid and
hence termed as Liquid Crystal Display.

CGR-22318 www.gunwantmankar.com Page 10


Unit-I Basics of Computer Graphics

Fig- LCD Display


 The LCD shows three types of mesophase i.e, Smectic , Nematic (thread like) and
Cholestric. In Mematic phase, the long axis of liquid crystal molecules align parallel to
each other. The alignment direction is sensitive to temperature, surface tension, pressure
and electric and magnetic fields. The optical characteristics of Liquid crystal are also
sensitive to these effects.
 There are two types of LCD displays namely Active Matrix LCD and Passive Marix
LCD.

8.6.1. Advantages of LCD


1. Light weight
2. Small size
3. The consumption of power is low
4. Low cost.
8.6.2. Disadvantages of LCD
1. Low reliability
2. Speed is slow

8.7. Touch Screen


 It is an input technology. A touch screen is a computer display screen that is
sensitive to human touch. A touch screen is a display device that allows the
user to interact with a computer by using their finger.
 Touch screens are used on a variety of devices such as computer and laptop
monitors, smartphones, tablets etc.

CGR-22318 www.gunwantmankar.com Page 11


Unit-I Basics of Computer Graphics

 A touch screen may contain pictures or words that the user can touch to interact
with the device.
 A touch has two main advantages
1. It allows users to interact directly with what is displayed.
2. It does not require the use of an intermediate device.
The three main technologies are explained below:
8.7.1. Resistive:
 This screen has a thin metallic layer that is conductive and resistive, so that
touching results in a change in the electrical current sent to the controller.
8.7.2. Surface Acoustic Wave(SAW)
 Ultrasonic waves pass over this screen. Touching it results in absorption of part of the
wave, registering the position of the touch, which is sent to the controller.
8.7.3. Capacitive
 This screen is coated with an electrically charged material. Touching it causes a
change in capacitance, which allows the location to be determined and sent to
the controller.’

9. Output Primitives
 Graphics primitives are the functions that we use to draw actual lines and the
characters that make up the picture. These functions provide convenient
method to application programmer for describing pictures.
9.1. Point: Plots a single pixel on screen.
Attributes: x, y, co-ordinate position, color.

For example, consider following command


Putpixel(x, y, color); It displays pixel at x,y, co-ordinate position in given color.
9.2. Line: It draws a straight line.
Attributes: Line type, width, color, cap etc.

For example, consider following command.


lineto(x, y): It draws a straight line from current beam position to the point(x, y).
Line( x1,y1, x2,y2): It draws a straight line form (x1, y1) co –ordinate position to (x2,
y2) position.
setlineType(parameter);
setLineWidth(parameter);
setLineColor(parameter);
9.3.Text: Draws a string of characters.

CGR-22318 www.gunwantmankar.com Page 12


Unit-I Basics of Computer Graphics

Attributes: font, color, siz, spacing, orientation, height, width.


Font example,
 Type (Helvetica, times, courier etc.)
 Size (10pt, 14 pt, etc)
 Style (bold, italic, underlined)
For example, consider following command:
TEXT(X, Y, STRING)
Where (X, Y) is the text position and STRING is a string of characters.
setTextFont(parameter);
setTextColor(parameter);
9.4.Polygons:
 A set of line segments joined end to end. Some graphics device supports
polygon drawing approach, where directly basic polygon shapes are drawn. So
here one polygon is saved as one unit.
 Standards command for drawing triangle (polygon) could be,
Triangle (x1, y1, x2, y2, x3, y3 )
Where,
(x1,y1), (x2,y2) and (x3, y3) are co ordinates of three vertices of triangle and
thus supports, direct polygon drawing commands.
Consider the following command:
drawpoly(x[ ], y[ ], n);
where, x[ ] is array of x co-ordinate of all line segment end points, y[ ] is array
of y co-ordinates of all line segment end points. N is number of corners of
polygon +1.
9.5.Marker:
 It draws a specified symbol at given co-ordinated position in different color
and different sizes. We can select a particular character to be a marker symbol.
Attributes: marker type, size color etc.

For example, consider following command:


drawmarker(x[ ], y[ ], n); which is as drawpoly. Instead of drawing a polygon it
will draw symbols on polygon edges.
setPolymarkerSize( );
setPolymarkerType( );
for example,
setPolymarkerType(‘*’); It will draw * symbol all round polygon edges.

CGR-22318 www.gunwantmankar.com Page 13


Unit-I Basics of Computer Graphics

10. Graphics Functions and Standards.


10.1. Graphics mode and Graphics mode function
 Graphics mode is a computer display mode that displays image using pixels.
 In graphics mode, the display screen is treated as an array of pixels. Programs
that run in graphics mode can display an unlimited variety of shapes and fonts.
10.1.1. Basic Graphics Mode functions:
1. initgraph( ): It is used to initialise graphics mode.
Syntax: initgraph( int driver, int mode, char path);
Where,
 driver: This argument specifies the graphics driver to be used and it
interfaces with display adapter, some of available drivers are CGA, EGA,
VGA etc.
 mode: Each graphic adapter can use several different possible graphics
modes. The mode argument is used to select particular mode. Following table
shows different possible modes for CGA, VGA, EGA etc.
Note:- CGA- Computer Graphics Adapter
VGA- Video Graphics Adapter
EGA- Enhanced Graphics Adapter
 path: It specifies path to graphics driver. Graphics drivers are files with
BGI(Borland Graphics Adapter) file extension supplies as part of Turbo C++.
The path name is string therefore it must be surrounded by quotes.
Example: initgraph(&gd, &gm, “c:\\tc\\bgi”);
int gm, gd= DETECT

Where, gd- specifies graphics driver


gm- specifies graphics driver
“c:\\tc\\bgi”- specifies paths of BGI files.
DETECT- is micro which automatically selects the driver.
2. closegraph( ):
It is used to close graphics mode.
Syntax: closegraph( );

CGR-22318 www.gunwantmankar.com Page 14


Unit-I Basics of Computer Graphics

10.1.2. Graphics Mode functions for Shape


 Computer graphics has many inbuilt commands, which can be used either to
draw a shape and /or for filling a colour in any bounded shape.
1. lineto( ): This command draws a line on screen from current cursor positions to
the(x, y) positions mentioned in command.
Syntax- lineto(x, y);
Where, (x, y) are co-ordinates of end of line.
2. line( ): This command draws a line on screen.
Syntax: line(x1, y1, x2, y2);
Where, (x1, y1) are co-ordinates of starting point of line and (x2, y2) are co-
ordinates of end point of line.
Example :- line(10, 10, 100, 100);
It will draw a line from point (10, 10) to point (100, 100).
3. circle( ): This command draws a circle on screen.
Syntax: circle(x, y, r);
Where, (x, y) are co- ordinates of centre of circle and r is radius of circle.
Example :- circle (50, 50, 10);
It draws a circle with centre 50, 50 and radius 10.
4. rectangle( ): This command draws a line on screen.
Syntax: rectangle(x1, y1, x2, y2);
Where, (x1, y1) are co-ordinates of top left corner point of rectangle and (x2, y2)
are co-ordinates of bottom right corner point of rectangle.
Example :- rectangle(10, 10, 100, 100);
It will draw a rectangle as a top left corner is(10,10) & bottom right corner
is(100,100).
5. ellipse( ): It draws an ellipse on screen.
Syntax: ellipse(x, y, start, end , xrad, yrad);
Where,
x, y are co ordinates of centre point.
start, end- starting and ending angle of ellipse.
xrad, yrad: x- axis and y-axis radius respectively.
For full ellipse, the start and end should be 0 to 360 else it will draw an arc on
screen.
Example :- ellipse(100, 100, 0, 360, 20, 10);
CGR-22318 www.gunwantmankar.com Page 15
Unit-I Basics of Computer Graphics

6. drawpoly( ): It draws outline of polygon having specified number of sides.


Syntax: drawpoly(n, array);
Where,
n is number of vertices of a polygon +1.
Array is integer array name which stores co- ordinates of vertices of a polygon.
Example: To draw a triangle with drawpoly.
drawpoly(4, m);
where,
m is array which stores co –ordinates of vertices of a triangle.

10.2. Need for Standards


 A good computer graphics system includes good software, as well as, a
compatible hardware.
 Both computer graphics vendors as well as users indentified some needs to
have some graphics standards.
 The needs are as follows
1. Software portability.
2. Image data portability.
3. Text data portability.
4. Model database portability.
10.3. Standards for Computer Graphics
1. CORE (Core of a Graphics System)
2. GKS (Graphics kernel system)
3. IGES(Initial Graphics Exchange Specifications)
4. PHIGS(Programmer’s Hierarchical Interactive Graphics System)
5. CGM(Computer Graphics Metafile)
6. CGI(Computer Graphics Interface)

11. Latest trends in Computer Graphics:


11.1. Virtual Reality
 Virtual reality means experience things though our computers that don’t
really exist. Virtual Reality (VR) literally makes it possible to experience
anything, anywhere , anytime. It is the most immersive type of reality

CGR-22318 www.gunwantmankar.com Page 16


Unit-I Basics of Computer Graphics

technology and can convince the human brain that it is somewhere it is


really not.
 VR is able to immerse you in a computer generated world of your own
making: a room , a city the interior of human body.
11.1.1. Components of Virtual Reality System
1. Virtual world:- A virtual world is a three-dimensional environment that
is often, but not necessarily, realized through a medium where on can
interact with others. Two common types of immersion include.
a. Mental immersion- A deep mental state of engagement, with
suspension of disbelief that one is in a virtual environment.
b. Physical immersion: Exhibited physical engagement in a virtual
environment, with suspension of disbelief that one is in a virtual
environment.
2. Virtual Reality Engine:- It is the main component of any VR system
and it consists of simulation engine and graphics engine.
a. Scene Database-
b. Graphic Engine-
c. Simulation Engine
d. User Interface(UI)
3. Interactive
4. Sensory feedback

11.1.2. Types of Virtual Reality


 There are more than one approach to building virtual worlds and thus more
than one flavour of virtual reality.
1. Non- immersive- These simulations are the least immersion
implementation of virtual reality technology.
For example, an architect might build a detailed 3D model of a new
building to show to clients that can be explored on a desktop computer by
moving a mouse.
2. Fully –immersive simulations – provides the most immersive
implementation of virtual reality technology.
3. Semi immersive- These simulations provide a more immersive
experience, in which the user is partly but not fully immersed ina virtual
envoirnment.
CGR-22318 www.gunwantmankar.com Page 17
Unit-I Basics of Computer Graphics

11.1.3. Devices used in virtual Reality System.


1. Console / Smartphone/Computer.
2. Head mounted display
3. Input devices
o Joysticks.
o Force balls/ tracking balls.
o Controller wands
o Data gloves
o Trackpads
o On- device control buttons
o Motion trackers/ bodysuits
o Treadmills
o Motion platforms
11.1.4. Applications
o Education
o Entertainment
o Industrial design and architecture
o Scientific visualization
o Medical field

11.2. Augmented Reality


 Mixed Reality(Augmented Reality):
o The seamless merging of real space and virtual space.
o Integrate the computer generated virtual objects into the physical
world which become in a sense an equal part of our natural
environment.
 An AR system combined the real and the virtual in order to assist the user
in perform his task. So we can say that, an augmented(mixed) reality is a
halfway point between a non-immersive and fully immersive CR system.
 Mobile devices like smartphones and tablets have put supercomputer
power in our hands and pockets. If we are wondering round the world,
maybe visiting a heritage site like the pyramids or a fascinating foreign
city we have never been to before, what we want is typically not virtual
reality but an enhanced experience of the exciting reality we can see in
front of us. That’s the idea of Augmented Reality(AR).
CGR-22318 www.gunwantmankar.com Page 18
Unit-I Basics of Computer Graphics

11.2.1. Types of Augmented Reality (Category)


1. Marker based.
2. Markerless
3. Projection based
4. Superimposition based

12. Graphics Basic Programs


12.1. C program to draw circle built-in graphics commands.
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
int x, y, radius=80;
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
/* Initialize center of circle with center of screen */
x = getmaxx( ) / 2;
y= getmaxy( ) / 2;
outtextxy(x-100, 50, “Circle using Graphics in C”);
/*Draw circle on screen*/
circle(x, y, radius);
getch( );
closegraph( );
return 0;
};
Output:-
Circle Using Graphics in C

CGR-22318 www.gunwantmankar.com Page 19


Unit-I Basics of Computer Graphics

12.2. Simple program to draw circle.


#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
circle(25, 25, 100);
getch( );
closegraph( );
return 0;
}

12.3. C program to draw rectangle and a line.


#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
/* Draw rectangle on screen */
rectangle(150, 50, 400, 150);
/* Draw line on screen */
Line(500, 150, 600, 250);
getch( );
closegraph( );
return 0;
}

Output-

CGR-22318 www.gunwantmankar.com Page 20


Unit-I Basics of Computer Graphics

12.4. Program to draw polygon.

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
int points[ ]= {320, 150, 420, 300, 250, 300, 320, 150 };
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
drawpoly(4, points);
getch( );
closegraph( );
return 0;
}
Output -

CGR-22318 www.gunwantmankar.com Page 21


Unit-I Basics of Computer Graphics

12.5. C program to draw a circle and fill it by color and pattern.

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
circle(100, 100, 50);
setfillstyle(HATCH_FILL, RED); // set fill pattern and color
floodfill(100, 100, RED); // 100, 100 is just a point inside circle
getch( );
closegraph( );
}

Output-

End of Chapter No.1....

CGR-22318 www.gunwantmankar.com Page 22

You might also like