【Android UI】Path 测量 PathMeasure ② ( PathMeasure API 简介 | nextContour 函数 | getPosTan 函数 ★ | 曲线切线处理 )
2023-06-13 09:18:06 时间
文章目录
一、PathMeasure API 简介
PathMeasure 官方文档 : https://developer.android.google.cn/reference/kotlin/android/graphics/PathMeasure
PathMeasure 是 Path 的一个 工具类 , 字面意思就是 Path 的测量工具类 ,
为该 PathMeasure 设置一个 Path 对象 , 则可以对 Path 的 路径 , 轨迹 进行测量 , 可以精确的计算出 Path 的运动轨迹 ,
PathMeasure 提供了 7 个函数用于实现相关功能 ;
1、nextContour 函数
nextContour 函数 作用是 跳转到下一个轮廓 ;
Path 是可以进行组合的 , 调用 Path 的 op 函数 , 可以将两个 Path 轮廓组合在一起 , 设置了组合以后 , 假如对其中的一个 Path 进行测量 , 调用 nextContour 函数 , 即可对另外一个 Path 轮廓进行测量 ;
两个 Path 没有先后顺序 ;
nextContour 函数原型 :
open fun nextContour(): Boolean
Move 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!
): Boolean
Pins 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 telephony_android获取真实时间
- android开机动画多长时间_Android开机动画原理分析
- 基于chromium for android开发Android浏览器
- 代码加密 android,Android 开发怎样做代码加密或混淆「建议收藏」
- a8三星手机android,三星a8手机参数和测评介绍[通俗易懂]
- strictmode android,Android 应用性能优化-StrictMode(严格模式)
- android sdk根目录,Android SDK位置
- android 杀进程 方法,android中杀死进程的方法
- android更新ui的方式_android ui界面模板
- Android Studio greadle打包拷贝apk
- 【Android 应用开发】Android屏幕适配解析 - 详解像素,设备独立像素,归一化密度,精确密度及各种资源对应的尺寸密度分辨率适配问题
- 【Android APT】编译时技术 ( 编译时注解 和 注解处理器 依赖库 )
- 【Android 逆向】Android 逆向通用工具开发 ( 静态库项目中的网络操作核心类 CNetwork 分析 )
- 【Android 逆向】函数拦截原理 ( 可执行程序基本结构 | GOT 全局偏移表 | 可执行程序函数调用步骤 )
- 【错误记录】Android 应用 POST 网络请求报错 ( java.io.IOException: Cleartext HTTP traffic to xxx not permitted )
- Android Studio 导入项目 出现安装Error:Cause: failed to find target with hash string ‘android-23’ 等错误详解手机开发
- Android学习路线图详解编程语言
- 2013年上半年Android平台病毒同比增长7.96倍
- android???虹?搴?瑙e?冲??瀛????剧?????
- Android中的android:layout_weight使用详解
- android在异步任务中关闭Cursor的代码方法
- 浅析Android的MediaPlayer类
- Android使用WebView播放flash的方法
- Android编程中避免内存泄露的方法总结