我试图在Android中找到两个(或更多)路径或区域的交叉点。
当规定>=应用编程接口级别19时,这很容易实现
// onDraw(Canvas oCanvas)....
Paint oPaint = new Paint();
oPaint.setStyle(Style.STROKE);
oPaint.setColor(Color.BLACK);
Path oPath1 = new Path();
oPath1.addCircle(200, 400, 100, Direction.CW); // (X,Y,Radius,Direction)
oCanvas.drawPath(oPath1, oPaint);
Path oPath2 = new Path();
oPath2.addCircle(400, 400, 150, Direction.CW); // (X,Y,Radius,Direction)
oCanvas.drawPath(oPath2, oPaint);
oPath1.op(oPath2, Op.INTERSECT);
// Draw intersection area in red.
oPaint.setColor(Color.RED);
oCanvas.drawPath(oPath1, oPaint);我注意到Region有一个在API级别1上可用的op。
那么,对于所有API级别,我如何实现上述效果呢?
发布于 2014-03-17 15:01:06
您可以使用Region.setPath将Path (就像在问题文本中一样)转换为Region。然后,您可以像使用API19代码一样使用op。
https://stackoverflow.com/questions/22424283
复制相似问题