如何使用matrix.preScale(x,y)

Khi*_*iem 5 android android-canvas

该功能matrix.preScale(x,y)如何工作以及如何使用?

用法示例:

matrix.preScale(1.0f, 1.0f);
Run Code Online (Sandbox Code Playgroud)

Dir*_*irk 8

前,后功能分别用于前后乘法.

例如,调用以下函数:

reset(); //reset to identity matrix
setRotate(90); //set the matrix to be a 90 degree rotation
preScale(2.0f,2.0f); //scale uniformly with factor 2
Run Code Online (Sandbox Code Playgroud)

要么

reset(); //reset to identity matrix
setRotate(90); //set the matrix to be a 90 degree rotation
postScale(2.0f,2.0f); //scale uniformly with factor 2
Run Code Online (Sandbox Code Playgroud)

现在,有什么区别?

在第一个版本中,最终矩阵首先缩放然后旋转.在第二个,反之亦然.

前置函数构造一个矩阵,并将其从右侧乘以现有的矩阵后置函数,从左侧乘以.