/// <summary> /// /// </summary> /// <param name="cubicBezier"></param> /// <param name="v"></param> /// <param name="threshold"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> public static BaseShape HitTestCubicBezier(XCubicBezier cubicBezier, Vector2 v, double threshold, double dx, double dy) { if (ShapeBounds.GetPointBounds(cubicBezier.Point1, threshold, dx, dy).Contains(v)) { return cubicBezier.Point1; } if (ShapeBounds.GetPointBounds(cubicBezier.Point2, threshold, dx, dy).Contains(v)) { return cubicBezier.Point2; } if (ShapeBounds.GetPointBounds(cubicBezier.Point3, threshold, dx, dy).Contains(v)) { return cubicBezier.Point3; } if (ShapeBounds.GetPointBounds(cubicBezier.Point4, threshold, dx, dy).Contains(v)) { return cubicBezier.Point4; } if (ShapeBounds.Contains(cubicBezier.GetPoints().ToImmutableArray(), v, dx, dy)) { return cubicBezier; } return null; }
/// <summary> /// /// </summary> /// <param name="cubicBezier"></param> /// <param name="selection"></param> /// <param name="selected"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> public static bool HitTestCubicBezier(XCubicBezier cubicBezier, Vector2[] selection, ISet<BaseShape> selected, double dx, double dy) { var points = cubicBezier.GetPoints().ToImmutableArray(); if (ShapeBounds.Overlap(selection, points, dx, dy)) { if (selected != null) { selected.Add(cubicBezier); return false; } else { return true; } } return false; }