title: Draw parallel Line
body: <p>I have a set of points representing a line. It might be a closed shape or an open one.
  I need to draw a parallel line that goes besides the original one without any intersection.</p>
  
  <p>I have the following code to return the generated line. I have problems in the angles of the shape. Some point goes over the original line.</p>
  
  <p>My Code is:</p>
  
  <pre><code>PointF[] GetParrarel(PointF[] lst, double width, float distance)
  {
      List&lt;PointF&gt; final = new List&lt;PointF&gt;();
      width = width + distance;
  
      for (int i = 0; i &lt; lst.Length-1 ; i++)
      {
          int index = i;
          PointF current = lst[index];
          PointF next = lst[index + 1];
          double dx = next.X - current.X;
          double dy = next.Y - current.Y;
          PointF first = current;
          PointF second = next;
          if (dx &gt; 0)
          {
              if (dy == 0)
              {
                  first.Y += (float)width;
                  second.Y += (float)width;
              }
              first.X += (float)width;
              second.X += (float)width;
  
          }
          else if (dx &lt; 0)
          {
              if (dy == 0)
              {
                  first.Y -= (float)width;
                  second.Y -= (float)width;
              }
              first.X -= (float)width;
              second.X -= (float)width;                    
          }
          else //// X = 0 
          {
              if (dy &gt; 0)
              {
                  first.X -= (float)width;
                  second.X -= (float)width;
              }
              else if (dy &lt; 0)
              {
                  first.X += (float)width;
                  second.X += (float)width;                       
              }
              else
              {
                  continue;
              }
          }
          final.Add(first);
          final.Add(second);
      }
      return final.ToArray();
  }
  </code></pre>