我想创建一个发言气球类型的形状,其中有一个矩形或椭圆形的三角形突出它。Android:如何组合两个形状的路径并移除重叠?
我如何试图做到这一点是创建一个三角形与其他形状(圆形矩形)相结合的路径对象。
我做它,如下所示:
Path path = new Path();
// Create triangular segment
Point drawOffset = getAttributes().getDrawOffset();
int leaderGap = getAttributes().getLeaderGapWidth();
// Recall that we have a coordinate system where (0,0) is the
// bottom midpoint of the annotation rectangle.
// the point to left of gap
int x1 = -leaderGap/2;
int y1 = 0;
// the point to right of gap
int x2 = leaderGap/2;
int y2 = 0;
// The point where we're drawing to; the end of the pointy segment of triangle
int x3 = -drawOffset.x;
int y3 = drawOffset.y;
path.moveTo(x2, y2);
path.lineTo(x3, y3);
path.lineTo(x1, y1);
// path.close();
// Add the rectangular portion to the path
path.addRoundRect(backgroundShape, 5, 5, Path.Direction.CW);
的问题是,ROUNDRECT是一个封闭的路径,所以它的边缘显示了通过三角部分下方。
一张照片的胜过千言万语,所以在这里你去:
我要的是三角形消失的这两个端点之间的线段,所以它看起来像一个无缝路径。
如果我所做的只是一个矩形,我可以从头创建整个路径。但是我想要做圆角,并且在Path中做这件事(我知道你可以做quad to和arcTo,但它仍然不像我想的那样干净利落喜欢)。
因此,一般情况下,是否可以组合两条路径并创建一个跟踪两者边界的单个联合对象?