Output Primitives
Output Primitives
x x2 1
b y m x
1 1
y
y mx x
m
Scan Converting A Line
These equation form the basic for
determining deflection voltage in
analog devices.
y mx y
x
m
|m|<1 |m|>1
Scan Converting A Line
On raster system, lines are plotted
with pixels, and step size (horizontal
& vertical direction) are constrained
by pixel separation.
Scan Converting A Line
We must sample a line at discrete
positions and determine the
nearest pixel to the line at each
sampled position.
Digital Differential
Analyzer
(DDA Algorithm)
DDA Algorithm
Algorithm is an incremental scan
conversion method.
Based on calculating either x or y
If |m|<1,(x 1)
y mx
y y m
K 1 k
DDA Algorithm
If |m|>1, (y 1)
y
x
m
1
x x
m
K 1 k
If (x 1)
y mx
y K 1
y m
k
Bresenham’s Line
Algorithm
Bresenham’s Line Algorithm
A highly efficient incremental
method for scan converting lines.
Using only incremental integer
calculation.
By testing the sign of an
integer parameter, whose
value is proportional to the
difference between the
separation of two pixel
positions from the actual
line path.
Bresenham’s Line Algorithm
A highly efficient incremental
method for scan converting lines.
Using only incremental integer
calculation.
By testing the sign of an
integer parameter, whose
value is proportional to the
difference between the
separation of two pixel
positions from the actual
line path.
Bresenham’s Line Algorithm
Bresenham’s Line Algorithm
Bresenham’s Line Algorithm
yk+1
} d2
y
}d 1
yk
xk+1
Bresenham’s Line Algorithm
d1 = y - yk = m (xk + 1) + b - yk
d2 = (yk + 1) - y = yk + 1 - m (xk + 1) –b
d1 - d2 = 2 m (xk + 1) - 2 yk + 2b -1
Bresenham’s Line Algorithm
Pk = ΔX ( d1 - d2) =
2 ΔY . xk - 2 ΔX . yk + c
Pk+1 = Pk + 2ΔY
or
= Pk + 2(ΔY – ΔX(
0
P0=2ΔY -ΔX
Bresenham’s Line Algorithm
Example: Digitize the line with endpoint
(20,10) and (30,18) P0=2ΔY –ΔX
ΔX=10 ΔY=
Pk+1 =8Pk + 2ΔY
P0=2ΔY –Δx=6 or
2ΔY =16 = Pk + 2(ΔY – ΔX(
2(ΔY – ΔX)=-4
Circle Generation
Algorithms
Circle Generation Algorithms
The equation of a circle:
8 -Way symmetry
Midpoint Circle
Algorithm
Circle Generation Algorithms
As in the line algorithm, we sample at
unit intervals and determine the closet
pixel position to the circle path at each
step.
Circle Generation Algorithms
Points are generated from 90º to 45º, moves
will be made only in the +x and –y
direction.
positive x direction over this octant and use
a decision parameter
Circle Generation Algorithms
We define a circle function:
0
f circle
( x, y ) x y r 0
2 2 2
o
Circle Generation Algorithms
Midpoint 1
( x 1, y )
2
i i
Midpoint
Circle Generation Algorithms
2 2
i i i i
Circle Generation Algorithms
If pi 0 is negative, the midpoint
is inside the pixel, and we choose
pixel T.
If pi 0 we choose pixel S.
Circle Generation Algorithms
Parameter for the next step is:
1
p ( x 1) ( y ) r
2 2
2
i 1 i 1 i 1
since
x x 1
i 1 i
Circle Generation Algorithms
If T is chosen ( pi 0 ) we have:
If pixel S is chosen ( pi 0 ) we
have
Circle Generation Algorithms
In terms of
Circle Generation Algorithms
Initial value for the decision parameter using the
original function of (0,r(
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.