title: GraphicsPath.IsClockWise() Extension Method
body: <p>I need to create an extension method for a <code>GraphicsPath</code> object that determines if the <code>GraphicsPath</code> is wound clockwise or counter-clockwise.</p>
  
  <p>Something like this:</p>
  
  <pre><code>    public static bool IsClockwise(GraphicsPath gp)
      {
          bool bClockWise = false;
          PointF[] pts = gp.PathPoints;
  
          foreach (PointF pt in pts)
          {
              //??
          }
  
          return bClockWise;
      }
  </code></pre>
  
  <p>Note: I just assume that we'd need a <code>foreach</code> on the points in the <code>GraphicsPath</code> here, but if there is a better way, please feel free to offer.</p>
  
  <p>The reason for this is because the <code>FillMode</code> of the <code>GraphicsPath</code> determines if overlapping sections of adjacent GraphicsPaths are 'filled' (<code>Winding</code>) or 'holes' (<code>Alternate</code>).  However, this is only true if the adjacent GraphicsPaths are wound in the same direction.</p>
  
  <p><img src="https://i.stack.imgur.com/RFXiv.gif" alt="Fillmode Winding vs Alternate">  </p>
  
  <p>If the two paths are wound in opposing directions, even setting the <code>FillMode</code> to <code>Winding</code> results in the (unwanted) holes.</p>
  
  <p>Interestingly enough, the GraphicsPath DOES have a <code>.Reverse()</code> method that allows one to change the direction of the path (and this DOES solve the problem), but it is impossible to know WHEN the GraphicsPath needs to be .Reversed without knowing the direction of the path.</p>
  
  <p>Can you help out with this extension method?</p>