#include "SkMatrix.h" SkMatrix myMatrix; myMatrix.setScale(2.0f, 3.0f); // apply the matrix to a point SkPoint myPoint = SkPoint::Make(1.0f, 1.0f); myMatrix.mapPoints(&myPoint, 1); // output the transformed point printf("Transformed Point: (%.2f, %.2f)\n", myPoint.x(), myPoint.y());
#include "SkMatrix.h" SkMatrix myMatrix; myMatrix.setRotate(45.0f); // apply the matrix to a rectangle SkRect myRect = SkRect::MakeLTRB(0.0f, 0.0f, 100.0f, 50.0f); myMatrix.mapRect(&myRect); // output the transformed rectangle printf("Transformed Rectangle: (%.2f, %.2f, %.2f, %.2f)\n", myRect.left(), myRect.top(), myRect.right(), myRect.bottom());In this second example, we create a SkMatrix object and set it to a rotation transform of 45 degrees. We then create a SkRect object and apply the matrix transformation to it using the `mapRect()` method. Finally, we output the transformed rectangle using a printf statement. These examples utilize the Skia graphics library's SkMatrix class.