Path之PathMeasure的介绍(一)

PathMeasure顾名思义,是用来对path进行测量。其进行的一些方法的操作也与path息息相关。下面,就详细地介绍PathMeasure。

来张图装饰下

  • PathMeasure的两个常量(Constants)

POSITION_MATRIX_FLAG:位置矩阵标志(个人理解),Constant Value: 1 (0x00000001)
TANGENT_MATRIX_FLAG:正切矩阵标志(个人理解),Constant Value: 2 (0x00000002)

  • PathMeasure的构造方法

PathMeasure():Create an empty PathMeasure object.即创建一个空的PathMeasure类

PathMeasure(Path path, boolean forceClosed):Create a PathMeasure object associated with the specified path object (already created and specified).即创建一个与path相关联的PathMeasure类

  • PathMeasure的所有方法

getLength():返回值类型为float,如果PathMeasure没有与path关联上,则返回的length为0,反之,返回的是path的总长度。

getMatrix(float distance, Matrix matrix, int flags):返回值类型boolean,在0<=distance<=getLength()的情况下,然后计算相应的矩阵matrix。参数flags可以是上面两种常量的任意一种。

getPosTan(float distance, float[] pos, float[] tan):返回值类型boolean,在0<=distance<=getLength()的情况下,然后计算相应的位置和正切。

getSegment(float startD, float stopD, Path dst, boolean startWithMoveTo):返回值类型boolean,提供开始(startD)和停止(stopD)的距离,返回介于其两者之间的部分或者是片段。

isClosed():返回值类型boolean,如果当前轮廓已经关闭,则返回true

nextContour():返回值类型boolean,移动到下一个轮廓的路径。

setPath(Path path, boolean forceClosed):返回值类型void,将PathMeasure与path相关联。

以上就是本人结合Android API以及自己的一些理解,把它描述出来。若有不妥之处,希望大家多多指正。

猜你喜欢

转载自blog.csdn.net/huangf321123/article/details/54863922