Nothing Special   »   [go: up one dir, main page]

Computer Graphics Unit 3

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

BCA IV Unit 3

Computer Graphics

Graphics Primitives

A graphics primitive refers to the basic geometric shapes or elements used in computer graphics to
create more complex images. These primitives serve as the building blocks for rendering graphical
objects on a screen or digital canvas. Examples of graphics primitives include points, lines, curves,
polygons, and text.

Here's a brief overview of some common graphics primitives along with examples:

1. Point:
- Definition: A single position in space defined by its coordinates (x, y).
- Example: A single pixel on a computer screen represents a point.

2. Line:
- Definition: A straight path connecting two points.
- Example: Drawing a line segment from (x1, y1) to (x2, y2) on a screen.

3. Curve:
- Definition: A smooth or segmented path defined by mathematical equations or control points.
- Example: A quadratic or cubic Bézier curve used in vector graphics applications.

4. Polygon:
- Definition: A closed shape formed by connecting multiple points with straight lines.
- Example: A triangle, square, or any other n-sided polygon.

5. Circle:
- Definition: A closed curve where all points are equidistant from a central point.
- Example: Drawing a circle with a specified radius centered at (x, y) on a screen.

6. Rectangle:
- Definition: A four-sided polygon with opposite sides being equal and parallel, and all angles being
right angles.
- Example: Drawing a rectangle with specified width and height at a given position.

7. Text:
- Definition: Characters or symbols displayed on a screen or canvas to convey information.
- Example: Rendering text strings using fonts and styles to display messages or labels.

These graphics primitives provide the foundation for creating complex images, illustrations, and user
interfaces in various applications, including computer-aided design (CAD), video games, animation,
data visualization, and graphical user interfaces (GUIs). By combining and manipulating these
primitives, developers and designers can create visually compelling graphics to convey information,
engage users, and enhance the user experience in digital environments.

Primitive Operations

In computer graphics, primitive operations refer to basic operations or functions used


to manipulate graphical primitives, such as points, lines, and polygons, to generate
visual content. These operations are typically performed at a low level and form the
foundation for rendering complex images on a screen. Here are some common
primitive operations in computer graphics:

TS 1
BCA IV Unit 3
Computer Graphics

· Point Plotting- Placing a single pixel (point) at a specified location on the screen. This
operation is fundamental for drawing individual points or creating raster
graphics.Displaying individual points in a 2D or 3D space using specific colors or attributes.
· Line Drawing - Connecting two points to create a line segment, often utilized to depict object
outlines or boundaries. Generating straight lines between two points on the screen.
Algorithms like Bresenham's line algorithm or DDA (Digital Differential Analyzer)
are commonly used for line drawing.
· Polygon Filling - Coloring enclosed regions formed by interconnected vertices (points), commonly
employed to generate solid faces or areas of 3D objects. Filling the interior of a polygon with a
solid color or pattern. Various algorithms, such as scanline filling or flood fill, can be
used for polygon filling.
· Curve Generation - Creating mathematically defined curves, either parametrically or implicitly,
allowing representation of smoother and more organic shapes than polygons alone. Examples include
Bezier curves and B-spline curves. Drawing circles or circular arcs on the screen.
Algorithms like midpoint circle algorithm or Bresenham's circle algorithm are used
for efficient circle drawing.
· Transformations - Transforming graphical primitives by applying translation
(movement), rotation, scaling (resizing), or shearing transformations. These
operations are essential for positioning and orienting objects in a scene.Transformations
allow for animation, movement, and perspective changes in 3D scenes.
· Clipping - Before rendering, primitives may need to be clipped against the view frustum (the portion
of 3D space visible through the camera lens) to remove any parts that fall outside of it. Clipping
ensures that only relevant information is processed and displayed. Removing portions of
graphical primitives that lie outside the visible region of the screen or viewport.
Clipping ensures that only the visible parts of objects are rendered.

The Display File Interpreter

The term "display file interpreter" typically refers to a software module responsible
for translating high-level drawing commands into low-level graphics primitives that
can be rendered on a display device.

In computer graphics, the display file interpreter is often part of a larger graphics
library or framework that provides a set of abstractions for creating and manipulating
graphical objects.

