Unit-1 CG
Unit-1 CG
Unit-1 CG
Computer Graphics is the creation of pictures with the help of a computer. The end product of
the computer graphics is a picture it may be a business graph, drawing, and engineering.
In computer graphics, two or three-dimensional pictures can be created that are used for
research. Many hardware devices algorithm has been developing for improving the speed of
picture generation with the passes of time. It includes the creation storage of models and image
of objects. These models for various fields like engineering, mathematical and so on.
Computer Graphics is the creation and manipulation of images or pictures with the help of
computers. The major product of computer graphics is a picture. With the help of CG,
pictures can be represented in 2D and 3D space. Many applications show various parts of the
displayed picture changing in size and orientation.
For some training applications, particular systems are designed. For example Flight Simulator.
Flight Simulator: It helps in giving training to the pilots of airplanes. These pilots spend much
of their training not in a real aircraft but on the ground at the controls of a Flight Simulator.
Advantages:
1. Fuel Saving
2. Safety
3. Ability to familiarize the training with a large number of the world's airports.
2. Use in Biology: Molecular biologist can display a picture of molecules and gain insight
into their structure with the help of computer graphics.
o Financial Reports
o Statistical Reports
o Mathematical Reports
o Scientific Reports
o Economic Data for research reports
o Managerial Reports
o Consumer Information Bulletins
o And other types of reports
6. Computer Art: Computer Graphics are also used in the field of commercial arts. It is
used to generate television and advertising commercial.
7. Entertainment: Computer Graphics are now commonly used in making motion pictures,
music videos and television shows.
10. Printing Technology: Computer Graphics is used for printing technology and textile
design.
Introduction
Display Devices:
The most commonly used display device is a video monitor. The operation of most video
monitors based on CRT (Cathode Ray Tube). The following display devices are used:
Advantages:
1. A CRT has the electron beam directed only to the parts of the screen where an image is
to be drawn.
2. Produce smooth line drawings.
3. High Resolution
Disadvantages:
Frame Buffer is also known as Raster or bit map. In Frame Buffer the positions are called
picture elements or pixels. Beam refreshing is of two types. First is horizontal retracing and
second is vertical retracing. When the beam starts from the top left corner and reaches the
bottom right scale, it will again return to the top left side called at vertical retrace. Then it will
again more horizontally from top to bottom call as horizontal retracing shown in fig:
UNIT-1
Types of Scanning or travelling of beam in Raster Scan
1. Interlaced Scanning
2. Non-Interlaced Scanning
In Interlaced scanning, each horizontal line of the screen is traced from top to bottom. Due to
which fading of display of object may occur. This problem can be solved by Non-Interlaced
scanning. In this first of all odd numbered lines are traced or visited by an electron beam, then
in the next circle, even number of lines are located.
For non-interlaced display refresh rate of 30 frames per second used. But it gives flickers. For
interlaced display refresh rate of 60 frames per second is used.
Advantages:
1. Realistic image
2. Million Different colors to be generated
3. Shadow Scenes are possible.
Disadvantages:
1. Low Resolution
2. Expensive
5. Refresh rate depends or resolution 5. Refresh rate does not depend on the picture.
7. Beam Penetration technology come under it. 7. Shadow mark technology came under this.
Display Processor:
It is interpreter or piece of hardware that converts display processor code into pictures. It is
one of the four main parts of the display processor
Display File Memory: It is used for generation of the picture. It is used for identification of
graphic entities.
Display Controller:
1. It handles interrupt
2. It maintains timings
3. It is used for interpretation of instruction.
Display Generator:
Display Console: It contains CRT, Light Pen, and Keyboard and deflection system.
UNIT-1
The raster scan system is a combination of some processing units. It consists of the control
processing unit (CPU) and a particular processor called a display controller. Display Controller
controls the operation of the display device. It is also called a video controller.
Working: The video controller in the output circuitry generates the horizontal and vertical
drive signals so that the monitor can sweep. Its beam across the screen during raster scans.
As fig showing that 2 registers (X register and Y register) are used to store the coordinate of
the screen pixels. Assume that y values of the adjacent scan lines increased by 1 in an upward
direction starting from 0 at the bottom of the screen to ymax at the top and along each scan line
the screen pixel positions or x values are incremented by 1 from 0 at the leftmost position to
xmax at the rightmost position.
The origin is at the lowest left corner of the screen as in a standard Cartesian coordinate system.
X register is set to 0 and y register is set to ymax. This (x, y') address is translated into a memory
address of frame buffer where the color value for this pixel position is stored.
The controller receives this color value (a binary no) from the frame buffer, breaks it up into
three parts and sends each element to a separate Digital-to-Analog Converter (DAC).
These voltages, in turn, controls the intensity of 3 e-beam that are focused at the (x, y) screen
position by the horizontal and vertical drive signals.
UNIT-1
This process is repeated for each pixel along the top scan line, each time incrementing the X
register by Y.
As pixels on the first scan line are generated, the X register is incremented throughxmax.
Then x register is reset to 0, and y register is decremented by 1 to access the next scan line.
Pixel along each scan line is then processed, and the procedure is repeated for each successive
scan line units pixels on the last scan line (y=0) are generated.
For a display system employing a color look-up table frame buffer value is not directly used to
control the CRT beam intensity.
It is used as an index to find the three pixel-color value from the look-up table. This lookup
operation is done for each pixel on every display cycle.
As the time available to display or refresh a single pixel in the screen is too less, accessing the
frame buffer every time for reading each pixel intensity value would consume more time what
is allowed:
Multiple adjacent pixel values are fetched to the frame buffer in single access and stored in the
register.
After every allowable time gap, the one-pixel value is shifted out from the register to control
the warm intensity for that pixel.
The procedure is repeated with the next block of pixels, and so on, thus the whole group of
pixels will be processed.
Components of CRT:
Main Components of CRT are:
1. Electron Gun: Electron gun consisting of a series of elements, primarily a heating filament
(heater) and a cathode. The electron gun creates a source of electrons which are focused into a
narrow beam directed at the face of the CRT.
3. Focusing system: It is used to create a clear picture by focusing the electrons into a narrow
beam.
4. Deflection Yoke: It is used to control the direction of the electron beam. It creates an electric
or magnetic field which will bend the electron beam as it passes through the area. In a
conventional CRT, the yoke is linked to a sweep or scan generator. The deflection yoke which
is connected to the sweep generator creates a fluctuating electric or magnetic potential.
5. Phosphorus-coated screen: The inside front surface of every CRT is coated with phosphors.
Phosphors glow when a high-energy electron beam hits them. Phosphorescence is the term
used to characterize the light given off by a phosphor after it has been exposed to an electron
beam.
The Beam-Penetration method has been used with random-scan monitors. In this method, the
CRT screen is coated with two layers of phosphor, red and green and the displayed color
UNIT-1
depends on how far the electron beam penetrates the phosphor layers. This method produces
four colors only, red, green, orange and yellow. A beam of slow electrons excites the outer red
layer only; hence screen shows red color only. A beam of high-speed electrons excites the inner
green layer. Thus screen shows a green color.
Advantages:
1. Inexpensive
Disadvantages:
1. Only four colors are possible
2. Quality of pictures is not as good as with another method.
2. Shadow-Mask Method:
o Shadow Mask Method is commonly used in Raster-Scan System because they produce
a much wider range of colors than the beam-penetration method.
o It is used in the majority of color TV sets and monitors.
Construction: A shadow mask CRT has 3 phosphor color dots at each pixel position.
This type of CRT has 3 electron guns, one for each color dot and a shadow mask grid just
behind the phosphor coated screen.
Shadow mask grid is pierced with small round holes in a triangular pattern.
Figure shows the delta-delta shadow mask method commonly used in color CRT system.
UNIT-1
The deflection system of the CRT operates on all 3 electron beams simultaneously; the 3
electron beams are deflected and focused as a group onto the shadow mask, which contains a
sequence of holes aligned with the phosphor- dot patterns.
When the three beams pass through a hole in the shadow mask, they activate a dotted triangle,
which occurs as a small color spot on the screen.
The phosphor dots in the triangles are organized so that each electron beam can activate only
its corresponding color dot when it passes through the shadow mask.
Inline arrangement: Another configuration for the 3 electron guns is an Inline arrangement
in which the 3
electron guns and the corresponding red-green-blue color dots on the screen, are aligned along
one scan line rather of in a triangular pattern.
This inline arrangement of electron guns in easier to keep in alignment and is commonly used
in high-resolution color CRT's.
UNIT-1
Advantage:
1. Realistic image
2. Million different colors to be generated
3. Shadow scenes are possible
Disadvantage:
1. Relatively expensive compared with the monochrome CRT.
2. Relatively poor resolution
3. Convergence Problem
Example: Small T.V. monitor, calculator, pocket video games, laptop computers, an
advertisement board in elevator.
1. Emissive Display: The emissive displays are devices that convert electrical energy into
light. Examples are Plasma Panel, thin film electroluminescent display and LED (Light
Emitting Diodes).
UNIT-1
2. Non-Emissive Display: The Non-Emissive displays use optical effects to convert sunlight
or light from some other source into graphics patterns. Examples are LCD (Liquid Crystal
Device).
Keyboard:
The most commonly used input device is a keyboard. The data is entered by pressing the set of
keys. All keys are labelled. A keyboard with 101 keys is called a QWERTY keyboard.
The keyboard has alphabetic as well as numeric keys. Some special keys are also available.
1. Numeric Keys: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
2. Alphabetic keys: a to z (lower case), A to Z (upper case)
3. Special Control keys: Ctrl, Shift, Alt
4. Special Symbol Keys: “? @ ~ ? :
5. Cursor Control Keys: ↑ → ← ↓
6. Function Keys: F1 F2 F3....F9.
7. Numeric Keyboard: It is on the right-hand side of the keyboard and used for fast entry
of numeric data.
Function of Keyboard:
Disadvantage:
1. Keyboard is not suitable for graphics input.
Mouse:
A Mouse is a pointing device and used to position the pointer on the screen. It is a small palm
size box. There are two or three depression switches on the top. The movement of the mouse
along the x-axis helps in the horizontal movement of the cursor and the movement along the
y-axis helps in the vertical movement of the cursor on the screen. The mouse cannot be used
to enter text. Therefore, they are used in conjunction with a keyboard.
Advantage:
1. Easy to use
2. Not very expensive
Trackball
Spaceball:
It is similar to trackball, but it can move in six directions where trackball can move in two
directions only. The movement is recorded by the strain gauge. Strain gauge is applied with
pressure. It can be pushed and pulled in various directions. The ball has a diameter around 7.5
cm. The ball is mounted in the base using rollers. One-third of the ball is an inside box, the rest
is outside.
Applications:
1. It is used for three-dimensional positioning of the object.
2. It is used to select various functions in the field of virtual reality.
3. It is applicable in CAD applications.
4. Animation is also done using spaceball.
5. It is used in the area of simulation and modeling.
Joystick:
A Joystick is also a pointing device which is used to change cursor position on a monitor screen.
Joystick is a stick having a spherical ball as its both lower and upper ends as shown in fig. The
lower spherical ball moves in a socket. The joystick can be changed in all four directions. The
function of a joystick is similar to that of the mouse. It is mainly used in Computer Aided
Designing (CAD) and playing computer games.
Light Pen
Light Pen (similar to the pen) is a pointing device which is used to select a displayed menu
item or draw pictures on the monitor screen. It consists of a photocell and an optical system
placed in a small tube. When its tip is moved over the monitor screen, and pen button is pressed,
its photocell sensing element detects the screen location and sends the corresponding signals
to the CPU.
UNIT-1
Uses:
1. Light Pens can be used as input coordinate positions by providing necessary
arrangements.
2. If background color or intensity, a light pen can be used as a locator.
3. It is used as a standard pick device with many graphics system.
4. It can be used as stroke input devices.
5. It can be used as valuators
Digitizers:
The digitizer is an operator input device, which contains a large, smooth board (the appearance
is similar to the mechanical drawing board) & an electronic tracking device, which can be
changed over the surface to follow existing lines. The electronic tracking device contains a
switch for the user to record the desire x & y coordinate positions. The coordinates can be
entered into the computer memory or stored or an off-line storage medium such as magnetic
tape.
Advantages:
1. Drawing can easily be changed.
2. It provides the capability of interactive graphics.
Disadvantages:
1. Costly
2. Suitable only for applications which required high-resolution graphics.
Touch Panels:
Touch Panels is a type of display screen that has a touch-sensitive transparent panel covering
the screen. A touch screen registers input when a finger or other object comes in contact with
the screen.
UNIT-1
When the wave signals are interrupted by some contact with the screen, that located is recorded.
Touch screens have long been used in military applications.
Voice Recognition is one of the newest, most complex input techniques used to interact with
the computer. The user inputs data by speaking into a microphone. The simplest form of voice
recognition is a one-word command spoken by one person. Each command is isolated with
pauses between the words.
Voice Recognition is used in some graphics workstations as input devices to accept voice
commands. The voice-system input can be used to initiate graphics operations or to enter data.
These systems operate by matching an input against a predefined dictionary of words and
phrases.
Advantage:
1. More efficient device.
2. Easy to use
3. Unauthorized speakers can be identified
Disadvantages:
1. Very limited vocabulary
2. Voice of different operators can't be distinguished.
Image Scanner
It is an input device. The data or text is written on paper. The paper is feeded to scanner. The
paper written information is converted into electronic format; this format is stored in the
computer. The input documents can contain text, handwritten material, picture extra.
By storing the document in a computer document became safe for longer period of time. The
document will be permanently stored for the future. We can change the document when we
need. The document can be printed when needed.
Scanning can be of the black and white or colored picture. On stored picture 2D or 3D rotations,
scaling and other operations can be applied.
Components:
The graphics software components are the tools that you use to create and
manipulate your graphic images. These components include the following:
Image editors: These are the tools that you use to create or edit your
graphic images. Common image editors include Photoshop,
Illustrator, and Inkscape.
Vector graphics editors: These are the tools that you use to create or
edit vector graphics. Common vector graphics editors include
CorelDRAW and Inkscape.
3D modeling software: This is the software that you use to create
three-dimensional models. Common 3D modeling software includes
Maya, 3ds Max, and Cinema 4D.
UNIT-1
Animation software: This is the software that you use to create
animations. Common animation software includes Adobe After
Effects, Apple Motion, and Autodesk Maya.
Video editing software: This is the software that you use to edit
videos. Common video editing software includes Adobe Premiere
Pro, Apple Final Cut Pro, and Avid Media Composer.
Types:
Vector graphics software: This type of software is used to create
images made up of lines and shapes, which can be scaled without
losing quality. Vector graphics are often used for logos, illustrations,
and diagrams.
Raster graphics software: This type of software is used to create
images made up of pixels, which cannot be scaled without losing
quality. Raster graphics are often used for photos and web graphics.
3D graphics software: This type of software is used to create three-
dimensional images and animations. 3D graphics are often used for
product visualization and gaming.
Animation software: This type of software is used to create moving
images, either by animating existing graphics or by creating new
ones from scratch. Animation software is often used for movies,
commercials, and video games.
Applications:
The applications are used by professionals in a variety of fields, including
graphic design, photography, video editing, and web design. There are a wide
variety of graphics software applications available, each with its own unique
set of features and capabilities. It is important to choose the right application
for the specific task at hand.
It can be used to create and edit logos, and other graphical elements.
It can be used to create website layouts and design elements.
It can be used to create illustrations, visual presentations, and digital
art.
It can be used to edit and enhance photos, images, and animation.
It can be used to create and edit website designs, presentation slides,
and marketing materials.
2. SetbkColor
Purpose:-Setbkcolor function is used to set background color of the screen.
Syntax:-setbkcolor(COLOR);
Example:-setbkcolor(RED);
3. Setlinestyle
Purpose:-setlinestyle function is used to set the current line style, width and
pattern
Syntax:-setlinestyle(linestyle, pattern, thickness);
Example:-setlinestyle(SOLID_LINE,1,2);
4. Setcolor
Purpose:-setcolor is to set color of the objects which is to be drawn after this
setcolor line.
Syntax:-setcolor(COLOR);
Example:-setcolor(RED);
5. Rectange:-
Purpose:- Rectangle function is used to draw the rectangle on the
screen. X1,y1 are the lower left co-ordinates of the rectangle and the x2,y2 are
the upper right co-ordinates of the rectangle.
Syntax:– rectangle(x1,,y1,x2,y2);
Example:– rectangle(100,100,200,200);
6. Textheight
Purpose:-textheight returns the height of a string in pixels.
Syntax:-textheight(STRING);
Example:-i=textheight(“HELLO”);
7. Textwidth
Purpose:-textwidth returns the width of a string in pixels
UNIT-1
Syntax:-textwidth(STRING);
Example:-i=textwidth(“HELLO”);
8. Getx
Purpose:-getx returns the current position’s of x o-ordinate
Syntax:-getx();
Example:-x=getx();
9. Gety
Purpose:-gety returns the current position’s of y co-ordinate
Syntax:-gety();
Example:-y=gety();
10. Getmaxx
Purpose:-getmaxxreturns the maximum x co-ordinate on the screen
Syntax:-getmaxx();
Example:-maxx=getmaxx();
11. Getmaxy
Purpose:-getmaxy returns the maximum y co-ordinate on the screen
Syntax:-getmaxy();
Example:-maxy=getmaxy();
12. Line
Purpose:-Line function is used to draw the line on the screen.
Syntax: line(x1,y1,x2,y2);
Example:-line(100,100,200,100);
13. Closegraph
Purpose:-closegraph function shut down the graphic system
Syntax:-closegraph();
Example:-closegraph();
14. Moveto
Purpose:-moveto function moves current cursor position on the screen
Syntax:-moveto(x co-ordinate, y co-ordinate);
Example:-moveto(getmaxx/2, getmaxy/2);
15. Settextstyle
Purpose:-settextstyle sets the current text characteristics like font, direction and
size
UNIT-1
Syntax:-settextstyle(font, direction size);
Example:-settextstyle(1,1,10);
Font 1 DEFAULT
2 TRIPLEX
3 SMALL
4 SANS SERIF
5 GOTHIC
Direction 0 HORIZ_DIR
VERT_DIR
Size 0 SMALL
10 large
16. Circle
Purpose: Circle function is used to draw the circle on the screen
Syntax:– circle(x,y,radius);
Example:circle(100,100,50);
17. Cleardevice
Purpose: cleardevice function is used to clear the contents or graphic images on
the screen in graphics mode.
Syntax:cleardevice();
Example:cleardevice();
18. Outtextxy
Purpose: outtextxy function is used to print the text on the screen in graphics
mode.
Syntax:outtext(x,y,text);
Example:-outtextxy(100,100,”HELLO”);
19. Sector
Purpose:sector function draws and fills an elliptical pie slice.
Syntax:sector(x, y, starting angle, ending angle, xradius, yradius);
Example:sector(100,100,45 135 100 50);
20. Arc
Purpose:arc draws the arc on the screen, arc is a part of the circle
Syntax:arc(x, y, starting angle, ending angle, radius);
Example:arc( 100,100,90,180,50);
21. Setfillstyle
Purpose: setfillstyle is used to set the color and style to be filled in the object
using the flood fill method.
UNIT-1
Syntax:stefillstyle(STYLE, COLOR);
Example:setfillstyle(1,RED)
22. Floodfill
Purpose:floodfill function is used to fill the color in the object, object may be
circle, rectangle or any other closed image.
Syntax:floodfill(x,y,boundary color);
Example:floodfill(100,100,BLUE);
23.Ellipse
Purpose:ellipse function is used to draw the ellipse on the screen.
Syntax:ellipse(x, y, starting angle, ending angle, xradius, yradius);
Example:ellipse(100,100,90,200,20,20);
24. Outtext
Purpose:outtext function is used to display the text on the screen, using this
function text is display in the current position.
Syntax:outtext(STRING);
Example:outtex(“HELLO”);
25. Getcolor
Purpose:getcolor returns the current drawing color.
Syntax:getcolor();
Example:intclr = getcolor();
26. Getpixel
Purpose:getpixel gets the color of a specified pixel.
Syntax:getpixel(x,y);
Example: color=getpixel(100,100);