Path Op 与 Arc 和 Rectangle 相交,而不在结果 Path 中添加相交线

Path Op intersect Arc and Rectangle without adding intersecting lines in resulting Path

我正在开发一个自定义视图,其中将在屏幕矩形边界内单击的视图周围绘制一个圆圈。 下面是写的一段代码。

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    targetPaintOuterThinCircle.setStyle(Paint.Style.STROKE);
    targetPaintOuterThinCircle.setStrokeWidth(thinOuterCircleWidth);
    targetPaintOuterThinCircle.setColor(PRIMARY_GREEN);
    targetPaintOuterThinCircle.setAntiAlias(true);

    targetOuterThinCirclePath.reset();

    targetOuterThinCirclePath.addCircle(targetX, targetY, RADIUS_SIZE_OUTER_THIN_CIRCLE, Path.Direction.CW);
    targetOuterThinCirclePath.op(screenRectPath, Path.Op.INTERSECT);

    canvas.drawPath(targetOuterThinCirclePath, targetPaintOuterThinCircle);
}

我的输出结果是这样的。

预期输出 - 不需要底部的相交线。

我尝试使用 addArc 方法,但在使用矩形边界执行 Path.Op.Intersect 操作时,它也会添加相交线。

我使用下面的clipPath方法达到了我的要求,认为这对像我一样有类似问题的其他人有帮助:

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    targetPaintOuterThinCircle.setStyle(Paint.Style.STROKE);
    targetPaintOuterThinCircle.setStrokeWidth(thinOuterCircleWidth);
    targetPaintOuterThinCircle.setColor(PRIMARY_GREEN);
    targetPaintOuterThinCircle.setAntiAlias(true);

    targetOuterThinCirclePath.reset();
    screenRectPath.reset();
    outsidePath.reset();


    //creating the path for only app visible area path
    screenRectPath.addRect(selfRect.left, selfRect.top + statusBarHeight, selfRect.right, selfRect.bottom - bottomNavBarHeight, Path.Direction.CW);
    
    //below path is the complete screen path
    fullscreenPath.addRect(selfRect.left, selfRect.top, selfRect.right, selfRect.bottom, Path.Direction.CW);
            
    //keeping only the visible area path
    outsidePath.op(screenRectPath, Path.Op.INTERSECT);
    //clipping the canvas other than screenRectPath
    canvas.clipPath(outsidePath);

    targetOuterThinCirclePath.addCircle(targetX, targetY, RADIUS_SIZE_OUTER_THIN_CIRCLE, Path.Direction.CW);
    targetOuterThinCirclePath.op(screenRectPath, Path.Op.INTERSECT);

    canvas.drawPath(targetOuterThinCirclePath, targetPaintOuterThinCircle);
}

下面是输出 -