Skip to content

Commit d8e8d9e

Browse files
committed
Update value compute
1 parent a3d1b1e commit d8e8d9e

1 file changed

Lines changed: 44 additions & 3 deletions

File tree

‎CustomView/Advance/[10]Matrix_Method.md‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void mapPoints (float[] dst, float[] src)
137137
void mapPoints (float[] dst, int dstIndex,float[] src, int srcIndex, int pointCount)
138138
```
139139
140-
计算一组点基于当前Matrix变换后的位置,(由于是计算点,所以参数中的float数组长度一般都是偶数的)。
140+
计算一组点基于当前Matrix变换后的位置,(由于是计算点,所以参数中的float数组长度一般都是偶数的,若为奇数,则最后一个数值不参与计算)。
141141
142142
它有三个重载方法:
143143
@@ -171,14 +171,55 @@ before: [0.0, 0.0, 80.0, 100.0, 400.0, 300.0]
171171
after : [0.0, 0.0, 40.0, 100.0, 200.0, 300.0]
172172
```
173173
174-
(2) `void mapPoints (float[] dst, float[] src)` ,src作为参数传递原始数值,计算结果存放在dst中。
174+
(2) `void mapPoints (float[] dst, float[] src)` ,src作为参数传递原始数值,计算结果存放在dst中,src不变。
175175
176-
```
176+
如果原始数据需要保留则一般使用这种方法。
177+
178+
示例:
179+
180+
``` java
181+
// 初始数据为三个点 (0, 0) (80, 100) (400, 300)
182+
float[] src = new float[]{0, 0, 80, 100, 400, 300};
183+
float[] dst = new float[6];
184+
185+
// 构造一个matrix,x坐标缩放0.5
186+
Matrix matrix = new Matrix();
187+
matrix.setScale(0.5f, 1f);
188+
189+
// 输出计算之前数据
190+
Log.i(TAG, "before: src="+ Arrays.toString(src));
191+
Log.i(TAG, "before: dst="+ Arrays.toString(dst));
192+
193+
// 调用map方法计算
194+
matrix.mapPoints(dst,src);
195+
196+
// 输出计算之后数据
197+
Log.i(TAG, "after : src="+ Arrays.toString(src));
198+
Log.i(TAG, "after : dst="+ Arrays.toString(dst));
177199
```
178200
201+
结果:
202+
203+
```
204+
before: src=[0.0, 0.0, 80.0, 100.0, 400.0, 300.0]
205+
before: dst=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
206+
after : src=[0.0, 0.0, 80.0, 100.0, 400.0, 300.0]
207+
after : dst=[0.0, 0.0, 40.0, 100.0, 200.0, 300.0]
208+
```
179209
180210
(3) `void mapPoints (float[] dst, int dstIndex,float[] src, int srcIndex, int pointCount)` 可以指定只计算一部分数值。
181211
212+
示例:
213+
214+
``` java
215+
216+
```
217+
218+
结果:
219+
220+
```
221+
222+
```
182223
183224
**2.mapRadius**
184225

0 commit comments

Comments
 (0)