100% found this document useful (1 vote)
418 views

CG PDF

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 (1 vote)
418 views

CG PDF

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/ 63

Computer Graphics Vidyavahini First Grade college, Tumkur

VIDYAVAHINIFIRSTGRADECOLLEGE

COMPUTER GRAPHICS
6th Sem BCA

Vidyavahini First Grade College


Near Puttanjaneya Temple, Kuvempunagar, Tumkur – 572103.

E-Mail:[email protected]
Website:www.vidyavahini.org/bca

Contact No: 0816 – 2261130

Department of BCA Page 1


Computer Graphics Vidyavahini First Grade college, Tumkur

ntroduction to Graphics
Chapter 1
Computer graphics is a picture that is generated by a computer; it converts a scene to an image or
the process of transformations, shading, and animation of the image.

History of Computer Graphics:

• In the 1950‟s the first computer driven display was used to generate simple pictures, this
display used Cathode Ray Tube(CRT).

• Then “Ben Laposky” created the first graphic images generated by an electronic machine.

• In the 1960‟s beginning of modern interactive graphics and vector graphics .One of the
problem was cost and inaccessibility of machines.

• In the early 1970‟s output started using raster displays.

• In the 1980‟s output are built in raster graphics, bitmap image and pixel. Pc costs decrease
drastically.

• In 1990‟s , since the introduction of VGA[Video Graphics Array] and SVGA[Super Video
Graphics Array], pc could easily display the images and movies. 3D image become the main
advances and it helps in cinematic Graphics applications.

Applications of Computer Graphics:


1. Computer Aided Design (CAD).
2. Presentation Graphics.
3. Computer art
4. Entertainment
5. Educational and Training
6. Information visualization
7. Image processing

8. Information Graphics

Department of BCA Page 2


Computer Graphics Vidyavahini First Grade college, Tumkur

9. Virtual Reality.

Computer Aided Design (CAD): it is a type of computer based tool used for drafting and
designing. CAD is useful in various designing fields such as architecture, mechanical and
electrical, automobiles, aircrafts, spacecrafts, textiles etc.

Presentation Graphics: it is used to produce bar charts, pie charts, line graphs, surface
graphs and other displays. Computer Graphics is applicable in financial, statistical,
mathematical, scientific data for research reports and other types of reports.

Computer Art:computer graphics methods are widely used in both fine art and commercial
art applications, artists use a variety of computer methods including special purpose hardware,
paint brush, animations, CAD etc.

Entertainment:computer Graphics methods are also used in making motion pictures, video games,
television shows, music videos etc.

Educational and Training: it is used in education and training. Computer generated models of
physical, financial and economic systems are often used, which helps trainee to understand the
operation of the system.

Ex: flight simulation, automobile driving simulators…

Information Visualization: visual representation and interaction techniques take advantage


of the human eyes broadband width pathway in to mind to allow users to see, explore and
understand large amount of information at once. Computer Graphics is increasingly applied as
a critical component in scientific research, digital libraries, data mining, financial data analysis
etc.

Image processing: it is a technique used to modify or interpret existing pictures. In image processing
methods we first digitize a photograph or other picture into an image file.

Department of BCA Page 3


Computer Graphics Vidyavahini First Grade college, Tumkur

Information Graphics: it is also called as info graphics are Graphics Visual representation of
information, data or knowledge, these Graphics presents complex information quickly and
clearly such as signs, maths, generalism, technical writing and education.

Virtual Reality: it is a term that applies to computer simulated environments that can simulate places
in the real world as well as in imaginary world.

Computer Graphics Classifications:


A computer Graphics can be categorized in to different variety of ways.
a) Types of objects (Dimensionality): the objects can be represented graphically two
dimensional or three dimensional type.

b) Type of Interaction: it determines the user control over the object and its image.
c) Role of Pictures: CAD application is used to drawing is just a representation of the object
being designed or analyzed.

d) Relationship b/w objects and their pictures: this category arises from the logical and
temporal relationship b\w objects and their pictures.

Graphics Software:
It is a program or collection of programs that enable a person to manipulate visual images on a
computer. Graphics software are classified into two types

a) General Graphics Programming Packages:it is used in high level programming


language. It uses a set of graphics functions to generate picture components like
straight lines, polygons, circles, rectangles etc. ex: c and Fortran.

b) Application Graphics Packages: it is designed for non programmers so that users


can generate and display without knowing how graphics operation works. Some
software‟s are photoshop, coraldraw, Microsoft paint, picasa etc.

Interactive Graphics Display:

Department of BCA Page 4


Computer Graphics Vidyavahini First Grade college, Tumkur

3) Television Monitor

00000000000000000000000
00000010000000000000000
10100000000000000001000 Display controller
00101010000000000000000
00000000000100101000000

Frame Buffer: the displayed image is stored as a matrix of intensity values (stores the
picture definition in terms of bytes).
It consists of 3 components
1) Frame Buffer or Digital memory
2) Display controller or video controller
Display Controller:a special purpose processor called display controller is used to control the
operation of the display device. It passes the contents of the frame buffer to the monitor. The
image must be passed repeatedly to the monitor 30 or more times a second to maintai n
constant picture on the screen.
Television Monitor:the Display controller reads the byte of data from the frame buffer and converts
its zero‟s and one‟s (0‟s & 1‟s) into corresponding video signal then the signal is transferred to the
TV monitor producing a black and white pattern on the screen.

Cathode Ray Tube [CRT]:


A cathode ray tube is a vacuum tube in which images are produced when an electron beam strikes
a phosphor coated surface.

Department of BCA Page 5


Computer Graphics Vidyavahini First Grade college, Tumkur

The electron gun generates a beam of electrons, which passes through focusing and deflection
system that direct the beam towards specified positions on the phosphor coated screen.
The phosphor emits a small spot of light at each position strikes by the electron beam.
Focusing system consists of two metal plates mounted perpendicular to the beam axis with holes
at their center through which the beam pass. It is maintained at high relating potential to
accelerate the beam to necessary velocity.Deflection system contains a set of coils mounted at the
neck of the tube. The horizontal deflection plates controls the vertical deflection and the vertical
deflection plates controls the horizontal deflection.

Phosphorus used in graphic display, the electric energy is converted to light when the electron
beam fall on the phosphor coated screen

Factors affecting CRT:


1. Resolution: the number of pixels or points per inch or centimeters, if the pixels are
more than the clarity and sharpness of the picture is high. The pixels size is smaller
than the resolution is higher. The higher quality resolution is 1280*1024.

2. Persistence: how long small spots continue to emit light after the beam is moved or
removed is called persistence. Lower persistence requires higher refresh rate

and it‟s good for animation. Higher persistence is useful for displaying complex static
picture.

3. Addressability: it is a measure of the spacing between the centers of vertical and


horizontal lines. The smallest addressable point on the screen is called pixel or
picture element.

4. Aspect ratio: ratio between vertical points and horizontal points necessary to
produce equal length lines in both directions on the screen.

Aspect ratio=3/4
Vertical line with 3 points is equal in length to horizontal line of 4 points(pixels)

Raster scan Display(Monitor)

Department of BCA Page 6


Computer Graphics Vidyavahini First Grade college, Tumkur

The electron beam is fall across the screen are row at a time from top to bottom. As the
electron beam moves across each row, the beam intensity is turned on and off depends on the
picture definition.

