Unit-1 CG

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

UNIT-1

Introduction of Computer Graphics


Computer Graphics involves technology to access. The Process transforms and presents
information in a visual form. The role of computer graphics insensible. In today life, computer
graphics has now become a common element in user interfaces, T.V. commercial motion
pictures.

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.

Application of Computer Graphics


1. Education and Training: Computer-generated model of the physical, financial and
economic system is often used as educational aids. Model of physical systems, physiological
system, population trends or equipment can help trainees to understand the operation of the
system.

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.

3. Computer-Generated Maps: Town planners and transportation engineers can use


computer-generated maps which display data useful to them in their planning work.

4. Architect: Architect can explore an alternative solution to design problems at an


interactive graphics terminal. In this way, they can test many more solutions that would not be
possible without the computer.
UNIT-1
5. Presentation Graphics: Example of presentation Graphics are bar charts, line graphs,
pie charts and other displays showing relationships between multiple parameters. Presentation
Graphics is commonly used to summarize

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.

8. Visualization: It is used for visualization of scientists, engineers, medical personnel,


business analysts for the study of a large amount of information.

9. Educational Software: Computer Graphics is used in the development of educational


software for making computer-aided instruction.

10. Printing Technology: Computer Graphics is used for printing technology and textile
design.

Overview of Computer Graphics What is computer Graphics?


Computer graphics is an art of drawing pictures, lines, charts, etc. using computers with the
help of programming. Computer graphics image is made up of number of pixels. Pixel is the
smallest addressable graphical unit represented on the computer screen.

Introduction

Computer is information processing machine. User needs to communicate with


computer and the computer graphics is one of the most effective and commonly used
ways of communication with the user. It displays the information in the form of
graphical objects such as pictures, charts, diagram and graphs. Graphical objects convey
more information in less time and easily understandable formats for example statically
graph shown in stock exchange. In computer graphics picture or graphics objects are
presented as a collection of discrete pixels. We can control intensity and color of pixel
UNIT-1
which decide how picture look like. The special procedure determines which pixel will
provide the best approximation to the desired picture or graphics object this process is
known as Rasterization. The process of representing continuous picture or graphics
object as a collection of discrete pixels is called Scan Conversion. Advantages of
computer graphics Computer graphics is one of the most effective and commonly used
ways of communication with computer. It provides tools for producing picture of “real-
world” as well as synthetic objects such as mathematical Surfaces in 4D and of data that
have no inherent geometry such as survey result. It has ability to show moving pictures
thus possible to produce animations with computer graphics. With the use of computer
graphics, we can control the animation by adjusting the speed, portion of picture in view
the amount of detail shown and so on. It provides tools called motion dynamics. In
which user can move objects as well as observes as per requirement for example walk
throw made by builder to show flat interior and surrounding. It provides facility called
update dynamics. With this we can change the shape color and other properties of
object. Now in recent development of digital signal processing and audio synthesis chip
the interactive graphics can now provide audio feedback along with the graphical feed
backs.

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:

1. Refresh Cathode Ray Tube


2. Random Scan and Raster Scan
3. Color CRT Monitors
4. Direct View Storage Tubes
5. Flat Panel Display
6. Lookup Table

Random Scan and Raster Scan Display:


Random Scan Display:
Random Scan System uses an electron beam which operates like a pencil to create a line image
on the CRT screen. The picture is constructed out of a sequence of straight-line segments. Each
line segment is drawn on the screen by directing the beam to move from one point on the screen
to the next, where its x & y coordinates define each point. After drawing the picture. The system
cycles back to the first line and design all the lines of the image 30 to 60 time each second. The
process is shown in fig:
UNIT-1

Random-scan monitors are also known as vector displays or stroke-writing displays or


calligraphic displays.

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:

1. Random-Scan monitors cannot display realistic shades scenes.

Raster Scan Display:


A Raster Scan Display is based on intensity control of pixels in the form of a rectangular box
called Raster on the screen. Information of on and off pixels is stored in refresh buffer or Frame
buffer. Televisions in our house are based on Raster Scan Method. The raster scan system can
store information of each pixel position, so it is suitable for realistic display of objects. Raster
Scan provides a refresh rate of 60 to 80 frames per second.

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

Differentiate between Random and Raster Scan Display:


Random Scan Raster Scan

1. It has high Resolution 1. Its resolution is low.

2. It is more expensive 2. It is less expensive

3. Any modification if needed is easy 3.Modification is tough

4. Solid pattern is tough to fill 4.Solid pattern is easy to fill

5. Refresh rate depends or resolution 5. Refresh rate does not depend on the picture.

6. Only screen with view on an area is displayed. 6. Whole screen is scanned.

