public StrokeGenerator()
 {
     m_stroker          = new StrokeMath();
     vertexDistanceList = new VertexDistanceList();
     m_out_vertices     = new VertexStore();
     m_status           = StrokeMath.Status.Init;
 }
Exemple #2
0
        //-------------------------------------------------------calc_polygon_area
        public static double CalculatePolygonArea(VertexDistanceList st)
        {
            int    i;
            double sum = 0.0;
            double x   = st[0].x;
            double y   = st[0].y;
            double xs  = x;
            double ys  = y;
            int    j   = st.Count;

            for (i = 1; i < j; i++)
            {
                VertexDistance v = st[i];
                sum += x * v.y - y * v.x;
                x    = v.x;
                y    = v.y;
            }
            return((sum + x * ys - y * xs) * 0.5);
        }
 public static void ShortenPath(VertexDistanceList vertexDistanceList, double s, bool closed)
 {
     if (s > 0.0 && vertexDistanceList.Count > 1)
     {
         double d;
         int    n = (int)(vertexDistanceList.Count - 2);
         while (n != 0)
         {
             d = vertexDistanceList[n].dist;
             if (d > s)
             {
                 break;
             }
             vertexDistanceList.RemoveLast();
             s -= d;
             --n;
         }
         if (vertexDistanceList.Count < 2)
         {
             vertexDistanceList.Clear();
         }
         else
         {
             n = (int)vertexDistanceList.Count - 1;
             VertexDistance prev = vertexDistanceList[n - 1];
             VertexDistance last = vertexDistanceList[n];
             d = (prev.dist - s) / prev.dist;
             double x = prev.x + (last.x - prev.x) * d;
             double y = prev.y + (last.y - prev.y) * d;
             last.x = x;
             last.y = y;
             if (!prev.IsEqual(last))
             {
                 vertexDistanceList.RemoveLast();
             }
             vertexDistanceList.Close(closed);
         }
     }
 }