/// <summary> /// create contour(closed, open) from input flatten XYs,and put into output vxs /// </summary> /// <param name="flattenXYs"></param> /// <param name="vxs"></param> /// <param name="closedContour"></param> /// <returns></returns> public static VxsContext1 Borrow(float[] flattenXYs, out VertexStore vxs, bool closedContour = true) { VxsContext1 context1 = Borrow(out vxs); using (VectorToolBox.Borrow(vxs, out PathWriter pw)) { if (closedContour) { pw.WritePolygon(flattenXYs); } else { pw.WritePolylines(flattenXYs); } } return(context1); }
public static VxsContext1 Borrow(double[] flattenXYs, out VertexStore vxs, bool closedContour = true) { VxsContext1 context1 = Borrow(out vxs); using (VectorToolBox.Borrow(vxs, out PathWriter pw)) { pw.MoveTo(flattenXYs[0], flattenXYs[1]); for (int i = 2; i < flattenXYs.Length;) { pw.LineTo(flattenXYs[i], flattenXYs[i + 1]); i += 2; } if (closedContour) { pw.CloseFigure(); } } return(context1); }