Computer Graphics: Output Primitives
Computer Graphics: Output Primitives
Output Primitives
This Presentation has no copyrights.
Picture descriptions:
Raster:
Completely specified by the set of intensities for the pixels positions in the
display.
Shapes and colors are described with pixel arrays.
Scene displayed by loading pixels array into the frame buffer.
Vector:
Set of complex objects positioned at specified coordinates locations within
the scene.
Shapes and colors are described with sets of basic geometric structures.
Scene is displayed by scan converting the geometric-structure specifications
into pixel patterns.
Introduction:
Output Primitives:
Basic geometric structures used to describe scenes.
Can be grouped into more complex structures.
Each one is specified with input coordinate data and
other information about the way that object is to be
displayed.
Examples: point, line and circle each one with
specified coordinates.
Construct the vector picture.
Introduction:
In digital representation:
Display screen is divided into scan lines and columns.
Pixels positions are referenced according to scan line number
and column number (columns across scan lines).
Scan lines start from 0 at screen bottom, and columns start
from 0 at the screen left side.
Screen locations (or pixels) are referenced with integer values.
The frame buffer stores the intensities temporarily.
Video controller reads from the frame buffer and plots the
screen pixels.
Point Drawing
x
Point Drawing:
Converting a single coordinate position furnished by
an application program into appropriate operation for
the output device in use.
In raster system:
Black-white: setting the bit value corresponding to a
specified screen position within the frame buffer to 1.
RGB: loading the frame buffer with the color codes for the
intensities that are to be displayed at the screen pixel
positions.
Line Drawing Algorithms
y2
y1
x1 x2
Line Drawing:
X1 x2
Scan conversion process samples a
line at discrete positions and determine Sampling along y axis
the nearest pixel to the line at each Y2
sampled position.
y1
X1 x2
Line Drawing Algorithms:
DDA
A scan-conversion line algorithm based on calculating either
y or x using line points calculating equations.
In each case, choosing the sample axis depends on the slop
value.
The unit step for the selected axis is 1.
The other axis is calculated depending on the first axis and
the slop m.
The next slides will show the different cases of the slop:
Line Drawing Algorithms:
DDA
Case 1:the slop is Positive and less than 1
Sample at unit x interval (x=1) and compute each successive
y value as :
y k+1= yk+ m
K takes integer values starting from 1,at the first point, and
increasing by 1 on each step until reaching the final endpoint.
The calculated y must be rounded to the nearest integer.
Example:
Describe the line segment which starts at (3,3) and ends at
(23,7).
Lines Drawing Algorithms: DDA
24
23
22
21
m= (7-3)/(23-3) 20
=4/20 19
18
=0.2 17
16
15
x=1 14
13
y=0.2 12
11
10
9
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Lines Drawing Algorithms: DDA
x y actual point pixel position 24
23
3 3 (3,3) (3,3) 22
4 3.2 (4,3.2) (4,3) 21
5 3.4 (5,3.4) (5,3) 20
6 3.6 (6,3.6) (6,4) 19
18
7 3.8 (7,3.8) (7,4) 17
8 4 (8,4) (8,4) 16
9 4.2 (9,4.2) (9,4) 15
10 4.4 (10,4.4) (10,4) 14
13
11 4.6 (11,4.6) (11,5) 12
12 4.8 (12,4.8) (12,5) 11
13 5 (13,5) (13,5) 10
9
14 5.2 (14,5.2) (14,5) 8
15 5.4 (15,5.4) (15,5) 7
16 5.6 (16,5.6) (16,6) 6
17 5.8 (17,5.8) (17,6) 5
4
.. .. .. .. 3
.. .. .. .. 2
22 6.8 (22,6.8) (22,7) 1
23 7 (23,7) (23,7) 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms:
DDA
Case 2:the slop is Positive and greater than 1
Sample at unit y interval (y=1) and compute each successive
y value as :
x k+1= xk+ (1/m)
K takes integer values starting from 1,at the first point, and
increasing by 1 on each step until reaching the final endpoint.
The calculated x must be rounded to the nearest integer.
Example:
Describe the line segment which starts at (3,3) and ends at
(7,23).
Line Drawing Algorithms: DDA
24
23
22
m= (23-3)/(7-3) 21
20
= 20/4 19
=5 18
17
16
15
x =1/m 14
=1/5 13
12
=0.2 11
10
9
y =1 8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms: DDA
y x actual point pixel position 24
23
3 3 (3,3) (3,3) 22
4 3.2 (3.2,4) (3,4) 21
5 3.4 (3.4,5) (3,5) 20
6 3.6 (3.6,6) (4,6) 19
18
7 3.8 (3.8,7) (4,7) 17
8 4 (4,8) (4,8) 16
9 4.2 (4.2,9) (4,9) 15
10 4.4 (4.4,10) (4,10) 14
13
11 4.6 (4.6,11) (5,11) 12
12 4.8 (4.8,12) (5,12) 11
13 5 (5,13) (5,13) 10
9
14 5.2 (5.2,14) (5,14) 8
15 5.4 (5.4,15) (5,15) 7
16 5.6 (5.6,16) (6,16) 6
17 5.8 (5.8,17) (6,17) 5
4
.. .. .. .. 3
.. .. .. .. 2
22 6.8 (6.8,22) (7,22) 1
23 7 (7,23) (7,23) 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms:
DDA
Case 3:the slop is negative and its absolute value is less than 1
Follow the same way in case 1.
Case 4:the slop is negative and its absolute value is greater than 1
Follow the same way in case 2.
In the previous 4 cases, we start from the left to the right. If
the state is reversed then:
If the absolute slop is less than 1, set x=-1 and
y k+1= yk - m
If the absolute slop is greater than 1, set y=-1 and
x k+1= xk - (1/m)
Line Drawing Algorithms:
DDA properties
A faster method for calculating pixel positions than the direct
use: y= m . x +b.
Uses x or y to eliminate the multiplication in the above
equation.
Rounding successive additions of the floating-point
increment can cause the calculated pixel positions to drift
away from the true line path for long line segment.
Rounding and floating-point arithmetic are time-consuming
operations.
Line Drawing Algorithms:
Mid-point Algorithm
(xc, yc )
r (x, y)
Standard Algorithm:
x,y
r
Ө
Symmetry Algorithm:
ry
F2 rx F1
d2 d1
P=(x,y)
Ellipse Properties:
An elongated circle.
A set of points having an equal sum distances from two
fixed positions (foci F1,F2).
d1+d2=constant
The major axis is the straight line segment extending from
one side of the ellipse to the other through the foci.
The minor axis spans the shorter dimension of the ellipse,
bisecting the major axis at the halfway position (ellipse
center) between the two foci.
The two foci and point coordinates on the circumference
are enough information to plot an ellipse with arbitrary
orientation.
Ellipse Properties:
The equation of the ellipse can be written in terms of the
ellipse center coordinates and parameters rx, and ry, as:
Scan line
Filled Area Primitives:
Scan line
Filled Area Primitives:
Scan line
Inside-Outside Tests:
Odd-even (odd parity or even odd) rule:
Drawing a line from any position P to a distant
point outside the coordinate extents of the object.
Counting the number of edge crossings along the
line.
If the number of polygon edges crossed by this
line is odd, then P is an interior point, otherwise it
is an exterior point.
The line chosen must not intersect the polygon
vertices.
Inside-Outside Tests:
Non-zero winding number rule:
Counts the number of times the polygon edges wind around
a particular point in the counterclockwise direction, which is
called “winding number”.
Interior points of a two-dimensional object are defined to be
those that have a nonzero value for the winding number.
Counting method:
Start winding number with 0.
Imagine a line passing across the object and not intersect vertices.
Add 1 to winding number when the line is crossed by an edge
from right to left.
Subtract 1 from winding number when the line is crossed by an
edge from left to right.
To determine the direction use either cross product or dot product.
Inside-Outside Tests:
Scan-Line Fill of Curved Boundary Areas :
Serif group:
Has small lines or accents at the ends of the main
character strokes.
More readable.
Sans serif group:
Does not have accents.
The individual characters easier to recognize.
More legible, and hence, good for labeling and
short headings.
Character Generation Methods:
Bitmapped Font:
Uses rectangular grid patterns.
The simplest to define and display, the character grid
only needs to be mapped to a frame-buffer position.
Need more space, each variation (size and format)
must be stored in a font cache.
Outline Font:
Uses straight-line and curve sections.
Require less storage since each variation does not
require a distinct font cache.
Need more time since to the scan conversion process.
Character Generation Methods: