2 // Mono.Cairo.Matrix.cs
6 // (C) Ximian Inc, 2003.
8 // This is an OO wrapper API for the Cairo API
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Runtime.InteropServices;
41 internal IntPtr matrix = IntPtr.Zero;
48 internal Matrix (IntPtr ptr)
50 if (ptr == IntPtr.Zero)
56 public static IntPtr Create ()
58 return CairoAPI.cairo_matrix_create ();
61 public void Destroy ()
63 CairoAPI.cairo_matrix_destroy (matrix);
66 public Cairo.Status Copy (out Cairo.Matrix other)
68 IntPtr p = IntPtr.Zero;
70 Cairo.Status status = CairoAPI.cairo_matrix_copy (matrix, out p);
72 other = new Cairo.Matrix (p);
77 public IntPtr Pointer {
78 get { return matrix; }
81 public Cairo.Status SetIdentity ()
83 return CairoAPI.cairo_matrix_set_identity (matrix);
86 public Cairo.Status SetAffine (
87 double a, double b, double c, double d, double tx, double ty)
89 return CairoAPI.cairo_matrix_set_affine (
90 matrix, a, b, c, d, tx, ty);
93 public Cairo.Status GetAffine (
94 out double a, out double b, out double c, out double d, out double tx, out double ty)
96 return CairoAPI.cairo_matrix_get_affine (
97 matrix, out a, out b, out c, out d, out tx, out ty);
100 public Cairo.Status Scale (double sx, double sy)
102 return CairoAPI.cairo_matrix_scale (matrix, sx, sy);
105 public Cairo.Status Rotate (double radians)
107 return CairoAPI.cairo_matrix_rotate (matrix, radians);
110 public Cairo.Status Invert ()
112 return CairoAPI.cairo_matrix_invert (matrix);
115 public static Cairo.Status Multiply (
116 out Cairo.Matrix result, Cairo.Matrix a, Cairo.Matrix b)
118 IntPtr p = IntPtr.Zero;
120 Cairo.Status status = CairoAPI.cairo_matrix_multiply (
121 out p, a.Pointer, b.Pointer);
123 result = new Cairo.Matrix (p);
128 public Cairo.Status TransformDistance (ref double dx, ref double dy)
130 return CairoAPI.cairo_matrix_transform_distance (
131 matrix, ref dx, ref dy);
134 public Cairo.Status TransformPoint (ref double x, ref double y)
136 return CairoAPI.cairo_matrix_transform_distance (
137 matrix, ref x, ref y);