介绍
从TouchGFX 4.12.3开始
的Texture Mapper&Animation Texture Mapper能够绘制变换图像的窗口小部件,即可以自由地缩放和旋转围绕调节原点。透视印象也可以通过应用虚拟相机来实现,其中透视量也可以调整。
本文将逐步介绍创建和配置Texture Mapper/ 的步骤 Animation Texture Mapper。
- 此小部件仅在4.12.3及更高版本中可用。
- 此小部件对MCU负载有重大影响。
- 此小部件不支持每像素颜色深度1位。

Texture Mapper 在TouchGFX Designer中的“图像”下。
重要属性
| 位置 | 设置x,y,width,height和 visible的性能Texture Mapper。也可以设置是否 Texture Mapper 将生成为Animation Texture Mapper。 |
| 图片 | 设置应该转化的的形象x,y 在小部件中的图像的位置。 |
| 角度和比例 |
设置 应该显示的图像 的 角度以弧度设置。 |
| 奥里戈 |
设置
|
| 相机 |
设置 |
| 出现 |
配置 |
用法
当 选择Texture Mapper/ Animation Texture Mapper并将其放在TouchGFX Designer画布上时,上表中的属性用于配置 Texture Mapper/ Animation Texture Mapper。
位置

在TouchGFX Designer中修改位置属性
通过调整“位置”下的属性来确定Texture Mapper/ 的面积 Animation Texture Mapper。要设置位置,请设置坐标属性,x 并 y确定Texture Mapper/ 角左上角的Animation Texture Mapper位置。大小由属性确定的width,height。
根据Texture Mapper/ 的大小裁剪转换后的图像 Animation Texture Mapper。为了使图像完全可见,Texture Mapper/ Animation Texture Mapper 应该足够大以容纳转换后的图像。
这也可以将部件从改变 Texture Mapper 到Animation Texture Mapper,通过把一个对勾复选框与标签“动画纹理映射”。
- 如果将旋转或缩放交互应用于持续时间或延迟大于零的“纹理映射器”,则还将生成为“动画纹理映射器”。
图片

在TouchGFX Designer中修改图像属性
通过调整“图像”下的属性,可以设置要变换的图像及其位置。坐标属性x , y确定图像左上角的位置。要将图像锁定在Texture Mapper/ 的中心, Animation Texture Mapper请在复选框中打上带有“锁定图像至中心”标签的复选框。
- 如果在运行时调整纹理映射器/动画纹理映射器的大小,则此选项不会保持图像的居中位置。
Origo和相机

在TouchGFX Designer中修改Origo和Camera属性
在“ Origo”和“ Camera”下的属性中设置Origo和Camera Texture Mapper/ Animation Texture Mapper。
Origo确定应在其周围进行所选图像转换的位置。坐标特性x 和 y可相对于纹理映射器的宽度和高度与不相对于所选择的图像的宽度和高度。
坐标属性 z 是相对于camera distance. 如果camera distance设置为1000,并且图像必须绕它自己的轴 zORIGO也应设置为1000。
为了在中心锁定位置变换 Texture Mapper/Animation Texture Mapper,在带有“锁定origo到中心”标签的复选框中打勾。这会将x and y 属性锁定在 Texture Mapper/ 的中心, Animation Texture Mapper 并将该z 属性锁定在 / 的值 camera distance。
- 如果在运行时调整纹理贴图器/动画纹理贴图器的大小或更改了相机距离,则此选项不会保持居中的变换位置。
相机距离决定了获得的透视量,较低的值将导致较大的透视图,而较高的值将导致较少的透视图。
请参阅下图,直观地了解Texture Mapper/中使用的坐标系 Animation Texture Mapper。

用于Texture Mapper / Animation Texture Mapper中的Origo和相机距离的坐标系
回呼
如果将Texture Mapper 设置为a Animation Texture Mapper,则将调用两个回调: textureMapperAnimationStepCallback &textureMapperAnimationEndedCallback。
textureMapperAnimationStepCallback 每当当前动画执行一个步骤时,就会调用。
textureMapperAnimationStepCallback 所有动画结束时调用。