Picture definition is stored in a memory area called the frame buffer. This memory area holds
the set of int ensity values for all screen points. Stored intensity values are then retrieved from
the buffer and painted on the screen one row at a time. Each screen point is referred to as a pixel
(or) pel.
A bit value of 1 indicates that the electron beam is to be turned on at that position and a value
of 0 indicates that the beam intensity is to be off. Refreshing on raster scan display is carried
out at the rate of 60 to 80 frames/second. At the end of each scan line the electron beam returns
to the left side of the screen to begin displaying the next line. Returning to left screen after
refreshing each scan line is called horizontal retrace. Similarly when an electron beam returns to
the top left corner of the screen to begin next frame is called vertical retrace.

Advantages:

(i) Images can be displayed with realistic and includes 3D effects also.
(ii) The cost is very low compared to other devices.

(iii) Computers monitors and TV‟s use this method.

Department of BCA Page 7


Computer Graphics Vidyavahini First Grade college, Tumkur

Disadvantages:
(i) Resolution is low.
(ii) The lines produced are zigzag
(iii) High speed display application and animations cannot use this technique.

Random Scan Display

In Random scan display a CRT as the electron beam directed only to the parts of the screen
where a picture is to be drawn. It draws a picture one line at a time. Picture definition is now
stored as a set of the drawing commands in area of memory referred t o as the refresh display
(or) refresh buffer. After all line drawing commands have been processed the electron beam to
the first line command in the list. Random scan systems are designed for line drawing
applications and cannot display realistic images.

Advantages:

(i) High resolution.


(ii) Producing smooth line drawing.
(iii) Easy for animation.

Disadvantages:

Department of BCA Page 8


Computer Graphics Vidyavahini First Grade college, Tumkur

(i) Costlier (or) over cost.


(ii) Difficult to display realistic images.
(iii) This technique cannot be used to draw complex images.

Differences between Raster Scan and Random Scan Display


Raster Scan Random Scan

i) Less Resolution i) High Resolution


ii) Line Produced as zigzag ii) ducing smooth line drawing
Pro
iii) Cost is low iii) C ost is High.
iv) Image is displayed realistic iv) age is difficult displayed realistic
Im
v) Difficult in animation v) Easy in animation.

Color CRT Monitors:

CRT Monitors displayed color picture by using combination of phosphors that emit different coloured
light color RT monitors used two methods.

i) Beam – Penetration method.


ii) Shadow – mask method.

Beam – Penetration method:

Department of BCA Page 9


Computer Graphics Vidyavahini First Grade college, Tumkur

Random scan system technique is used in beam penetration method for displayed colour
pictures.There are 2 layers of phosphors one is green phosphor coated on to the inside of the
CRT Screen and other one is the Red phosphor coated behind the green phosphor.Thecolor
depends on the electron beam speed penetrates. A beam of slow electrons excites(strikes) only
the red layer to produce a red color. A beam of very fast electron penetrates through the red
layer and excites the green layer to produce green color.

An intermediate beam speed, a combination of red and green light to display two colors like Orange
and Yellow.

Disadvantages:

i) Only four colours are produced.


ii) Picture quality is not good. iii) Intensity of
beam is changed at different color.

Shadow-Maskmethod: it is commonly used in Raster Scan system like color T.V.

Department of BCA Page 10


Computer Graphics Vidyavahini First Grade college, Tumkur

Shadow – mask method produce a much wider range of colors than the beam penetration
method. A shadow-mask CRT has 3 electron – Gun produce 3 colors with the help of Red, Blue
and Green electron beam.

A Grid called a shadow– mask is just placed behind the phosphor coated screen. The 3 electron
beam are deflected and focussed as a group on to the shadow mask contains a series of holes
aligned with the phosphor dot pattern.

When the 3 electron beams pass through a hole in the shadow– mask, they activate a dot triangle
which appears as a small coloured dot on the screen. Different colours are displayed by varying
the intensity levels of the 3 electron beam. White produces when all three dots with equal
intensity. Yellow produced with green and red dots only. Magenta is produced with blue and
red dots. Cyan produced when blue and green are activated equally.

There are 2 types of display processor.

(i) Raster-Scan display processor.


(ii) Random-Scan Display Processor.

Raster-Scan Display Processor:Interactive Raster Graphic Systems typically has several


processing units. In addition to the CPU a video controller is used to control the operation of the
display devices.

Department of BCA Page 11


Computer Graphics Vidyavahini First Grade college, Tumkur

A major task of the display processor

• Digitising a picture definition.


• The functions generate various line styles, displaying color areas and performing transformations.

• Display processors are typically designed to interface with interactive input devices.
• Cartesian co-ordination is referred in frame buffer location and corresponding screen positions.

Department of BCA Page 12


Computer Graphics Vidyavahini First Grade college, Tumkur

(i) Random – Scan display processor:

• An application program is input and stored in the system memory along with a graphics packages.

• Graphics command in the application program is translated by the graphics package into a display
file stored in the system memory.

• This display file is then accessed by the display processor to refresh the screen.
• The display processor is referred as dis play processor unit (or) graphics controller which goes
through each command in the displayed file during every refresh cycle.

Instruction Set

The display processing unit (DPU) or Graphics controller has an instruction set and instruction
address regis ter, which goes through the classic instruction fetch, decode and execute cycle
found in any computer.

In order to provide a flicker free display the display processor must execute its program 30 to
60 times/sec.Graphic packages create a display program and tell the DPU where to start the
program. DPU then execute the display program until it is told to stop by graphics packages.
JUMP instruction at the end of display program transfers control back to its start, so that display
continues to start without CPU intervention.

Color Mapping

Department of BCA Page 13


Computer Graphics Vidyavahini First Grade college, Tumkur

A color model is an abstract mathematical model describing the way colors can be represented
as Tupiles of numbers, typically as 3 (or) is values (or) color components. A color model is a
specification of 3D coordinate system.

The different type of color models are

(i) RGB color model [Red, Green, Blue]


(ii) CMY color model [cyan, magenta, yellow].
(iii) YIQ [using RGB, removing the luminance in RGB and contact with ultraviolet (UV) and
producing different colours].

Questions:
1. What is staircase effect?(1M,DEC 2011)
2. Define the terms refresh rate and aspect ratio. (1M,DEC 2011)
3. Explain any five applications of computer graphics.(5M,DEC 2011)
4. Explain functioning of CRT with a neat diagram.(9M,DEC 2011)
5. Explain RGB and CMY color models.(5M,DEC 2011)
6. Explain the concept of interactive graphics.(3M,DEC 2011)
7. Explain application computer graphics in education and health care.(3M,DEC 2011)
8. Discuss the working of a Beam penetration CRT, with a neat diagram.(5M,DEC 2011)

Department of BCA Page 14


Computer Graphics Vidyavahini First Grade college, Tumkur

2 Chapter
Points and Lines
Point plotting techniques are based on Cartesian co-ordinate system where they are referred to
by their „x‟ and „y‟ co-ordinates.

Points are plotted in response to digital signals from the computer.

Line Drawing Algorithms: The criteria required to generate straight lines are (i)
Line should appear straight.
(ii) Line should terminate accurately.
(iii) Line should have constant density.
(iv) Line density should be independent of line length and angle. (v) Line should draw
rapidly.

