CGR CH 1
CGR CH 1
Computer Graphics
As per MSBTE ‘I’ Scheme Syllabus
CGR-22318
Unit-I
Basics of Computer Graphics
Total Marks- 08
Contents:
1.1 Image and Objects, pixel and resolution, Text mode. Graphics mode. Basic Graphics
Pipeline, Bitmap and vector based Graphics, Application of Computer Graphics.
1.2 Display Devices: Raster scan Display, random scan display, Flat Panel Display, LED,
LCD Display, Plasma, Touch screen.
1.3 Output primitives: line, polygon, marker, text.
1.4 Graphics functions and standards
1.5 Latest trends in Computer Graphics: Virtual reality, Augmented reality.
For example, if an has M rows and N columns, then its resolution can be defined as
M X N.
Syntax: textbackground(color);
Example : int col = 4
textbackground(col);
It sets text’s background colour to red
10) moveto( ): It moves cursor to the location specified by int(x, y) co- ordinates.
Syntax: moveto(x, y);
11) outtextxy( ): (“sentence”)
OR
Outtextxy(x, y, “sentence”)
Where, x, y gives co-ordinates of a point where from to display text.
It displays text within quotation mark at specified position and with latest setcolour
style.
The real world objects are represented in world co-ordinates system. It is then
projected onto a view plane. The projection is done from the viewpoint of the
position of a camera or eye.
There is an associated camera co-ordinate system whose z axis specifies the view
direction when viewed from the viewpoint.
The infinite volume swept by the rays emerging from the viewpoint and passing
through the window is called as view volume or view pyramid. Clipping planes
(near and far) are used to limit the output of the object.
The mapping of an object to a graphic device requires the transformation of view
plane co- ordinates to physical device co –ordinates.
There are two steps involved in this process
o Step 1:- The window to a viewpoint transformation. The viewport is
basically a sub- rectangle of a fixed rectangle known as logical screen.
o Step 2:- The transformation of logical screen co- ordinates to physical
device co –ordinates.
Representation Transform to
of 3D world physical device
objects coordinates
8. Display devices:
Display device is a device used for presentation of information such as image or text
for visual purpose. i.e to display information.
8.1. Raster Scan Display:
In a raster scan system, the electron beam is swept across the screen, one row at a
time from top to bottom. As the electron beam moves across each row, the beam
intensity is turned on and off to create a pattern of illuminated spots.
Picture definition is stored in memory area called the Refresh Buffer or Frame
Buffer. This memory area holds the set of intensity values for all the screen points.
Stored intensity values are then retrieved from the refresh buffer and “painted” on the
screen one row (scan line) at a time as shown in the following illustration.
Each screen point is referred to as a pixel (picture element) or pel. At the end of
each scan line, the electron beam returns to the left side of the screen to begin
displaying the next scan line.
A touch screen may contain pictures or words that the user can touch to interact
with the device.
A touch has two main advantages
1. It allows users to interact directly with what is displayed.
2. It does not require the use of an intermediate device.
The three main technologies are explained below:
8.7.1. Resistive:
This screen has a thin metallic layer that is conductive and resistive, so that
touching results in a change in the electrical current sent to the controller.
8.7.2. Surface Acoustic Wave(SAW)
Ultrasonic waves pass over this screen. Touching it results in absorption of part of the
wave, registering the position of the touch, which is sent to the controller.
8.7.3. Capacitive
This screen is coated with an electrically charged material. Touching it causes a
change in capacitance, which allows the location to be determined and sent to
the controller.’
9. Output Primitives
Graphics primitives are the functions that we use to draw actual lines and the
characters that make up the picture. These functions provide convenient
method to application programmer for describing pictures.
9.1. Point: Plots a single pixel on screen.
Attributes: x, y, co-ordinate position, color.
Output-
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
int points[ ]= {320, 150, 420, 300, 250, 300, 320, 150 };
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
drawpoly(4, points);
getch( );
closegraph( );
return 0;
}
Output -
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
int gd= DETECT, gm;
initgraph(&gd, &gm, “C:\\Turboc3\BGI”);
circle(100, 100, 50);
setfillstyle(HATCH_FILL, RED); // set fill pattern and color
floodfill(100, 100, RED); // 100, 100 is just a point inside circle
getch( );
closegraph( );
}
Output-