7. Beam Penetration technology come under it. 7. Shadow mark technology came under this.

8. It does not use interlacing method. 8. It uses interlacing


UNIT-1

9. It is restricted to line drawing applications 9. It is suitable for realistic display.

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

Parts of Display Processor

1. Display File Memory


2. Display Processor
3. Display Generator
4. Display Console

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:

1. It is used for the generation of character.


2. It is used for the generation of curves.

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.

At the start of a Refresh Cycle:

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.

Cathode Ray Tube (CRT):


CRT stands for Cathode Ray Tube. CRT is a technology used in traditional computer monitors
and televisions. The image on CRT display is created by firing electrons from the back of the
tube of phosphorus located towards the front of the screen.
UNIT-1
Once the electron heats the phosphorus, they light up, and they are projected on a screen. The
color you view on the screen is produced by a blend of red, blue and green light.

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.

2. Control Electrode: It is used to turn the electron beam on and off.

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.

Color CRT Monitors:


The CRT Monitor display by using a combination of phosphors. The phosphors are different
colors. There are two popular approaches for producing color displays with a CRT are:

1. Beam Penetration Method


2. Shadow-Mask Method

1. Beam Penetration Method:

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.

o One phosphor dot emits: red light


o Another emits: green light
o Third emits: blue light

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

Working: Triad arrangement of red, green, and blue guns.

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

Flat Panel Display:


The Flat-Panel display refers to a class of video devices that have reduced volume, weight
and power requirement compare to CRT.

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).

Logical Classification of Input Devices


The Input Devices are the hardware that is used to transfer transfers input to the computer. The
data can be in the form of text, graphics, sound, and text. Output device display data from the
memory of the computer. Output can be text, numeric data, line, polygon, and other objects.

These Devices include:

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:

1. Alphanumeric Keyboards are used in CAD. (Computer Aided Drafting)


2. Keyboards are available with special features line screen co-ordinates entry, Menu
selection or graphics functions, etc.
3. Special purpose keyboards are available having buttons, dials, and switches. Dials are
used to enter scalar values. Dials also enter real numbers. Buttons and switches are used
to enter predefined function values.
UNIT-1
Advantage:
1. Suitable for entering numeric data.
2. Function keys are a fast and effective method of using commands, with fewer errors.

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

It is a pointing device. It is similar to a mouse. This is mainly used in notebook or laptop


computer, instead of a mouse. This is a ball which is half inserted, and by changing fingers on
the ball, the pointer can be moved.
UNIT-1
Advantage:
1. Trackball is stationary, so it does not require much space to use it.
2. Compact Size

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 Systems (Voice Recognition):

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.

What is Graphics Software?


Graphics software is a type of computer program that is used to create and edit
images. There is a wide range of graphics software available on the market,
ranging from simple programs that allow users to create and edit basic images,
to complex tools that can be used to create detailed 3D models and animations.
Some of the most popular graphics software programs include Adobe
Photoshop, Corel Painter, and Autodesk Maya.
UNIT-1
Characteristics:
 A graphics software program is a computer application used to create
digital images.
 Graphics software programs can be used to create both vector and
raster images.
 Common features of graphics software programs include the ability to
create, edit, and save images in a variety of formats.
 Some graphics software programs also offer features such as the
ability to create animations or 3D models.
 Popular examples of graphics software programs include Adobe
Photoshop, GIMP, and Inkscape.
Examples:
Some popular graphics software programs are Adobe Photoshop, Adobe
Illustrator, and CorelDRAW. These programs can be used to create and edit
digital images, illustrations, and logos. They offer a variety of features and tools
that allow users to manipulate photos and graphics to create custom designs.
 Adobe Photoshop is a popular graphics software used by
photographers and graphic designers.
 Adobe Illustrator is another popular graphics software used by
graphic designers, especially for creating vector illustrations.
 CorelDRAW is a graphics software used by both professionals and
hobbyists.
 GIMP is a free and open source graphics software with capabilities
similar to Photoshop.
 Inkscape is a free and open source vector graphics software used by
graphic designers and illustrators.

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.

COORDINATE REPRESENTATION IN COMPUTER GRAPHICS


Points are represented in the form of coordinates (x, y) in two- dimension with
respect to x- and y- axes. In three-dimensional space, the Cartesian coordinate
UNIT-1
system is based on three mutually perpendicular coordinate axes: the x-axis, the
y- axis, and the z-axis.
GRAPHICS FUNCTIONS
1. Putpixel
Purpose:-Putpixel function is to draw the pixel on the screen. Pixel is small dot
on the screen.
Syntax:-putpixel(x co-orinate, y co-ordinate,COLOR);
Example: – putpixel(100,100,BLUE);

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);

You might also like