private void calculatePath() { calculatedPath.Clear(); // Sliders may consist of various subpaths separated by two consecutive vertices // with the same position. The following loop parses these subpaths and computes // their shape independently, consecutively appending them to calculatedPath. int start = 0; int end = 0; for (int i = 0; i < ControlPoints.Length; ++i) { end++; if (i == ControlPoints.Length - 1 || ControlPoints[i] == ControlPoints[i + 1]) { ReadOnlySpan <Vector2> cpSpan = ControlPoints.Slice(start, end - start); foreach (Vector2 t in calculateSubpath(cpSpan)) { if (calculatedPath.Count == 0 || calculatedPath.Last() != t) { calculatedPath.Add(t); } } start = end; } } }