Update
This commit is contained in:
@@ -169,10 +169,22 @@ startWithMoveTo | 起始点是否使用 moveTo | 用于保证截取
|
|||||||
从上图可以看到我们成功到将需要到片段截取了出来,然而当 dst 中有内容时会怎样呢?
|
从上图可以看到我们成功到将需要到片段截取了出来,然而当 dst 中有内容时会怎样呢?
|
||||||
|
|
||||||
``` java
|
``` java
|
||||||
|
canvas.translate(mViewWidth / 2, mViewHeight / 2); // 平移坐标系
|
||||||
|
|
||||||
|
Path path = new Path(); // 创建Path并添加了一个矩形
|
||||||
|
path.addRect(-200, -200, 200, 200, Path.Direction.CW);
|
||||||
|
|
||||||
|
Path dst = new Path(); // 创建用于存储截取后内容的 Path
|
||||||
|
dst.lineTo(-300, -300); // 在 dst 中添加一条线段
|
||||||
|
|
||||||
|
PathMeasure measure = new PathMeasure(path, false); // 将 Path 与 PathMeasure 关联
|
||||||
|
|
||||||
|
measure.getSegment(200, 600, dst, true); // 截取一部分 并使用 moveTo 保持截取得到的 Path 第一个点的位置不变
|
||||||
|
|
||||||
|
canvas.drawPath(dst, mDeafultPaint); // 绘制 Path
|
||||||
```
|
```
|
||||||
|
|
||||||
从上面的示例可以得到结论:**被截取的 Path 片段会添加到 dst 中,而不是替换 dst 中到内容。**
|
从上面的示例可以看到 dst 中的线段保留了下来,可以得到结论:**被截取的 Path 片段会添加到 dst 中,而不是替换 dst 中到内容。**
|
||||||
|
|
||||||
前面两个例子中 startWithMoveTo 均为 true, 如果设置为false会怎样呢?
|
前面两个例子中 startWithMoveTo 均为 true, 如果设置为false会怎样呢?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user