The Cartesian slope intercept equation for a straight line is


Y= m x + B
Where m slope of the line
y is intercept.

The slope of the line „m‟ is


Y2-Y1 m =
X2– X1

b = Y1– mx1
The „Y‟ intercept „b‟ is

dy else
steps = dx

Department of BCA Page 15


Computer Graphics Vidyavahini First Grade college, Tumkur

For any given x interval x along a line, we compute corresponding line interval „

y‟

The two end points are represented as (x1, y1) & (x2, y2)

DDA Line Algorithm

DDA - “Digital Differential Analyser”.


The DDA generates lines from the differential Equations dy/dx= y/ x The
values of x and y are simultaneously incremented by small steps.

Algorithm
Step 1: Input two end points (x1, y1) & (x2, y2)
Step 2: Calculate the constants dx &dy

dx = |x1 – x2| dy = |y1 –


y2|
Step 3: Find the no. of steps to plot
if(dx<dy ) steps =
Step 4: Find the increment constant values

x1nc = dx | Steps
y1nc = dy | Steps
Step 5: (for loop) i = 1 up to steps
Plot pixel (x, y, RED)
x = x + xinc
y = y + yinc
End for
Write a program to construct a line using DDA Algorithm. # include<iostream.h>
# include<conio.h>

Department of BCA Page 16


Computer Graphics Vidyavahini First Grade college, Tumkur

# include<graphics.h>
Void main ( ) {
int x1, y1, x2, y2; Clrscr
()
Cout<<“enter first end point”; Cin>> x1>>
y1;
Cout<<“enter second end point”; Cin>> x2>>
y2;
initgraph (&gd, &gm “ ,C: \\ tc \\bg::”);
Clear device ( ); dda line (x1, y1, x2,
y2);
getch ( ); close
graph ( );
}
Void ddaline (int x1, y1,int x2, int y2)
{ int dx, dy, steps, i;
float x inc, y inc, x, y;
dx = abs (x1 – x2); dy
= abs (y1 – y2); if(dx
<dy)
Steps = dy;
else Steps =
dx;
Xinc = dx / steps; Yinc
= dy / steps; for
(i=1;i<= steps; i++)
{
Put pixel (x, y, RED);
X = x + xinc;
Y = y + yinc;
Put pixel (x, y, RED);
}
|| End of function.

Bresenhams Lien Algorithm


An accurate and efficient line generating algorithm developed by Bresenhams, Scan converts lines
using only incremental integer calculations 0<|M|<_1

Bresenhams algorithm is designed such that each interaction changes one of the coordinate values by
+ 1 (or) – 1.

Department of BCA Page 17


Computer Graphics Vidyavahini First Grade college, Tumkur

Defining the decision parameter as Po = 2dy – dx


The next value is evaluated depending on whether Po is Positive (or) Negative. If Po
<O the next point to plot is (Xk+1,Yk) otherwise plot (Xk+1,Yk+1)

Algorithm: let (x1, y1) (x2, y2) = (10, 10) (15, 15)

Step 1 : Input two end points (x1, y1) & (x2, y2)
Step 2 : calculate dx = |x1
– x2| dy = |y1 –
y2|
Step 3 : Starting decision Parameter
P= 2dy – dx.
Step 4 :if (x1< x2)
x= x1 Y= y1
Xend = x2
Else

X = X2
Y = Y2
Xend = X1

Step 5 :while(x<_xend)
Putpixel(x,y,RED)
if(p>0)
y++;
p=p+2(dy-dx)
else
p=p+2dy
x++
step 6: stop

Difference between DDA Line algorithm and Brensenhams line algorithm.

DDA Line Algorithm Bresenhams Line Algorithm

• X inc and Y inc are calculated The increment value of X and Y is always based on the formula.
Unity.

• There is no decision parameter used There is a decision parameter used.


• Both x and y values are incremented Depending on the decision parameter the at every
step. X and Y values are incremented.

Department of BCA Page 18


Computer Graphics Vidyavahini First Grade college, Tumkur

Circle Generations

DDA Circle Generation Algorithm

The differential equation of a circle with centre at Origin is dy/dx=-x/y

A circle is defined as the set of points that are all at a given distance „r‟ from a
centre position (Xc, Yc). (x-x c) 2+(y-yc)2=r2
The distance relationship is written as

The circular boundary using polar co-ordinates „r‟ and θ


Xnew=xc+rcos θ
Ynew=Yc+rsinθ

Algorithm for DDA Circle Generation:

Step1 : Input Xc, Yc and radius r.


Step 2 : for (theta = o to 360)
Xnew=xc+rcos θ
Ynew=Yc+rsinθ
Putpixel(x,y,red);
Step3:stop

Bresenham’s Circle Generating Algorithm.

Department of BCA Page 19


Computer Graphics Vidyavahini First Grade college, Tumkur

In Bresenhams algorithm, the decision parameter decides the closest point lying on the
circumference of the circle. For a given radius „r‟ and centre position (Xc, Yc). We calculate
pixel positions around the circle with the centre at a Origin.

Algorithm:
Step1: input Xc, Yc and radius r
Step 2: x=0; y=r; p=1-r;
While(x<y)
{
If(p<0)
P=p+2x+1
X++
Plotpoints(Xc,Yc,X,Y)
}
Step3:stop
Void plotpoints (intXc, intYc,intX,int Y)
{
Putpixel(Xc+X,Yc+Y,RED);
Putpixel(Xc-X,Yc+Y,RED);
Putpixel(Xc+X,Yc-Y,RED);
Putpixel(Xc-X,Yc-Y,RED);
Putpixel(Xc+Y,Yc+X,RED);
Putpixel(Xc-Y,Yc+X,RED);
Putpixel(Xc+Y,Yc-X ,RED);
Putpixel(Xc-Y,Yc-X RED);}
Ellipse Generating Equation (Algorithm (Bresenhams)

Department of BCA Page 20


Computer Graphics Vidyavahini First Grade college, Tumkur

An ellipse is defined as the set of points such that the sum of the distance from 2 fixed positions
is the same for all points. The ellipse has 2 access:
i) Major axis (rx) ii) Minor
axis (ry) Equation of elipse:
(x-xc/rx)2+(y-yc/ry)2=1
Where((xc.yc)=(0,0) Region
1:

We can start at position (O, ry) and step Clockwise along the elliptical path in the first quadrant.

Decision Parameter :p1=r2y-r2xry+1/4r2x

Region 2 :Alternatively we can start at (rx, o) and select points in a counter clockwise order.

Decision parameter :p2=r2y(x0+1/2)2+r2x(y0-1)2-r2xr2y

Line Attributes:
The attributes of a straight line segment are
i) Type ii) Width
iii)

Color (i)
Line
Type :
Solid Line ___________
Dotted line .......................
Dashed line -----------------
Dashed – dotted line -.-.-.-.-.-.-.-.-.-

Department of BCA Page 21


Computer Graphics Vidyavahini First Grade college, Tumkur

Lines can be generated by setting the length and spacing. Set the line type attribute
with the command “setlinetype (lt)”; where lt = 1, 2, 3, 4 having solid, dotted,
dashed, dashed-dotted resp.

(ii) Line Width:


Set the line width attribute with the command “setLinewidthScaleFactor (lw)”
Where lw = is a positive no. indicating the relative width of a line.
The value „1‟ specifies a standard width line and value>1 produce line thicker. We can adjust the
shape of the line ends to given than a better appearance by adding line caps. There
are 3 types of line caps.
(i) Butt Cap : End points of the line ends perpendicular to line path.

(ii) Round Cap : the arcs are centered on the end points of the line.

(iii) Square Cap : it extends the line and adds butt cap positioned half of line width beyond
the specified end points.

Line Color:
Set the line color attribute with the command set Polyline ColorIndex (lc) Where,
lc is a non-negative values to allow color choices. Eg: Set Line type
(2);
Set Line width Scale Factor (2);
Set Polyline Color Index (4);

Area Filling:

Department of BCA Page 22


Computer Graphics Vidyavahini First Grade college, Tumkur

The solid color filled (or) a pattern filled polygon is a standard o/p primitive of a graphics package.There
are 2 ways of area filling on rasters system.
(i) Using boundary definitions, identifying which pixels belongs to the interior of the area
specified.
(ii) Starting from a point inside the area and painting outwards until the boundary definition is
encounter.

Scanline algorithm for “area fill”


Scanline filling algorithm is used for filling polygon areas. This procedure contains the following
steps.

• For each scanline locate the intersection of the scanline with the edges.

• The intersection points are then stored from left to right.


• Generate frame buffer positions along the current scanline between each pair of intersections are
set to the specified fill color.

• When a scanline passes through a vertex, it intersects 2 polygon edges at that point and fills the
color.

Area filling attributes:


Fill an area with a solid color (or) a patterned fill and choices for the particular color and pattern.

Fill Styles:
There are 3 basic fill styles.
(i) Hallow with a color border.
(ii) Filled with a solid color.
(iii) Filled with specified pattern (or) design.

Department of BCA Page 23


Computer Graphics Vidyavahini First Grade college, Tumkur

The basic fill style command is,


setInterior Style (fs);
Where fs (fill style) include hallow, solid and pattern.
Another value for fill style is “Hatch”, which is used to fill an area will be selected hatching pattern parallel
lines (or) crossed lines.

Character Attributes (text attributes):


The appearance of characters depends on its attributes such as font style, color, size. Orientation, path and
spacing.

1. Font & Style:


The text can be set with a font (type phase) such as New York, Courier, Times New Roman,
Arial Black, etc.The character can be set with a font style such as underline, Bold face, italic
and shadow styles.

Font Options are available as set of Grip patterns (or) as character sets designed with
polyline curves.

2. Character Height : It is defined as the distance between the base line and cap line of characters.
Doubling the height also doubles the character width and height between the characters. Eg:
Heigh 1

Height2

Height3

Department of BCA Page 24


Computer Graphics Vidyavahini First Grade college, Tumkur

3. Character Width:The width of text can be set with the function “set Character Expansion Factor
(cw);” Where cw is a positive value.
The height dosenotchange by this attribute setting Eg:
width 1.0
W i d t h 2. 0
W i d t h 3.0
4. Character Spacing: The spacing between the characters can be changed with
“setCharacter Space (cs);”
Where cs can be assigned any real value.
Eg: spacing o.o
S p a c i n g o.5
S p a c i n g 1. 0
5. Orientation:The Orientation for a displayed character string is a set according to the direction of
the character up vector. “setCharacter Up Vector (upvect);” Where upvect having (x,y) values.
if x = 1 & y = 1 i.e., (1, 1), the text (or) string will be displayed in 45 angle.

To arrange character strings vertically (or) horizontally


set Text Path (tp); wheretp is right, left, up & dow n.

Quetions:

1. Explain attributes of line.(5M,DEC 2011)


2. Explain DDA line algorithm with an example.(5M,DEC 2011)
3. Explain scan-line algorithm for area filling.(5M,DEC 2011)
4. Write the Bresenham,s line drawing algorithm.(5M,DEC 2011)
5. What is an output primitive
6. What is point in computer graphics?
7. What is character up vector?
8. Explian the character attributes?
9. Explain area fill attributes?
10. Explain midpoint circle algorithm?

Department of BCA Page 25


Computer Graphics Vidyavahini First Grade college, Tumkur

2D TRANSFORMATION
Chapter 3
Creating an image is the first step of a Graphics system. The second step is to include variety of
transformations.

“Transformationis the ability to rearrange a picture so that its details appear more clearly and modifying
the picture.”

The basic Geometric transformations are

i) Translation. ii)
Scaling. iii)
Rotation.

(i) Translation: An object is re-positioning (moving) from one place to another place is known as
translation.

Department of BCA Page 26


Computer Graphics Vidyavahini First Grade college, Tumkur

A 2 – dimensional point can be translated by adding translation distances tx and ty to the original co-
ordinate position (x, y), after moved the object the new positions are (Xnew, Ynew).

The translation distance pair T(tx, ty) is called the translation vector (or) shift vector.

p Pnew

pnew= P+T

The matrix representation using 3*3 matrix

(ii) Scaling:It is the ability to change the size of an image (or) object each vertex of an object has the
scaling factor Sr and Sy to produce the transformed co-ordinates.

Department of BCA Page 27


Computer Graphics Vidyavahini First Grade college, Tumkur

p Pnew

Pnew= P*S

Xnew=x.Sx
Ynew=y.Sy

The matrix representation using 3*3 matrix

Any positive numeric value can be assigned to scaling value Sx&Sy value greater than one
produced enlarge object, value lesser than one decreases the size of the object and if Sx = 1 and
Sy = 1, the object size do not change Pnew = P.S.
(iii) Rotation: Rotation is the ability to repositioning an image along a circular path in the (x,
y) plan. By specifying the angle of rotation 𝜽 and the position (Xr, Yr) of the rotation point
which the object is to be rotated.

Using the standard trignometric equations

Xnew=rcos(𝜱 + 𝜽) Ynew=rsin(𝜱

+ 𝜽)

Department of BCA Page 28


Computer Graphics Vidyavahini First Grade college, Tumkur

Xnew= rcos 𝜱cos 𝜽-rsin 𝜱 sin 𝜽 Ynew=

rcos 𝜱sin 𝜽-rsin 𝜱cos 𝜽 Rotations are

rigid body transformations that move

object without deformation. Every point

on an object gets rotated through the same

angle.

The matrix representation using 3*3 matrix

Matrix Representations of 2 – D Transformations, Homogeneous Matrix Representation.

1. Translation
Pnew = P+T

2. Scaling
Pnew = P * S

Department of BCA Page 29


Computer Graphics Vidyavahini First Grade college, Tumkur

3. Rotation

Other Transformations

1. Shear.
2. Reflection.

1. Shear: The shape of an object can be distorted by sliding the internal layers of the original
object is known as shear. Two common shearing transformations are (i) Shift X values.

Xnew=X+ Shx.Y

Ynew = Y

Department of BCA Page 30


Computer Graphics Vidyavahini First Grade college, Tumkur

The matrix representation is

(ii) Shift Y values.

