title: Generating a beveled edge for a 2D polygon
body: <p>I'm trying to programmatically generate beveled edges for 2D polygons. For example, given an array of 4 vertices defining a square, I want to generate something like this:</p>
  
  <pre><code> _________
  |\ _____ /|
  | |     | |
  | |     | |
  | |_____| |
  |/_______\|
  </code></pre>
  
  <p>But computing the vertices of the inner shape is baffling me.</p>
  
  <p>Simply creating a copy of the original shape and scaling it down won't work in the general case. (Imagine trying to bevel an N-shaped polygon this way.)</p>
  
  <p>My algorithm so far involves analyzing adjacent edges (triples of vertices; e.g., the bottom-left, top-left, and top-right vertices of a square). From there, I need to find the angle between them, and then create a vertex somewhere along that angle, depending on how deep I want the bevel to be.</p>
  
  <p>And because I don't have much of a math background, that's where I'm stuck. How do I find that center angle? Or is there a much simpler way of attacking this problem?</p>