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: The Polygon Primeval</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: The Polygon Primeval</title>
<meta name="chapter" content="38" />
<meta name="pages" content="707-712" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head>
<body>
@ -37,10 +30,10 @@
<p><br /></p>
<h2><a id="Heading1"></a>Chapter 38<br />
<h2 id="Heading1">Chapter 38<br />
The Polygon Primeval</h2>
<h3><a id="Heading2"></a>Drawing Polygons Efficiently and Quickly</h3>
<h3 id="Heading2">Drawing Polygons Efficiently and Quickly</h3>
<p><i>&ldquo;Give me but one firm spot on which to stand, and I will move the Earth.&rdquo;</i></p>
@ -52,7 +45,7 @@
<p>And slow computer graphics is scarcely worth the bother.</p>
<h3><a id="Heading3"></a>Filled Polygons</h3>
<h3 id="Heading3">Filled Polygons</h3>
<p>A polygon is simply a shape formed by lines laid end to end to form a continuous, closed path. A polygon is filled by setting all pixels within the polygon&rsquo;s boundaries to a color or pattern. For now, we&rsquo;ll work only with polygons filled with solid colors.</p>
@ -62,13 +55,12 @@
<p>Why bother to distinguish between convex, nonconvex, and complex polygons? Easy: performance, especially when it comes to filling convex polygons. We&rsquo;re going to start with filled convex polygons; they&rsquo;re widely useful and will serve well to introduce some of the subtler complexities of polygon drawing, not the least of which is the slippery concept of &ldquo;inside.&rdquo;</p>
<h4 align="left"><a id="Heading4"></a>Which Side Is Inside?</h4>
<h4 align="left" id="Heading4">Which Side Is Inside?</h4>
<p>The basic principle of polygon filling is decomposing each polygon into a series of horizontal lines, one for each horizontal row of pixels, or scan line, within the polygon (a process I&rsquo;ll call <i>scan conversion</i>), and drawing the horizontal lines. I&rsquo;ll refer to the entire process as rasterization. Rasterization of convex polygons is easily done by starting at the top of the polygon and tracing down the left and right sides, one scan line (one vertical pixel) at a time, filling the extent between the two edges on each scan line, until the bottom of the polygon is reached. At first glance, rasterization does not seem to be particularly complicated, although it should be apparent that this simple approach is inadequate for nonconvex polygons.</p>
<p><a id="Fig1"><!-- </A><A HREF="javascript:displayWindow('images/38-01.jpg',407,116 )"> --><img src="images/38-01.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/38-01.jpg',407,116)"> --><b>Figure 38.1</b></a>&nbsp;&nbsp;<i>Convex, nonconvex, and complex polygons.</i></p>
<p><a id="Fig1"><img src="images/38-01.jpg" /><br />
<b>Figure 38.1</b></a>&nbsp;&nbsp;<i>Convex, nonconvex, and complex polygons.</i></p>
<p>There are a couple of complications, however. The lesser complication is how to rasterize the polygon efficiently, given that it&rsquo;s difficult to write fast code that simultaneously traces two edges and fills the space between them. The solution is to decouple the process of scan-converting the polygon into a list of horizontal lines from that of drawing the horizontal lines. One device-independent routine can trace along the two edges and build a list of the beginning and end coordinates of the polygon on each raster line. Then a second, device-specific, routine can draw from the list after the entire polygon has been scanned. We&rsquo;ll see this in action shortly.</p>
@ -76,9 +68,8 @@
<p>It&rsquo;s no crime to use standard lines to trace out a polygon, rather than drawing only interior pixels. In fact, there are certain advantages: For example, the edges of a filled polygon will match the edges of the same polygon drawn unfilled. Such polygons will look pretty much as they&rsquo;re supposed to, and all drawing on raster displays is, after all, only an approximation of an ideal.</p>
<p><a id="Fig2"><!-- </A><A HREF="javascript:displayWindow('images/38-02.jpg',412,188 )"> --><img src="images/38-02.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/38-02.jpg',412,188)"> --><b>Figure 38.2</b></a>&nbsp;&nbsp;<i>Drawing polygons with standard line-drawing algorithms.</i></p>
<p><a id="Fig2"><img src="images/38-02.jpg" /><br />
<b>Figure 38.2</b></a>&nbsp;&nbsp;<i>Drawing polygons with standard line-drawing algorithms.</i></p>
<p>There&rsquo;s one great drawback to tracing polygons with standard lines, however: Adjacent polygons won&rsquo;t fit together properly, as shown in Figure 38.3. If you use six equilateral triangles to make a hexagon, for example, the edges of the triangles will overlap when traced with standard lines, and more recently drawn triangles will wipe out portions of their predecessors. Worse still, odd color effects will show up along the polygon boundaries if XOR drawing is used. Consequently, filling out to the boundary lines just won&rsquo;t do for drawing images composed of fitted-together polygons. And because fitting polygons together is exactly what I have in mind, we need a different approach.</p>
@ -99,10 +90,6 @@
<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>