如何将 Python Cairo 矩阵转换为 Android Canvas 矩阵?
How to convert a Python Cairo matrix into Android Canvas Matrix?
python 中的 cairo 图形模块中的矩阵被描述为
cairo.Matrix(xx = 1.0, yx = 0.0, xy = 0.0, yy = 1.0, x0 = 0.0, y0 = 0.0)
在Andorid的Canvas中,矩阵定义为,
The Matrix class holds a 3x3 matrix for transforming coordinates.
如果给出了这 6 个仿射变换值(xx ,yx, xy, yy, x0, y0),如何将它们放入 9 个值的 Android 矩阵中?
6 值 PyCairo 矩阵可以映射到 9 值 Android 矩阵,如下所示,
android.graphics.Matrix() matrix = new android.graphics.Matrix();
matrix.setValues(new float[] {xx, xy, x0, yx, yy, y0, 0F, 0F, 1F});
在矩阵数学方面,映射实际上是这样的,
| xx xy x0 |
| yx yy y0 |
| 0 0 1 |
python 中的 cairo 图形模块中的矩阵被描述为
cairo.Matrix(xx = 1.0, yx = 0.0, xy = 0.0, yy = 1.0, x0 = 0.0, y0 = 0.0)
在Andorid的Canvas中,矩阵定义为,
The Matrix class holds a 3x3 matrix for transforming coordinates.
如果给出了这 6 个仿射变换值(xx ,yx, xy, yy, x0, y0),如何将它们放入 9 个值的 Android 矩阵中?
6 值 PyCairo 矩阵可以映射到 9 值 Android 矩阵,如下所示,
android.graphics.Matrix() matrix = new android.graphics.Matrix();
matrix.setValues(new float[] {xx, xy, x0, yx, yy, y0, 0F, 0F, 1F});
在矩阵数学方面,映射实际上是这样的,
| xx xy x0 |
| yx yy y0 |
| 0 0 1 |