SkMatrix matrix1, matrix2, resultMatrix; matrix1.setScale(2.0f, 2.0f); matrix2.setRotate(30.0f); resultMatrix.setConcat(matrix1, matrix2); // set resultMatrix to be the concatenated matrix of matrix1 and matrix2
void applyTransform(SkPath& path, const SkMatrix& matrix) { SkPath transformedPath; path.transform(matrix, &transformedPath); // apply given matrix transform to path path = transformedPath; } SkMatrix matrix1, matrix2; matrix1.setScale(2.0f, 2.0f); matrix2.setRotate(30.0f); SkMatrix concatenatedMatrix; concatenatedMatrix.setConcat(matrix1, matrix2); // set concatenatedMatrix to be the concatenated matrix of matrix1 and matrix2 SkPath path; path.moveTo(10, 10); path.lineTo(50, 50); applyTransform(path, concatenatedMatrix); // apply concatenatedMatrix transform to pathIn this example, we create two matrices: matrix1 and matrix2, and set them to scale and rotate similar to Example 1. We then create a new matrix concatenatedMatrix using setConcat() to be the concatenated matrix of matrix1 and matrix2. We define a helper function applyTransform() that applies the given matrix transform to a SkPath object using the transform() method, and then assigns the transformed path back to the original path. Finally, we create a path object, add some lines to it, and apply the concatenatedMatrix transform using the applyTransform() function. In conclusion, the setConcat() method in the SkMatrix class is useful for concatenating two matrices and setting the result to a new matrix. This method is useful in various graphics applications and is provided as part of the Skia Graphics Library, a popular C++ library for 2D graphics.