SkMatrix matrix; matrix.setScale(2.0f, 1.0f); // Sets a scale of 2 in the x direction and no scaling in the y direction float scaleX = matrix.getScaleX(); // Returns 2.0f
SkMatrix matrix; matrix.setRotate(30.0f); // Sets a rotation of 30 degrees matrix.preScale(2.0f, 1.0f); // Scales the matrix by 2 in the x direction and 1 in the y direction float scaleX = matrix.getScaleX(); // Returns approximately 1.732f (square root of 3, due to the rotation)This example sets a rotation of 30 degrees using the setRotate() method, then scales the matrix by 2 in the x direction and 1 in the y direction using the preScale() method. The getScaleX() method returns the scaling factor in the x direction after both transformations have been applied. Package library: Skia (C++ graphics library developed by Google)