Strip comments and inline ids onto h*

This commit is contained in:
James Gregory 2013-12-30 15:11:04 +11:00
commit 0f5f617adb
362 changed files with 2519 additions and 6694 deletions

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Wu'ed in Haste; Fried, Stewed at Leisure</title><!-- HEADER -->
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Wu'ed in Haste; Fried, Stewed at Leisure</title>
<meta name="chapter" content="42" />
<meta name="pages" content="778-781" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head>
<body>
@ -37,7 +30,7 @@
<p><br /></p>
<h3><a id="Heading4"></a>Tracing and Intensity in One</h3>
<h3 id="Heading4">Tracing and Intensity in One</h3>
<p>Horizontal, vertical, and diagonal lines do not require Wu antialiasing because they pass through the center of every pixel they meet; such lines can be drawn with fast, special-case code. For all other cases, Wu lines are traced out one step at a time along the major axis by means of 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 &ldquo;error adjust,&rdquo; 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, because the line intersects its endpoints exactly.</p>
@ -45,13 +38,12 @@
<p>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&rsquo;s a potentially time-consuming operation. Let&rsquo;s assume, however, that the number of possible intensity levels to be used for weighting is the value NumLevels = 2<sup>n</sup> for some integer n, with the minimum weighting (0 percent intensity) being the value 2<sup>n</sup> -1, and the maximum weighting (100 percent intensity) being the value 0. Given that, lo and behold, the most significant n bits of the error accumulator select the proper intensity value for one element of the pixel pair, as shown in Figure 42.2. Better yet, 2<sup>n</sup>-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&rsquo;s value. All this works because what the error accumulator accumulates is precisely the ideal line&rsquo;s current distance between the two bracketing pixels.</p>
<p><a id="Fig2"><!-- </A><A HREF="javascript:displayWindow('images/42-02.jpg',406,198 )"> --><img src="images/42-02.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/42-02.jpg',406,198)"> --><b>Figure 42.2</b></a>&nbsp;&nbsp;<i>Wu intensity calculations.</i></p>
<p><a id="Fig2"><img src="images/42-02.jpg" /><br />
<b>Figure 42.2</b></a>&nbsp;&nbsp;<i>Wu intensity calculations.</i></p>
<p>The intensity calculations take longer to describe than they do to perform. All that&rsquo;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&rsquo;s value in order to generate the second pixel&rsquo;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 complexity, but Listing 42.6, an assembly implementation, shows that only 15 instructions are required per step along the major axis&mdash;and the number of instructions could be reduced to ten by special-casing and loop unrolling. Make no mistake about it, Wu antialiasing is fast.</p>
<p><b>LISTING 42.1 L42-1.C</b></p><!-- CODE //-->
<p><b>LISTING 42.1 L42-1.C</b></p>
<pre>
/* Function to draw an antialiased line from (X0,Y0) to (X1,Y1), using an
* antialiasing approach published by Xiaolin Wu in the July 1991 issue of
@ -187,7 +179,7 @@ void DrawWuLine(int X0, int Y0, int X1, int Y1, int BaseColor, int NumLevels,
and so needs no weighting */
DrawPixel(X1, Y1, BaseColor);
}
</pre><!-- END CODE //-->
</pre>
<p><br /></p>
@ -206,10 +198,6 @@ void DrawWuLine(int X0, int Y0, int X1, int Y1, int BaseColor, int NumLevels,
<div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</div>
</body>
</html>