Chapter Three: Output Primitives
Chapter Three: Output Primitives
Chapter Three: Output Primitives
Part II
Output Primitives
CS 380 CH 3-P2 - 1
Outline
CS 380 CH 3-P2 - 2
Setting frame-buffer values
• Pixels are labeled from (0, 0) the lower left corner to (xmax,ymax)
the top right corner.
CS 380 CH 3-P2 - 3
Row by Row mapping
CS 380 CH 3-P2 - 4
Setting frame-buffer values (cont.)
2. addr(x + 1, y) = addr(x, y) + 1
CS 380 CH 3-P2 - 5
Setting frame-buffer values (cont.)
• Example:
Find the address of the pixel (6,5), where the address of (0,0) =500,
xmax=12, and ymax = 10.
CS 380 CH 3-P2 - 6
Pixel addressing and object geometry
• So, the displayed image may not correspond exactly with the
relative dimensions of the input object.
CS 380 CH 3-P2 - 7
Pixel addressing and object geometry (cont.)
CS 380 CH 3-P2 - 8
Pixel addressing and object geometry (cont.)
An alternative to addressing
display positions in terms of
pixel centers is to reference
screen coordinates with
respect to the grid of
horizontal and vertical pixel
boundary lines spaced one
unit a part.
CS 380 CH 3-P2 - 9
Pixel addressing and object geometry (cont.)
• Screen coordinate
position is then the pair of
integer values identifying
a grid intersection position
between two pixels.
CS 380 CH 3-P2 - 10
Pixel addressing and object geometry (cont.)
CS 380 CH 3-P2 - 11
Pixel addressing and object geometry (cont.)
CS 380 CH 3-P2 - 12
Pixel addressing and object geometry (cont.)
Notes:
CS 380 CH 3-P2 - 13
Pixel addressing and object geometry (cont.)
A circle of radius 5 and center position (10, 10), for instance, would
be displayed by the midpoint circle algorithm using screen grid
coordinate positions.
But the plotted circle has a diameter of 11, To plot the circle with the
defined diameter of 10, we can modify the circle algorithm to
shorten each pixel scan line and each pixel column.
CS 380 CH 3-P2 - 14
Pixel addressing and object geometry (cont.)
CS 380 CH 3-P2 - 15
Pixel addressing and object geometry (cont.)
CS 380 CH 3-P2 - 16
Filled- Area Primitives
2. Filling approaches
start from a given interior position and paint outward from this point
until we encounter the specified boundary conditions.
useful with more complex boundaries and in interactive painting
systems.
CS 380 CH 3-P2 - 17
Filled- Area Primitives (cont.)
CS 380 CH 3-P2 - 18
Filled- Area Primitives (cont.)
CS 380 CH 3-P2 - 19
Filled- Area Primitives (cont.)
CS 380 CH 3-P2 - 20
Inside-Outside Tests
1. Odd-Even rule
2. Nonzero winding number rule
CS 380 CH 3-P2 - 21
Inside-Outside Tests
CS 380 CH 3-P2 - 22
Inside-Outside Tests
CS 380 CH 3-P2 - 23
Inside-Outside Tests
CS 380 CH 3-P2 - 24
CH 3-P2 - 25
Boundary-Fill Algorithm
Start at a point inside a region and paint the interior
outward toward the boundary. If the boundary is
specified in a single color, the fill algorithm proceeds
outward pixel by pixel until the boundary color is
encountered.
CS 380 CH 3-P2 - 26
Boundary-Fill Algorithm (cont.)
CS 380 CH 3-P2 - 27
Boundary-Fill Algorithm (cont.)
1. The 4-connected
method.
2. The 8-connected
method.
CS 380 CH 3-P2 - 28
Boundary-Fill Algorithm (cont.)
CS 380 CH 3-P2 - 29
Boundary-Fill Algorithm (cont.)
CS 380 CH 3-P2 - 30
Boundary-Fill Algorithm (cont.)
CS 380 CH 3-P2 - 31
Pixel Span Method
CS 380 CH 3-P2 - 32
Pixel Span Method (cont.)
CS 380 CH 3-P2 - 33
Pixel Span Method (cont.)
CS 380 CH 3-P2 - 34
Flood-Fill Algorithm
CS 380 CH 3-P2 - 35
Flood-Fill Algorithm (cont.)
We start from a specified interior point (x, y) and reassign all pixel
values that are currently set to a given interior color with the desired
fill color.
If the area we want to paint has more than one interior color, we can
first reassign pixel values so that all interior points have the same
color. Using either a 4-connected or 8-connected approach, we then
step through pixel positions until all interior points have been
repainted.
CS 380 CH 3-P2 - 36
Flood-Fill Algorithm (cont.)
CS 380 CH 3-P2 - 37