Canvas.clipPath(Path) not clipping as expected

后端 未结 2 727
不知归路
不知归路 2020-12-09 09:18

I\'m trying to clip a canvas drawing operation to an arc-shaped wedge. However, I\'m not getting the intended result after setting the clipping path to the canvas.

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 09:54

    OP's question is specifically about using a clipping region and has been answered by @Simon. Bear in mind, however, that there's a more straightforward way of drawing a filled arc:

    Create a Paint:

    mPaint = new Paint();
    mPaint.setColor(Color.BLUE);
    mPaint.setStyle(Style.FILL);
    mPaint.setAntiAlias(true);
    

    When drawing, simply draw the path:

    canvas.drawPath(path, mPaint);
    

提交回复
热议问题