The display file provides a set of instructions and data definitions, while the display
file interpreter executes those instructions and applies those definitions to produce
a visual representation of the data.

TS 2
BCA IV Unit 3
Computer Graphics

Display files contain formatting information and instructions for presenting data to
end users via terminal emulators or green-screen terminals. They are often
associated with older business applications running on mainframes or midrange
computers.

Display files consist of lines of code written in a special language called DDS
(Display Data Specification). Each line specifies the attributes of a single field on
the screen, including things like length, position, font style, foreground and
background colors, and validation rules. Additionally, display files can include
logic statements, conditional branching, and subroutines that determine how the
application responds to user inputs.

When a user runs an application that uses a display file, the system generates a
dynamic screen image based on the contents of the file. The screen appears as a
fixed grid of character cells, arranged in rows and columns. Users can navigate
between fields using arrow keys or function keys, enter or modify data, and initiate
actions like submitting forms or executing reports.

Display Processor

Display Processor is a part of computer graphics which is used to convert the code
into pictures. In other words, we can say that the Display Processor is used to convert
the digital information or the digital signal into analog. Hence, the display Processor
in simple terms can also be called digital to analog converter. The conversion in the
Display Processors depends on the types of devices and the functions used for
graphical representations.

The main purpose of the Display Processor is scan conversion. Scan Conversion is a
process of displaying different graphics objects as a collection of pixels. In this
process, we have to differentiate graphics objects a collection of different
mathematical shapes like ellipse, rectangle, and polygons. It is also called Display
Processing Unit, DPU in short.

There are 4 major parts of the Display Processor

1. Display File Memory


2. Display Controller
3. Display Generator
4. Display Console

TS 3
BCA IV Unit 3
Computer Graphics

1. Display File Memory

It is used to display the pictures on the screen. The Display File Memory identifies the
different graphics objects or entities. All the pixel values that are to be showed on the
screen are there in the display File memory.

2. Display Controller

The Display Controller handles the flow instructions in the display processor. It is
responsible for handling the interrupt and to maintain the timings between their
executions. Interpretation of the instructions is also performed by the Display
Controller.

3. Display Generator

Display Generator is used to generate characters and shapes on the screen. This
displays the shapes and characters according to the input we give in it. In short, the
Display Generator is used for generating curves and characters on the screen.

4. Display Console

Display Console is a combination of a display device and an input device. This is the
part of the Display Processor which shows the output on the screen. The Cathode Ray
Tube comes under the Display Console. In common terms, the display console is the
screen on which you see all your graphical outputs.

TS 4
BCA IV Unit 3
Computer Graphics

Normalized Device Coordinates

We need to use a device independent coordinate system called (NCD) to describe the viewport. This
device (NCD) better than using the coordinate of the display screen to describe the viewport.
The (NCD) system allows the application programmer to write graphics programs independent of the
resolution of the display screen.

Normalized Device Coordinates make it easier to reason about rendering operations


without worrying about the specifics of the output display resolution or aspect ratio.

Display - File Structure

Picture definition is stored as a set of line-drawing commands in an area of memory


referred to as the refresh display file. To display a specified picture, the system cycles
through the set of commands in the display file, drawing each component line in turn.
After all the line-drawing commands are processed, the system cycles back to the first
line command in the list.

A display file is a data structure that stores the information needed to generate an
output image on a display device. The display file can be either a list of graphics
commands or a set of uncorrelated data, such as an array or a matrix. The display file
is processed by a display processor, which is a specialized hardware or software
component that executes the graphics commands or interprets the data to produce the
image. Display files can be used for both two-dimensional and three-dimensional
graphics, and can have different levels of complexity and flexibility depending on the
application and the display device.

In Computer Graphics, especially in terms of legacy systems, a display file doesn't


necessarily relate to graphics itself, but instead represents a file format used to store
textual data describing the layout and presentation of information on a text-mode
screen, primarily used in mainframe systems.

That being said, here's an overall structure of a typical display file:

1. Header Information: Includes record format, version, and other administrative


details required to identify and manage the display file properly.
2. Input Field Definitions: Describes the various input fields available for user entry,
including their characteristics, such as maximum length, default values, and validation
rules.
3. Output Field Definitions: Represents the various output fields shown on the screen,
specifying aspects such as label, position, justification, and protection (read-only vs.
writable).
4. Menu Structure: Organizes the menu options available to users, detailing items,
their labels, priorities, and actions upon selection.
5. Logic Control Statements: Contains procedural code snippets controlling the
sequence of operations and decisions made throughout interactions with the user,

