Another quick note on the topic. If you just need to flip a picture horizontally or vertically you can use Picture.Flip.
Also remember that a rotation matrix rotates around 0,0, and 0,0 in Picture is at the top-left corner. So a 180° rotation around the top-left corner will bring the source picture out of the destination rectangle.
If you want to rotate a picture around its center you have to build the transformation matrix like this:
t = gs.Matrix3.TranslationMatrix(center) * gs.Matrix3.RotationMatrixZAxis(angle) * gs.Matrix3.TranslationMatrix(center.Reversed());
What this does is build a compound matrix performing the following operations:
- Shift source by
-center.x, -center.y so that its center sits on the origin (0,0).
- Perform the rotation.
- Shift by
center.x, center.y so that the transformed center is back at (center.x, center.y).
Newer versions will include a
gs.Matrix3.RotationMatrix2D(angle, pivot) function that does just that.