Canvas.clipPath(Path) not clipping as expected

后端 未结 2 723
不知归路
不知归路 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);
    
    0 讨论(0)
  • 2020-12-09 09:56

    Are you using HC or above or otherwise using hardware acceleration?

    If so, clipPath is unsupported and problematic.

    developer.android.com/guide/topics/graphics/hardware-accel.html.

    0 讨论(0)
提交回复
热议问题