Professional Documents
Culture Documents
Lecture 2 (Output Primitives)
Lecture 2 (Output Primitives)
• Point plotting
• Line-drawing Algorithms
• Circle-generating Algorithms
• Filled-area Primitives
Points and Lines
• Point plotting
– Random Scan: deflection voltages position the electron beam at
the screen locations to be plotted during each refresh cycle
– Raster Scan: set the bit value corresponding to a specified screen
position within the frame buffer to 1
• Line drawing
– Calculating intermediate positions along the line path between two
specified endpoint positions
Scan Converting Lines
dx = x2 - x1;
dy = y2 - y1;
m = dy / dx;
y = y1 + 0.5;
dx = x2 - x1;
dy = y2 - y1;
d = 2 * dy - dx;
incE = 2 * dy;
incNE = 2 * (dy - dx);
y = y1;
4,5
Hence, left and bottom
edges will be drawn,
but pixels on top and
right edges will not be
drawn
0,0
Filling Rectangles
• Polygon Types:
– Convex
• Horizontally convex
– Concave - A type of polygon that has one or more interior angles
greater than 180 degrees
Why Polygons?
• For the third case, we count the ymin vertex of an edge in the
parity calculation, but not the ymax vertex
– Therefore a ymax vertex is drawn only if it is the ymin vertex for the
adjacent edge (consider vertex A)
– Thus edges are treated as intervals (closed at ymin and open at
ymax)
Span Filling
• Rules:
– Don’t consider the vertex contribution for the horizontal edge
– Invert the parity if the vertex is a ymin of some edge
– Do not invert if the vertex is a ymax of some edge
Example