public VertexStore MakeVxs(VertexStore sourceVxs, VertexStore outputVxs) { StrokeGenerator strkgen = _strokeGen; int j = sourceVxs.Count; strkgen.Reset(); VertexCmd cmd; double x = 0, y = 0, startX = 0, startY = 0; for (int i = 0; i < j; ++i) { cmd = sourceVxs.GetVertex(i, out x, out y); switch (cmd) { case VertexCmd.NoMore: break; case VertexCmd.Close: if (i < j) { //close command strkgen.Close(); strkgen.WriteTo(outputVxs); strkgen.Reset(); } else { } break; case VertexCmd.CloseAndEndFigure: if (i < j) { //close command strkgen.Close(); strkgen.WriteTo(outputVxs); strkgen.Reset(); } else { } break; case VertexCmd.LineTo: case VertexCmd.P2c: //user must flatten the curve before do stroke case VertexCmd.P3c: //user must flatten the curve before do stroke strkgen.AddVertex(x, y, cmd); break; case VertexCmd.MoveTo: strkgen.AddVertex(x, y, cmd); startX = x; startY = y; break; default: throw new System.NotSupportedException(); } } strkgen.WriteTo(outputVxs); strkgen.Reset(); return(outputVxs); }
public VertexStore MakeVxs(VertexStore sourceVxs) { StrokeGenerator strkgen = strokeGen; VertexStore vxs = new VertexStore(); int j = sourceVxs.Count; double x, y; strkgen.RemoveAll(); //1st vertex sourceVxs.GetVertex(0, out x, out y); strkgen.AddVertex(x, y, VertexCmd.MoveTo); double startX = x, startY = y; bool hasMoreThanOnePart = false; for (int i = 0; i < j; ++i) { var cmd = sourceVxs.GetVertex(i, out x, out y); switch (cmd) { case VertexCmd.Stop: case VertexCmd.HasMore: { } break; case VertexCmd.EndFigure: case VertexCmd.EndAndCloseFigure: { strkgen.AddVertex(x, y, cmd); if (i < j - 2) { strkgen.AddVertex(startX, startY, VertexCmd.LineTo); strkgen.WriteTo(vxs); strkgen.RemoveAll(); hasMoreThanOnePart = true; } //end this polygon } break; case VertexCmd.LineTo: case VertexCmd.P2c: case VertexCmd.P3c: { strkgen.AddVertex(x, y, cmd); } break; case VertexCmd.MoveTo: { strkgen.AddVertex(x, y, cmd); startX = x; startY = y; } break; default: throw new System.NotSupportedException(); } } strkgen.WriteTo(vxs); strkgen.RemoveAll(); vxs.HasMoreThanOnePart = hasMoreThanOnePart; return(vxs); }