diff --git a/CustomView/Advance/[10]Matrix_Method.md b/CustomView/Advance/[10]Matrix_Method.md index 0010643..cf39d65 100644 --- a/CustomView/Advance/[10]Matrix_Method.md +++ b/CustomView/Advance/[10]Matrix_Method.md @@ -143,8 +143,40 @@ void mapPoints (float[] dst, int dstIndex,float[] src, int srcIndex, int pointCo (1) `void mapPoints (float[] pts)` 方法仅有一个参数,pts数组作为参数传递原始数值,计算结果仍存放在pts中。 +示例: + +``` java + + // 初始数据为三个点 (0, 0) (80, 100) (400, 300) + float[] pts = new float[]{0, 0, 80, 100, 400, 300}; + + // 构造一个matrix,x坐标缩放0.5 + Matrix matrix = new Matrix(); + matrix.setScale(0.5f, 1f); + + // 输出pts计算之前数据 + Log.i(TAG, "before: "+ Arrays.toString(pts)); + + // 调用map方法计算 + matrix.mapPoints(pts); + + // 输出pts计算之后数据 + Log.i(TAG, "after : "+ Arrays.toString(pts)); +``` + +结果: + +``` +before: [0.0, 0.0, 80.0, 100.0, 400.0, 300.0] +after : [0.0, 0.0, 40.0, 100.0, 200.0, 300.0] +``` + (2) `void mapPoints (float[] dst, float[] src)` ,src作为参数传递原始数值,计算结果存放在dst中。 +``` +``` + + (3) `void mapPoints (float[] dst, int dstIndex,float[] src, int srcIndex, int pointCount)` 可以指定只计算一部分数值。