TS 5
BCA IV Unit 3
Computer Graphics

often implemented using Record Level Access (RLA) and Internal Subroutine (ISR)
concepts.
6. Keyboard Maps: Assigns functionalities to specific key presses and combinations,
facilitating navigation and input management.
7. Color and Attribute Settings: Configures visual attributes like colors, blinking,
reverse video, and intensity for various parts of the screen.

While the above structure pertains mainly to legacy display files used in text-mode
applications, contemporary computer graphics tend to utilize advanced graphics
libraries and frameworks, shifting towards higher abstraction levels and decoupling
layout definition from event handling and processing. Nevertheless, knowing the
traditional display file structure remains useful for historical purposes and
maintenance of legacy systems.

POLYGON

A Polygon is a closed figure made up of line segments (not curves). Typically, a


polygon is defined by specifying its vertices—the points where the edges meet.

There are several ways to represent polygons mathematically or programmatically in


computer graphics. Some common representations include:

1. Vertex List Representation: In this basic format, a list of vertices defines the
corners of each polygon. Each vertex typically consists of XYZ coordinates in 3D
space, although it may also contain information about texture coordinates, normals, or
other attributes. For example, a triangle might be represented as follows: `[v0 = (x0,
y0, z0), v1 = (x1, y1, z1), v2 = (x2, y2, z2)]

2. Indexed Face Set Representation: To avoid redundancy when multiple faces share
vertices, indexed face sets use a single array to store all unique vertices and another
array to specify which indices should be connected to create individual faces. For
instance, if we have four vertices {(0,0,0), (0,1,0), (1,0,0), (1,1,0)} and want to define
two triangles sharing one edge, we could write: `vertices = [[0,0,0], [0,1,0], [1,0,0],
[1,1,0]]` and `faces = [[0, 1, 2], [1, 2, 3]]`, indicating that the first triangle has vertices
at index 0, 1, and 2 while the second triangle has vertices at indices 1, 2, and 3.

TS 6
BCA IV Unit 3
Computer Graphics

Attributes of output primitives

The features or characteristics of an output primitive are known as Attribute. In other


words, any parameter that affects the way a primitive is to be displayed is known as
Attribute. Some attributes, such as colour and size, are basic characteristics of
primitive. Some attributes control the basic display properties of primitives. For
example, lines can be dotted or dashed, thin or thick. Areas can be filled with one
colour or with multiple colours pattern. Text can appear from left to right, slanted or
vertical.

TS 7
BCA IV Unit 3
Computer Graphics

TS 8
BCA IV Unit 3
Computer Graphics

TS 9
BCA IV Unit 3
Computer Graphics

TS 10
BCA IV Unit 3
Computer Graphics

GRAYSCALE

With monitors that have no color capability, color functions can be


used in an application program to set the shades of gray, or
grayscale, for displayed primitives. Numeric values over the range
from 0 to 1 can be used to specify grayscale levels, which are then
converted to appropriate binary codes for storage in the raster. This
allows the intensity settings to be easily adapted to systems with
differing grayscale capabilities.

Table lists the specifications for intensity codes for a four-level


grayscale system. In this example, any intensity input value near
0.33 would be stored as the binary value 01 in the frame buffer, and
pixels with this value would be displayed as dark gray. If additional
bits per pixel are available in the frame buffer, the value of 0.33
would be mapped to the nearest level. With 3 bits per pixel, we can
accommodate 8 gray levels; while 8 bits per pixel would give us 256
shades of gray. An alternative scheme for storing the intensity
information is to convert each intensity code directly to the voltage
value that produces this grayscale level on the output device in use.

TS 11
BCA IV Unit 3
Computer Graphics

Area-Fill Attributes

TS 12
BCA IV Unit 3
Computer Graphics

Character Attributes

TS 13
BCA IV Unit 3
Computer Graphics

TS 14
BCA IV Unit 3
Computer Graphics

TS 15
BCA IV Unit 3
Computer Graphics

TS 16

You might also like