/// <summary>Copies a section of this path. /// Note that if p2 is before p1, it will safely loop over a closed node. /// </summary> public VectorPath CopySection(VectorPoint p1, float c1, VectorPoint p2, float c2) { // Split the line p1 at c1. // Split the line p2 at c2. // The section between these two nodes is the part we want. // Create the path: VectorPath path = new VectorPath(); if (p1 == null) { p1 = FirstPathNode; c1 = 0f; } // Add the first node: path.AddPathNode(p1.PointAt(c1, true)); VectorPoint current = p1.Next; while (current != p2 && current != null) { if (current == p1) { // This occurs when p1 and p2 are not in the same shape. throw new Exception("Section start and end are not from the same path."); } // Add a copy: path.AddPathNode(current.Copy()); // Go to next: current = current.Next; if (current == null && p2 != null) { // Need to loop back around unless p2 is null. // Notice that we actively skip the moveTo itself as // current is in the same location. current = path.FirstPathNode.Next; } } if (current == p2 && p2 != null) { // Add it: path.AddPathNode(p2.PointAt(c2, false)); } return(path); }
/// <summary>Copies this vector path into the given one.</summary> public void CopyInto(VectorPath path) { VectorPoint point = FirstPathNode; while (point != null) { VectorPoint copiedPoint = point.Copy(); path.AddPathNode(copiedPoint); // Copy close status: if (point.IsClose) { copiedPoint.IsClose = true; path.CloseNode.ClosePoint = copiedPoint; } point = point.Next; } }
//--------------------------------------