public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOffset) { var points = sliderPath.ControlPoints.ToArray(); positionalOffset = sliderPath.PositionAt(1); sliderPath.ControlPoints.Clear(); PathType?lastType = null; for (int i = 0; i < points.Length; i++) { var p = points[i]; p.Position -= positionalOffset; // propagate types forwards to last null type if (i == points.Length - 1) { p.Type = lastType; p.Position = Vector2.Zero; } else if (p.Type != null) { (p.Type, lastType) = (lastType, p.Type); } sliderPath.ControlPoints.Insert(0, p); } }
public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOffset) { var points = sliderPath.ControlPoints.ToArray(); positionalOffset = points.Last().Position.Value; sliderPath.ControlPoints.Clear(); PathType?lastType = null; for (var i = 0; i < points.Length; i++) { var p = points[i]; p.Position.Value -= positionalOffset; // propagate types forwards to last null type if (i == points.Length - 1) { p.Type.Value = lastType; } else if (p.Type.Value != null) { var newType = p.Type.Value; p.Type.Value = lastType; lastType = newType; } sliderPath.ControlPoints.Insert(0, p); } }