diff --git a/CustomView/Advance/[10]Matrix_Method.md b/CustomView/Advance/[10]Matrix_Method.md index bc5094c..3fcc2ae 100644 --- a/CustomView/Advance/[10]Matrix_Method.md +++ b/CustomView/Advance/[10]Matrix_Method.md @@ -220,13 +220,37 @@ pointCount | 计算的点个数 示例: -``` java +> +将第二、三个点计算后存储进dst最开始位置。 +``` java + // 初始数据为三个点 (0, 0) (80, 100) (400, 300) + float[] src = new float[]{0, 0, 80, 100, 400, 300}; + float[] dst = new float[6]; + + // 构造一个matrix,x坐标缩放0.5 + Matrix matrix = new Matrix(); + matrix.setScale(0.5f, 1f); + + // 输出计算之前数据 + Log.i(TAG, "before: src="+ Arrays.toString(src)); + Log.i(TAG, "before: dst="+ Arrays.toString(dst)); + + // 调用map方法计算 + matrix.mapPoints(dst, 0, src, 2, 2); + + // 输出计算之后数据 + Log.i(TAG, "after : src="+ Arrays.toString(src)); + Log.i(TAG, "after : dst="+ Arrays.toString(dst)); ``` 结果: ``` +before: src=[0.0, 0.0, 80.0, 100.0, 400.0, 300.0] +before: dst=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0] +after : src=[0.0, 0.0, 80.0, 100.0, 400.0, 300.0] +after : dst=[40.0, 100.0, 200.0, 300.0, 0.0, 0.0] ```