Normal quotes
This commit is contained in:
parent
5e10794a24
commit
18011c595a
352 changed files with 6040 additions and 6040 deletions
16
42-02.md
16
42-02.md
|
|
@ -12,7 +12,7 @@ a simple, fixed-point algorithm. The move along the minor axis with
|
|||
respect to a one-pixel move along the major axis (the line slope for
|
||||
lines with slopes less than 1, 1/slope for lines with slopes greater
|
||||
than 1) is calculated with a single integer divide. This value, called
|
||||
the “error adjust,” is stored as a fixed-point fraction, in 0.16 format
|
||||
the "error adjust," is stored as a fixed-point fraction, in 0.16 format
|
||||
(that is, all bits are fractional, and the decimal point is just to the
|
||||
left of bit 15). An error accumulator, also in 0.16 format, is
|
||||
initialized to 0. Then the first pixel is drawn; no weighting is needed,
|
||||
|
|
@ -21,7 +21,7 @@ because the line intersects its endpoints exactly.
|
|||
Now the error adjust is added to the error accumulator. The error
|
||||
accumulator indicates how far between pixels the line has progressed
|
||||
along the minor axis at any given step; when the error accumulator turns
|
||||
over, it’s time to advance one pixel along the minor axis. At each step
|
||||
over, it's time to advance one pixel along the minor axis. At each step
|
||||
along the line, the major-axis coordinate advances by one pixel. The two
|
||||
bracketing pixels to draw are simply the two pixels nearest the line
|
||||
along the minor axis. For instance, if X is the current major-axis
|
||||
|
|
@ -36,7 +36,7 @@ So far, nothing special; but now we come to the true wonder of Wu
|
|||
antialiasing. We know which pair of pixels to draw at each step along
|
||||
the line, but we also need to generate the two proper intensities, which
|
||||
must be inversely proportional to distance from the ideal line and sum
|
||||
to 1, and that’s a potentially time-consuming operation. Let’s assume,
|
||||
to 1, and that's a potentially time-consuming operation. Let's assume,
|
||||
however, that the number of possible intensity levels to be used for
|
||||
weighting is the value NumLevels = 2^n^ for some integer n, with the
|
||||
minimum weighting (0 percent intensity) being the value 2^n^ -1, and the
|
||||
|
|
@ -47,18 +47,18 @@ shown in Figure 42.2. Better yet, 2^n^-1 minus the intensity of the
|
|||
first pixel selects the intensity of the other pixel in the pair,
|
||||
because the intensities of the two pixels must sum to 1; as it happens,
|
||||
this result can be obtained simply by flipping the n least-significant
|
||||
bits of the first pixel’s value. All this works because what the error
|
||||
accumulator accumulates is precisely the ideal line’s current distance
|
||||
bits of the first pixel's value. All this works because what the error
|
||||
accumulator accumulates is precisely the ideal line's current distance
|
||||
between the two bracketing pixels.
|
||||
|
||||
\
|
||||
**Figure 42.2** *Wu intensity calculations.*
|
||||
|
||||
The intensity calculations take longer to describe than they do to
|
||||
perform. All that’s involved is a shift of the error accumulator to
|
||||
perform. All that's involved is a shift of the error accumulator to
|
||||
right-justify the desired intensity weighting bits, and then an XOR to
|
||||
flip the least-significant n bits of the first pixel’s value in order to
|
||||
generate the second pixel’s value. Listing 42.1 illustrates just how
|
||||
flip the least-significant n bits of the first pixel's value in order to
|
||||
generate the second pixel's value. Listing 42.1 illustrates just how
|
||||
efficient Wu antialiasing is; the intensity calculations take only three
|
||||
statements, and the entire Wu line-drawing loop is only nine statements
|
||||
long. Of course, a single C statement can hide a great deal of
|
||||
|
|
|
|||
Loading…
Reference in a new issue