` Xnew=X

Ynew = Y+Shy.X
The matrix representation is

2. Reflection:

The mirror image of an object can be produced by the transformation of reflection.


Mirror image is generated relative to an axis of reflection by rotating the object 180 about the
reflection axis.

Reflection about the x – axis is given by the matrix,

The Reflection about y – axis is given by

Department of BCA Page 31


Computer Graphics Vidyavahini First Grade college, Tumkur

Reflection about the x – y plane perpendicular to the x-y plane.

Composite Transformations.
When a transformation is applied more than once on the particular object (or) image then we call
that as composite transformation.

(a) Translation

In order to apply two successive translations on an object, we can first perform the
concatenation of the translation matrices and then apply the composite matrix to the
coordinate points.

The general form is

T(tx1,ty1).T(tx2,ty2)=T(tx1+tx2,ty1+ty2)

(b) Scaling :
To apply 2 successive scaling to an object, the concatenation of scaling matrices is performed and
then the composite matrices is applied to the co-ordinates points.

Department of BCA Page 32


Computer Graphics Vidyavahini First Grade college, Tumkur

The general form is

S(Sx1,Sy1).S(Sx2,Sy2)=S(Sx1.Sx2,Sy1.Sy2)

(c) Rotation

To apply 2 rotations to an object, we can first perform the concatenation of rotation matrices and
then apply the composite matrices to the co-ordinate point

. =

Raster Method For Transformation:


Picture info is stored in Raster system as pixel patterns in the frame buffer. Some
transformation can be carried out by rapidly by moving rectangular arrays of stored pixel values
from one location to another within the frame buffer.

“Raster functions that manipulated rectangular pixel arrays are referred as raster operations,
moving a block of pixels from one location to another is also called as block transfer of pixel
values.”
Questions:
1. Give scaling factors to double the object size.(1M,DEC 2011)
2. Give matrix representation for reflection about X and Y axes. (1M,DEC 2011)
3. Explain 2 dimensional translations. (1M,DEC 2011)
4. Explain scaling transformation.(1M,DEC2011)
5. Give raster method for transformation. (5M,DEC 2011)
6. Explain the 2D composite transformation for scaling transformation.(5M,DEC2011)
7. Explain shear Transformation?
8. What do you mean by composite transformation? How it is useful?

Department of BCA Page 33


Computer Graphics Vidyavahini First Grade college, Tumkur

Chapter 4 Windowing
& Clipping
Normally graphical packages allow a user to specify what portion of the image is to be displayed
and where the image is to be displayed.

A convenient co -ordinate system which is used to define a reference frame of the picture forms the
world co-ordinates.

“A rectangular area specified in the world co-ordinates is called a Window”.

“A rectangular area of the display device, which will contain the picture to which a window is
mapped, is called a view port.”

Steps involved in 2 – Dimensional viewing transformation.

The commands to set the window and view port areas from an application program may be defined as
set of pre-defined function.

Department of BCA Page 34


Computer Graphics Vidyavahini First Grade college, Tumkur

Clipping

Whenever a window area is mapped onto a viewport, this results in the display of only
those parts of the picture within the window. All other portions of the picture which are outside
the window are discarded.

Clipping Operations

1. Extracting parts of a specified region for viewing.


2. Locating visible surfaces in 3 – D views.
3. Anti – aliasing line segments of objects.
4. Creating objects using solid modelling procedures.

Department of BCA Page 35


Computer Graphics Vidyavahini First Grade college, Tumkur

5. Display multiple windows.


6. Drawing and painting the parts of a picture object.

Clipping Steps Process:

Types of Clipping

1. Point Clipping.
2. Line Clipping.
3. Text Clipping.
4. Area Clipping.
5. Curve Clipping.

1. Point Clipping
Clipping of points is done by comparing each point with the boundary of the rectangle
window, i.e., point clipping against a window specification is done by testing the
coordinate values to determine whether they are within the boundaries (or) not.

2. Line Clipping:

The method of line clipping involves several parts

(i) Test whether the line segment lies completely inside the window.
(ii) Test whether the line segment lies completely outside the window.
(iii) If the line is neither completely inside nor outside the window, intersection calculations are
performed within the clipping boundaries.

Cohen – Sutherland Line Clipping Algorithm


This algorithm is invented by Dan Cohen and Ivan Sutherland, is very good for clipping picture that are
much larger than the screen.

Department of BCA Page 36


Computer Graphics Vidyavahini First Grade college, Tumkur

The algorithm are 2 parts.

(i) First determine whether the line lies entirely on the screen and if not whether it can be
rejected as lying entirely off the screen.
(ii) If it satisfies the 2 tests, then the line is divided into 2 parts and these 2 tests are applied
to each part.

The rejection test is done by extending the edges of the screen, so that they divide the space
occupied by the unclipped picture into 9 regions. Each of these regions has a 4 – bit code and
the 2 end – points of the line are assigned codes according to the regions.

Region codes
If the 4 – bit code for both end – points are zero then the line lies entirely on the screen. If the logical
intersection AND of the 2 codes is not zero then the line must lie off the screen.

If the line cannot be eliminated, it must be divided. This can be done by finding the point of intersection of
the line with one edge of the screen and discard the part that lies off the screen.

3. Text Clipping:
(a) String Clipping: If the complete string is inside the clip window boundary, then we it to a
viewport otherwise the string is discarded.

Department of BCA Page 37


Computer Graphics Vidyavahini First Grade college, Tumkur

(b) Character Clipping: Here we discard only those characters that are not completely
inside the window boundary.

(c) Components of Individual Character:if an individual character overlaps a window


boundary we discard the parts of the character that are outside the window.

4. Curve Clipping:

The bounding rectangle for the curved object is first tested for ovelap (or) intersection
with the rectangular window. If the bounding rectangle for the curve is completely within the window
then the object is saved otherwise discarded.

Blanking (or) Exterior Clipping

Department of BCA Page 38


Computer Graphics Vidyavahini First Grade college, Tumkur

If we want to clip a picture to the exterior specified region, i.e., all the parts outside the region
must be retained but within the window boundary region is discarded is known as blanking (or)
exterior clipping.

5. Area Clipping (or) Polygon Clipping.

Line clipping technique can also be applied to clip hallow polygons. Polygon clipping can
be done by clipping each component line using line clipping technique.

A technique for clipping polygons developed by Sutherland and Hodgeman.

Sutherland – Hodgeman Polygon Clipping Algorithm.

The Sutherland – Hodgeman algorithm is based on the fact it is easy to click a polygon against a single
clipping edge.

The algorithm operates on the vertices of polygon, when each pair of vertices is passed to a window
boundary clipper. There are 4 possible techniques,

1. Left Clipper.
2. Top Clipper.
3. Right Clipper.
4. Bottom Clipper.

First left clipping is applied to the polygon starting from the intersection point, the outside
window boundary is discarded and the inside the window boundary will be saved. This procedure is
applied to the top clipper, right clipper and bottom clipper.

Department of BCA Page 39


Computer Graphics Vidyavahini First Grade college, Tumkur

1. If the first vertex is outside the window boundary and the second vertex is inside the window
boundary, the intersection point of the polygon edge with the window boundary and the second
vertex is added to the output vertex list.
2. If both vertices is inside the window boundary, only the second vertex is added to the output vertex
list.
3. If the first vertex is inside the window boundary and the second vertex is outside, only the edge
intersection with the window is added to the output vertex list.
4. If both the input vertices are outside the window boundary nothing is added to the output vertex
list.

Midpoint Sub-Division Algorithm

The line is divided at its midpoint into 2 shorter line segments. The clipping categories of the 2 new line
segment are next computed using the region.

Category 1: Lines are completely inside the visible region.

Category 2: Lines are not visible and lines outside the window.

Category 3: Lien is again divided into shorter segments and apply these 3 categories.

The midpoint co-ordinates (Xm, Ym) of a line (x1,y1) and (x2,y2) are given by xm=(x1+x2)/2 In
the above picture, we can determine the 2 intersection points A1 and B1 With 5 bisections using
midpoint subdivision algorithm.

Questions:

1. Differentiate between Window and Viewport.(1M,DEC 2011)


2. Explain exterior clipping. (1M,DEC 2011)
3. How is curve clipping performed? (1M,DEC 2011)
4. Explain Cohen Sutherland curve clipping algorithm(1M,DEC 2011)
5. Explain different forms of text clipping.(5M,DEC 2011)
6. Describe the cohen Sutherland algorithm for line clipping.
7. Explain the midpoint subdivision method of clipping a line segment.
8. What are the different types of text clipping explain with example.

Department of BCA Page 40


Computer Graphics Vidyavahini First Grade college, Tumkur

9. How is curve clipping performrd?


10. Distinguish between windows and viewport?

Chapter 5 Three
Dimensional Displays

Department of BCA Page 41


Computer Graphics Vidyavahini First Grade college, Tumkur

Dimensional Co-ordinate System

The conventional orientation for the co-ordinate axis in a 3 dimensional system is determined as follows.

1. Right handed system.


2. Left handed system.

1. Right handed System: If the thumb of right hand point in the positive Z direction, then the co
ordinates are called a right handed system.

2. Left handed System:If the thumb of left hand points a positive Z direction, then the coordinates
are called a left handed system.

Three Dimensional Display Techniques

It is representation of a solid object on a viewing surface usually contain depth information.

Department of BCA Page 42


Computer Graphics Vidyavahini First Grade college, Tumkur

The technique for achieving realistic images objects in 3 Dimensional Graphics System.

Projection can be defined as mapping of a point p(x, y, z) onto its image P (x, y, z) in the projection
plane (or) view plane.

Projection can be classified into 2 types.

(i) Parallel projection.


(ii) Perspective projection.

1. Parallel Projection:

Parallel projection involves generating a view of a solid object by projecting points on the object
surface along parallel lines onto the display plane.

By selecting different viewing positions we can project visible points of the object on the display plane and
obtain different 2 – Dimensional views of the object.

Department of BCA Page 43


Computer Graphics Vidyavahini First Grade college, Tumkur

2. Perspective Projection:

For generating a view of a 3D object, the points are projected onto the display plane
along converging lines. This makes the objects which are far away from the viewing position
to be displayed smaller than the objects with the same size. If the object si nearer to the viewing
position to be displayed.

For generating a view of a 3 D object, the points are projected onto the display plane
along converging lines. This makes the objects which are far away from the viewing position
to be displayed smaller than the objects with the same size. If the object isnearer to the viewing
position to be displayed larger.

Using perspective projection, the images displayed look more realistic, since that is the way our
eyes (or) the camera, forms images.

Difference between Parallel And Perspective Projection.

Parallel projection Perspective Projection

1.The Projection are parallel 1. The projection intersect at the to each


other. thecentre of position.
2. Less realistic in parallel 2. Visual effect is similar to Projection.
3.Preserves the parallel lines. 3. Do not preserve the parallel Lines.
4.The centre of projection is at 4. The centre of project is a
Infinity. Finite point.
Intensity Cueing (or) Depth Cueing

Department of BCA Page 44


Computer Graphics Vidyavahini First Grade college, Tumkur

Intensity is to vary the intensity of lines according to their distance from the viewing position.
From the below the pic shows, an object with front lines highlighted and drawn wider than back
lines. The range of intensity brightness gradually decreases for lines far from the viewer.

Hidden Line Removal


This technique is useful when objects are defined as a set of lines representing the edges of the
surface of the objects. Any lines that are hidden by front surface are removed before the object
is displayed.

Hidden Surface Removal and Shading


When i mages are viewed as surfaces filled with color (or) shaded patterns, hidden surface removal
technique are used to remove surfaces hidden by visible surface.
Removing hidden surface is generally a complicated and time consuming process but it provides
realistic in 3D images.

Exploded and Cut Way Views.


The exploded view of the drawing clearly shows the structures of component parts, including those that
are invisible in the assembled view.
Another view is a cut way view, removes parts of the visible surface to show internal structure.

3-Dimensional Transformations.
(i) Translation.
(ii) Scaling.
(iii) Rotation.

Translation:

In a 3 – D Co -ordinate representation, a point „p‟ (x, y, z) is translated to position p 1(x1,y1,z1) with the
matrix operation.

The translation vectors areT(tx,ty,tz)

The matrix representation using 3*3 matrix

Department of BCA Page 45


Computer Graphics Vidyavahini First Grade college, Tumkur

= +

Scaling

In a 3 – D co-ordinate representation, an object is scaled from the position (x, y, z) to the position
(x1,y1,z1) with the matrix operation.

The matrix representation using 3*3 matrix

Where Sx,Sy,Sz are the scaling factors.

Rotation:Rotation is the ability to repositioning an image along a circular path in the x, y, z

Department of BCA Page 46


Computer Graphics Vidyavahini First Grade college, Tumkur

plane. By specifying the angle of rotation which the object is to be rotated.

Polygon Surfaces.

Any closed object can be classified as a polygon, i.e., any 3 – D object can be represented as a set of plain
polygon surfaces.

Department of BCA Page 47


Computer Graphics Vidyavahini First Grade college, Tumkur

A 3 – D graphics object is generally represented using a set of surface polygons enclosing the
object interior. The object descriptions are stored as a set of surface polygons. Realistic images
can be produced by interpolating shaded patterns on the polygon surface.

Polygon Tables

A polygon surface is specified with a set of vertex co-ordinates and attributes parameters. The
information for each polygon is stored in data tables which are later used for processing display
and manipulation of the objects.

Polygon tables can be divided into 2 groups.

1. Geometric Table:It consists of vertex co-ordinates and parameters for identifying orientation of
polygon surface.
2. Attribute Table:it contains parameters specifying the degree of transparency, surface reflectivity
and texture of the object.

Geometric Table generally date is stored in the form of 3 lists.


(i) Vertex table : stores co-ordinate values of each vertex of the object.
(ii) Edge table : Stores pointers to vertex table identifying the vertices for each polygon edge.
(iii) Polygon surface table: Consists of pointers to the edge table identifying the edges for each
polygon.

Constructive – Solid Geometry Method (CSG)

Another useful technique for solid modelling is to combine the volumes occupied by overlapping 3D
objects using set of operations. This method is called CSG.

It created a new object by applying the union, intersection and difference operation to two specified
objects.

(i) Union: A block and pyramid are placed adjacent to each other using union operation we obtain the
combined object.

Department of BCA Page 48


Computer Graphics Vidyavahini First Grade college, Tumkur

(ii) Intersection: A block and a cylinder with overlapping volumes, using the intersection operation,
we can get the resulting solid object.

(iii) Difference: The solid is obtained with a difference operation by substracting overlapping volume
of the cylinder from the block.
Oct trees

Oct trees are hierarchical tree structures used to represent solid objects in a graphics system,
medical imaging and other applications requiring displace of object cross sections use oct tree
representation. The tree structure is such that each node corresponds to a region of 3D space. It
also provides a convenient method for storing information about object interiors.

A heterogeneous octant is sub divided into 8 parts, the corresponding data element in the node
points to the next node in the oct tree.

Oct trees can be generated by using the procedure of quad trees.

Department of BCA Page 49


Computer Graphics Vidyavahini First Grade college, Tumkur

Fractal Geometry Method


There are no. of objects like mountains and clouds which have irregular (or) fragmented
features, such objects cannot be represented as smooth surface, they can be modelled using the
fractal Geometry method, that was developed by Mandelbrot.

Fractal Geometry representations for objects are applied in many fields to describe the features of
natural phenomenon. In computer graphics we use fractal method to generate images of
natural objects and for viewing of various mathematical and physical systems.

Applications of Fractals

1. Fractal representations are used for modelling clouds, water, trees, plants, etc.,
2. Fractal patterns are also found in distribution of stars, moon, music, traffic flow, etc.,

Classification of Fractals.

1. Self – Similar [Trees, Plants, Shrubs].


2. Self – affine [water, clouds, etc]
3. Invariant Fractals [self squaring fractals and self inverse fractals]

Bezier Curves

P Bezier pioneered the use of computer modelling of surfaces in automobile design. His method has
been applied to define the outer panels of several cause marketed by Reyna

Bezier defines the curve p (u) in terms of the location (n + 1) control points pi as a blending function B
I, n (u)

Where blending function,

Where the binomial co-efficient.

Department of BCA Page 50


Computer Graphics Vidyavahini First Grade college, Tumkur

According to x, y, z plane the respective Bezier curves are,

A Bezier curve is a polynomial of degree, one less than the no. of control points used, 3 points, generate
a parabola, u points generate a cubic curve and so on.

Hidden Surface and Hidden Line Removal

There are many approaches that we can take to solve the problem of removing the parts of the
picture definition that are not visible from a chosen viewing position.

Back Face Removal

A simple object space method for identifying the back face of objects is based on the equation of
planeAx + By +Cz + D =0

Any point x, y, z specified in a right – handed system co -ordinate is on the inside of this plane if it
satisfies the inequality Ax + By + Cz + D < O.

A simple back – face test can be done by considering a normal vector „N‟ with Cartesian co
ordinates (a,b,c) in a right – handed system viewing along the negative Z, axis.

If C < O the polygon is a back – face since the normal vector points away from the viewing position.

Depth Buffer Method

Department of BCA Page 51


Computer Graphics Vidyavahini First Grade college, Tumkur

Image space method is used to detect visible surface in depth buffer method, which compares surface
depth at each pixel position on the projection plane. This procedure is also referred to as Z – Buffer
method, since object depth is usually measured from the view plane along the Z – axis of a viewing
system.

2 Buffer areas are required to store depth values and intensity. One a depth buffer is used to
store depth values for each (x, y) positions. Second is refresh buffer stores the intensity values
for each position.

Scan Line Method

An extension of scan l ine polygon filling with multiple surfaces, it is to intersect each polygon with a
particular scan line solving hidden surface problem. Across each scan line depth calculations are made
for each over lapping surface to determine which is nearest to the view plane.

Scan lines are processed from left to right. For the various surfaces 2 tables are used to store the
data.

(i) Edge Table: contains co-ordinate points for each line in the screen.
(ii) Polygon table: contains co-efficient of the plane equation for each surface.

Questions:

Department of BCA Page 52


Computer Graphics Vidyavahini First Grade college, Tumkur

1. .Explain intensity cueing.(1M,DEC 2011)


2. Explain perspective projection technique.(1M,DEC 2011)
3. What is a cubic Bezier curve? What is the order of the polynomial for a cubic Bezier curve?
(5M,DEC 2011)
4. lustrate polygon tables with an example.(5M,DEC 2011)
5. Explain Depth-Buffer algorithm.(5M,DEC 2011)
6. Explain scan-line method for multiple surfaces.(5M,DEC 2011)
7. Explain union, intersection and differencesolid-geometry methods.(3M,DEC 2011) 8. Write
a short note on Graphical input techniques and octrees.(3M,DEC 2011)
9. What is Fractal? Explian.
10. Explain parallel and perspective projection?

Department of BCA Page 53


Computer Graphics Vidyavahini First Grade college, Tumkur

Chapter 6
Segments

A segment is a set of output primitives that are joined for modification purpose.

Segments are the subdivision of pictures, segments are the visualization of a particular part of the
picture and we can apply translation scaling and rotation.

Functions for segmenting the display file.

To create new segments we first open the segments and then call Graphics primitives to modify
the segments and then we must close the segment. To remove a segment from the display file.

We delete the segment.

The basic functions are

1. Open Segment (n) – Open a display file segment named n.


2. Close Segment – Close the Opened segment.
3. Delete Segment (n) – remove the segment n from the display file.

Segment File

List of segments are maintained by a Graphics system is known as segment file. Segment file often
are stored as linked structures.

Starting Segment

Address

Segment 1 Segment 2 Segment 3 /

Segment Attributes

1. Visibility - Visibility of a segment can be set by the user with the function.

Department of BCA Page 54


Computer Graphics Vidyavahini First Grade college, Tumkur
Set _visibility (id, v) where id- segment no.
V-visible (or) invisible.
2. Priority- segments priority can be set with the function.

Set _Segment Priority (id,p) where p- priority

3. Highlights – highlighting of a segment is implemented with the function.


Set_highlight(id, h) where h-highlight or normal 4. Transformation- transformation is
implemented with the function.

Set_segment_transformation (id, matrix) where matrix


specifies the element of the transformation matrix. To

achieve segment transformations, the user can specify the transformation like size,
position and orientation matrix which needs to be applied to the individual segments.

Questions:
1. Give any two functions for segmenting.(1M,DEC2011)
2. Explain storage of segment files. (1M,DEC2011)
3. Explain the attributes of segments?

Department of BCA Page 55


Computer Graphics Vidyavahini First Grade college, Tumkur

Chapter 7

Graphical Input Techniques


Interactive Picture Construction Techniques

The Co-Ordinate information of the object can be entered using input devices.

Once the information has entered in it can be modified to re-arrange (or) reshape the object. We
see several techniques available in Graphical packages to construct the interactive pictures using
input devices.

Positioning Techniques

Positioning involves the user in the first moving cursor (or) tracking cross to the desired spot on
the screen and then notifying the computer by pressing a button (or) key. A single positioning
operation can be used to insert a symbol as in the picture and two succession can be defined the
end points of a line.

The user indicates a position on the screen with an input device and this position is used to insert
a symbol. Positioning is also known as locating.

Constraints

There are many kinds of constraints functions that can be specified, but the most common

Department of BCA Page 56


Computer Graphics Vidyavahini First Grade college, Tumkur
constraint is a horizontal (or) vertical alignment of straight line.

Horizantal line constraint Vertical line constraint

Grids

Any input co -ordinate position is rounded to the nearest intersection of 2 grid lines each of the 2
cursor position is shifted to the nearest grid position point and the line is drawn between these grid
points.

Gravity Field

When constructing a pictu re, we sometimes need to connect lines at position between endpoints.
Since exact positioning of the screen cursor at the connecting point can be difficult, graphics
packages can be designed to convert any input position near a line to a position on the li ne

Any selected position with the gravity field of a line is moved to the nearest position on the line.

Rubber – Band Method

Straight lines, Rectangles & circles can be constructed and positioned using RubberBandMethods.
We first select a screen position for one end point of the line, as the cursor moves around the line

Department of BCA Page 57


Computer Graphics Vidyavahini First Grade college, Tumkur
stretches out from the starting position to the current position of the cursor. When we finally select
second position then it constructs line.

Dynamic Manipulation

Dragging is a technique used in interactive picture construction is to move objects by dragging


them with the screen cursor. First select an object, then move the curso r in the direction we want
the object to move, the selected object follows the cursor path and finally place to object
somewhere on the screen.

Painting and Drawing

Options for sketching and drawing and painting comes in a variety of forms curved drawing can
be provided using standard curve shapes such as circular arcs with free hand sketching procedures.
In free hand drawing curves are generated by following the path of styles on graphic tablets (or)
the path of the screen cursor on a video monitor.

Pointing & Selections

Pointing and selecting technique is used to select the picture parts that need modification.

Selection

Department of BCA Page 58


Computer Graphics Vidyavahini First Grade college, Tumkur
Selection is a useful tool in the hands of the user for selecting the images.

Different types of selection techniques are

1. Use of selection points.


2. Defining a bounding rectangle.
3. Multiple keys for selections.
4. Prefix commands.
5. Modes.
1. Use of selection points.
In order to select a Graphical unit the user points to a specific spot such as the centre of a
circle (or) an endpoint of a line selection points can be provided for symbols and larger sub
pictures.

2. Defining a bounding rectangle.


The user can define two opposite corners of a rectangle and in this way select an object that
lines within the rectangle. This techniques is useful for multiple selection.

3. Multiple keys for selections.

When the user has positioned the curser over the object to select, we can press one of the
several keys according to the type of object. The selection can be one key to select a line,
another to select a point and a third one to select a symbol.

4. Prefix commands

The type of object to be selected can be determined by the user priori/previous choice of
command. The command is given before the selection and many specifies which type of object
is to be selected.

For Eg:- There are 3 different DELETE commands are available.

i.e., DELETTE POINT, DELETE LINE, DELETE SYMBOL

5. Modes

The user may be able to change the selection mechanism by setting different modes of
operation. In one mode the program allow only line selection and in another program allow
only the symbol selection.

Multiple Selections

Department of BCA Page 59


Computer Graphics Vidyavahini First Grade college, Tumkur
The user must be able to select more than one element at a time. Multiple selection can be provided
in a no. of ways.

(i) To indicate the first and last element in the line sequence to be
selected.
(ii) To select the element by specifying a bounding rectangle. (iii)
The user must select each one.

Menu Selection

Menu is displayed on the screen and the user points to the selection with a graphical input
device. Menus can be used for a variety of reasons.

1. They allow the user to choose an element for insertion.


2. To change the mode of operation of the program.
3. To issue a command.
4. They protect the user from making an invalid selection.

Selection By Name

In this technique the user must type the name of the choice. If the user knows the names of
various objects, then referring to them by name would be reasonable and faster than pointing
method.

Selection by naming is also the best method for experienced and regular users. When the name
typed does not match one in the system, other name close to the typed name must be presented
to the user as alternatives.

Questions:

1. Explain pointing and selection techniques.(1M,DEC 2011)


2. Explain menu in detail?
3. Explain constraints?
4. Explain the selection Techniques?
5. Explain Rubber band method?

Department of BCA Page 60


Computer Graphics Vidyavahini First Grade college, Tumkur

CHAPTER 8
Graphical Input Device

An input device is any peripheral device (piece of hardware) used to provide data and control
signals to an information processing system. All the computers have keyboard which is an input
device. The other input devices are Mouse, trackball, joystick, touchpad and Light pen.

Two types of Graphical interaction

1. Pointing Device- points item already on the screen


2. Positioning Device- positioning new items.

Keyboard.

In a computer a “keyboard” is a device that converts letters, numbers and other


character into electronical signals that are machine readable by the computer‟s process. The
keyboard may look like a typewriter keyboard to which some special keys have been added.

• It is an Input Device.
• It is design came from typewriter.
• A person can type document access menus, play games and perform variety of tasks.

The keys on computer keyboards are often classified as follows alphanumeric keys,
punctuation keys and special keys.

Mouse [Mechanically Operated Use Serial Engineer]

Types of Mouse:

1. Mechanical mouse 2.
Opto Mechanical 3.
Optical mouse.

Main Goals of Mouse


It is to translate the motion of the hand into signals that the computer can understand and
use.

Department of BCA Page 61


Computer Graphics Vidyavahini First Grade college, Tumkur
A mouse is small hand-held box used to position the screen cursor.
The mechanical mouse uses a rubber coated ball on the underside. The movement of this
ball will sends electrical signals to the system.
The optical mouse uses diodes to emit light on to a metal pad.

Actions:
1. Pointing: Points to a particular object on the screen.
2. Single click: It selects the object.
3. Double click: It opens selected files.
4. Right click: Displays a popup menu corresponding to the selected object.
5. Drag and Drop: Dragging the one object to another location.

Advantages:
1. Easy to use
2. Low cost
3. No need to type commands
4. Easy to select menus and open them

Touch Pad
It is pointing devices consists of specialized surface and translate the motion and position of a
user‟s finger to relative position on screen.
Touchpad‟s are small sensitive tablets commonly used on laptop computers.
Most Touchpad supports support an absolute mode to allow Asian language to input or
signature.
Touchpad typically respond in relative mode because of the small size of the pad.
Features
1. They are commonly used for laptops.
2. Used as a substitute for a computer mouse.
3. Touch pads vary in size but are rarely made larger than 40 square centimetres.
A basic touch pad has 3 main components.
1. Touch sensor.
2. Controller.
3. Software driver.

Trackball

Department of BCA Page 62


Computer Graphics Vidyavahini First Grade college, Tumkur
It is a computer cursor control device that can be rotated with the fingers (or) palm of the
hand.
It was invented by Tom Cranston and Fred Long staff as part of the Royal Canadian
Navy‟s DATAR system in 1952.
Compared with a mouse, a trackball has no limits on effective travel; a mouse can reach an edge
of its working area.
A Trackball is a ball that can be rotated with the fingers to produce screen cursor
movement. Potentiometers attached to the ball measure the amount and directions of rotation.
Trackball are used for three dimensional positioning and selection operations in virtual systems.

Joystick:
It is an input device consisting of a stick that pivots on a base and reports its angle or direction to
the device it is controlling.
A joystick consists of a small, vertical level mounted on a base that is used to steer the
screen cursor around.
Most joysticks select screen positions with actual stick movement.

Potentiometers mounted at the base of the joystick measure the amount of movement.

Questions:

1. Write short notes on the following (5M,Dec 2011)


a) Game pad
b) Tablet
c) Light pen
2. Explain keyboard as an input device. (1M,Dec 2011)
3. Explain Graphical input techniques. (1M,Dec 2011)

Department of BCA Page 63

You might also like