Mono Class Library: Cairo Namespace

Cairo.Matrix Class

Defines the Matrix object for transformations and translations. [Edit]

See Also: Matrix Members

public class Matrix : ICloneable

Remarks

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.

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);
	// ...
} 
 
[Edit]

Requirements

Namespace: Cairo
Assembly: Mono.Cairo (in Mono.Cairo.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0