Академический Документы
Профессиональный Документы
Культура Документы
Primitives
MUHAMMAD AMMAR SHAIKH
201-S14-006
Output Primitives
y2
y1
x1 x2 x
Digital Differential Analyzer
If (x 1)
y mx
y y m
K 1 k
Advantages
DDA algorithm is a faster method for calculating the pixel
positions than the direct use of line equation.
It eliminates multiplication by making use of raster
characteristics.
Disadvantages
DDA algorithm runs slowly because it requires real arithmetic
(floating point operations) and rounding operations
Bresenhams Line Algorithm
A highly efficient incremental
method for scan converting lines.
Using only incremental integer
calculation.
Bresenhams
Algorithm(cont.)
(for |m| < 1.0)
Input the two line end-points, storing the left end-point
in (x0, y0)
Plot the point (x0, y0)
Calculate the constants x, y, 2y, and (2y - 2x)
and get the first value for the decision parameter as:
p0 2y x
At each xk along the line, starting at k = 0, perform the
following test. If pk < 0, the next point to plot is
(xk+1, yk) and: pk 1 pk 2y
Bresenhams Algorithm
k pk (xk+1,yk+1) 19
18
0 6 (21,11)
17
1 2 (22,12)
2 -2 (23,12) 16
3 14 (24,13) 15
4 10 (25,14) 14
5 6 (26,15) 13
6 2 (27,16) 12
7 -2 (28,16)
11
8 14 (29,17)
10
9 10 (30,18)
20 21 22 23 24 25 26 27 28 29 30 31 32
2 2
i i i i
Example:
To see the mid-point (0 , r)
circle algorithm in action (0 , 10)
lets use it to draw a Pk
circle centred at (0,0 k (xk+1,yk+1) 2xk+1 2yk+1
/Po
0 -9 1 , 10 2 20
10
9 4 20
8
7
1 -6 2 , 10
6
5 2 -1 3 , 10 6 20
4
3
2 3 6 4,9 8 18
1
0
0 1 2 3 4 5 6 7 8 9 10 4 -3 5,9 10 18
5 8 6,8 12 16
5 7,7 14 14
6
Fill Area Algorithms
4-connected pixels
Types of Basic Filling Algorithms
2.Outline font
Bitmap font
Bitmap font (or bitmapped font):
A simple method for representing the
character shapes in a particular typeface is
to use rectangular grid pattern.
Bitmap font
The character grid only need to be
mapped to a frame buffer position.
Bitmap fonts required more space, because
each variation (size and format) must be
stored in a font cash.
Bold Italic
Outline Font
Graphic primitives such as lines and arcs are
used to define the outline of each character.
Require less storage since variation does not
require a distinct font cash.
Outline Font
We can produce boldface, italic, or
different size by manipulating the curve
definition for the character outlines.