-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Feature Request
related #701
Path with fill="none" which is NOT closed should IMO fire touch events only when touching it's contour.
OR a different, perhaps better approach:
Add a flag in the event data to indicate where the hit occurred.
Why it is needed
Hit testing for open paths.
Possible implementation
Looking into the android implementation it seems that overriding RenderableView#hitTest(final float[] point) in PathView could do the job, adding a condition to check if fill="none" and path is open.
Code sample
static boolean intersectsPath(final PointF point, final RectF hitSlop, final Path path) {
RectF finalHitRect = Utility.applyHitSlop(point, hitSlop);
Rect roundedHitRect = new Rect();
finalHitRect.roundOut(roundedHitRect);
Path mTouchPath = new Path();
mTouchPath.addOval(finalHitRect, Path.Direction.CW);
mTouchPath.op(path, Path.Op.INTERSECT);
return !mTouchPath.isEmpty();
}
static RectF applyHitSlop(PointF point, RectF hitSlop) {
return new RectF(
point.x - hitSlop.left,
point.y - hitSlop.top,
point.x + hitSlop.right,
point.y + hitSlop.bottom
);
}