Mono Class Library: Cairo NamespaceCairo.Matrix Class |
See Also: Matrix Members
|
2D affine transform matrices are 3x3 of the form:
Example [ xx yx tx ] [ xy yy ty ] [ 0 0 1 ]As you can see, the bottom row is always [0 0 1]. The Cairo.Matrix implementation deals with the top 6 values only.
[Edit]
C# Example Cairo.Graphics g; Matrix matrix; // Assume we initialize the Graphics obj here... // Get the CTM (Current Transformation Matrix) Matrix m = g.Matrix; // Make some changes m.Translate (translateX, translateY) m.Scale (scaleX, scaleY); // set the CTM to the modified matrix g.Matrix = m; // do some drawing operations here... // Perhaps we now want to compute a few device-to-user point translations... // If we use Graphics. // first, get the CTM. m = g.Matrix; // invert it Cairo.Status cs = m.Invert(); if (cs == Cairo.Status.Success) { // TIP: Transform as many points as you like... m.TransformPoint (ref point1X, ref point1Y); m.TransformPoint (ref point2x, ref point2Y); // ... }
Namespace: Cairo
Assembly: Mono.Cairo (in Mono.Cairo.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0