700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 【Android UI】Path 测量 PathMeasure ② ( PathMeasure API 简介 | nextCo

【Android UI】Path 测量 PathMeasure ② ( PathMeasure API 简介 | nextCo

时间:2018-12-30 22:43:01

相关推荐

【Android UI】Path 测量 PathMeasure ② ( PathMeasure API 简介 | nextCo

文章目录

一、PathMeasure API 简介1、nextContour 函数2、getPosTan 函数 ★

一、PathMeasure API 简介

PathMeasure 官方文档 :https://developer./reference/kotlin/android/graphics/PathMeasure

PathMeasure 是 Path 的一个 工具类 , 字面意思就是 Path 的测量工具类 ,

为该 PathMeasure 设置一个 Path 对象 , 则可以对 Path 的 路径 , 轨迹 进行测量 , 可以精确的计算出 Path 的运动轨迹 ,

PathMeasure 提供了 777 个函数用于实现相关功能 ;

1、nextContour 函数

nextContour 函数 作用是 跳转到下一个轮廓 ;

Path 是可以进行组合的 , 调用 Path 的 op 函数 , 可以将两个 Path 轮廓组合在一起 , 设置了组合以后 , 假如对其中的一个 Path 进行测量 , 调用 nextContour 函数 , 即可对另外一个 Path 轮廓进行测量 ;

两个 Path 没有先后顺序 ;

nextContour 函数原型 :

open fun nextContour(): BooleanMove to the next contour in the path. Return true if one exists, or false if we're done with the path.移动到路径中的下一个轮廓。如果存在,则返回true;如果路径已完成,则返回false。

2、getPosTan 函数 ★

getPosTan 函数 作用是 获取指定长度位置的坐标点 以及该点对应切线的值 ;

getPosTan 函数原型 :

open fun getPosTan(distance: Float, pos: FloatArray!, tan: FloatArray!): BooleanPins distance to 0 <= distance <= getLength(), and then computes the corresponding position and tangent. Returns false if there is no path, or a zero-length path was specified, in which case position and tangent are unchanged.将距离固定到0<=距离<=getLength(),然后计算相应的位置和切线。如果没有路径或指定了零长度路径,则返回false,在这种情况下,位置和切线不变。

distance: Float 参数: 沿当前轮廓进行采样的距离 ;

The distance along the current contour to sample

pos: FloatArray! 参数: 如果不为null,则返回采样位置(x==[0],y==[1]) ;

If not null, returns the sampled position (x==[0], y==[1])

tan: FloatArray! 参数: 如果不为null,则返回采样的切线(x==[0],y==[1]);

If not null, returns the sampled tangent (x==[0], y==[1])

Boolean 返回值: 如果没有与此度量值对象关联的路径,则为false ;

false if there was no path associated with this measure object

pos: FloatArray! 和 tan: FloatArray! 这两个数组 , 适用于接收返回值的 , 并不是用于参数传递 ;

只有曲线找切线才有意义 , 直线的切线直接就是 ( 0, 0 ) 坐标 ;

下图中 , 蓝色是 圆形 的曲线 , 红色点 是 曲线上的点 , 则 绿色点就是获取的 tan: FloatArray 参数值 , 该点是曲线的圆心 , 与曲线上的点连接 , 垂直与切线 ;

【Android UI】Path 测量 PathMeasure ② ( PathMeasure API 简介 | nextContour 函数 | getPosTan 函数 ★ | 曲线切线处理 )

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。