title: How do I render thick 2D lines as polygons?
body: <p>I have a path made up of a list of 2D points. I want to turn these into a strip of triangles in order to render a textured line with a specified thickness (and other such things). So essentially the list of 2D points need to become a list of vertices specifying the outline of a polygon that if rendered would render the line. The problem is handling the corner joins, miters, caps etc. The resulting polygon needs to be &quot;perfect&quot; in the sense of no overdraw, clean joins, etc. so that it could feasibly be extruded or otherwise toyed with.</p>
  <p>Are there any <em>simple</em> resources around that can provide algorithm insight, code or any more information on doing this efficiently?</p>
  <p>I absolutely DO NOT want a full fledged 2D vector library (cairo, antigrain, OpenVG, etc.) with curves, arcs, dashes and all the bells and whistles. I've been digging in multiple source trees for OpenVG implementations and other things to find some insight, but it's all terribly convoluted.</p>
  <p>I'm definitely willing to code it myself, but there are many degenerate cases (small segments + thick widths + sharp corners) that create all kinds of join issues. Even a little help would save me hours of trying to deal with them all.</p>
  <p>EDIT: Here's an example of one of those degenerate cases that causes ugliness if you were simply to go from vertex to vertex. Red is the original path. The orange blocks are rectangles drawn at a specified width aligned and centered on each segment.</p>
  <p><a href="https://i.stack.imgur.com/MfYJs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MfYJs.png" alt="" /></a></p>