1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = cairo-cairo-matrix-t.html
27  * outPack = cairo
28  * outFile = Matrix
29  * strct   = cairo_matrix_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = Matrix
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- cairo_matrix_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * 	- cairo_matrix_t* -> Matrix
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module cairo.Matrix;
55 
56 public  import gtkc.cairotypes;
57 
58 private import gtkc.cairo;
59 private import glib.ConstructionException;
60 
61 
62 private import glib.Str;
63 
64 
65 
66 
67 /**
68  * cairo_matrix_t is used throughout cairo to convert between different
69  * coordinate spaces. A cairo_matrix_t holds an affine transformation,
70  * such as a scale, rotation, shear, or a combination of these.
71  * The transformation of a point (x,y)
72  * is given by:
73  *
74  * x_new = xx * x + xy * y + x0;
75  * y_new = yx * x + yy * y + y0;
76  *
77  * The current transformation matrix of a cairo_t, represented as a
78  * cairo_matrix_t, defines the transformation from user-space
79  * coordinates to device-space coordinates. See cairo_get_matrix() and
80  * cairo_set_matrix().
81  */
82 public class Matrix
83 {
84 	
85 	/** the main Gtk struct */
86 	protected cairo_matrix_t* cairo_matrix;
87 	
88 	
89 	public cairo_matrix_t* getMatrixStruct()
90 	{
91 		return cairo_matrix;
92 	}
93 	
94 	
95 	/** the main Gtk struct as a void* */
96 	protected void* getStruct()
97 	{
98 		return cast(void*)cairo_matrix;
99 	}
100 	
101 	/**
102 	 * Sets our main struct and passes it to the parent class
103 	 */
104 	public this (cairo_matrix_t* cairo_matrix)
105 	{
106 		this.cairo_matrix = cairo_matrix;
107 	}
108 	
109 	/**
110 	 */
111 	
112 	/**
113 	 * Sets matrix to be the affine transformation given by
114 	 * xx, yx, xy, yy, x0, y0. The transformation is given
115 	 * Since 1.0
116 	 * Params:
117 	 * xx = xx component of the affine transformation
118 	 * yx = yx component of the affine transformation
119 	 * xy = xy component of the affine transformation
120 	 * yy = yy component of the affine transformation
121 	 * x0 = X translation component of the affine transformation
122 	 * y0 = Y translation component of the affine transformation
123 	 */
124 	public void init(double xx, double yx, double xy, double yy, double x0, double y0)
125 	{
126 		// void cairo_matrix_init (cairo_matrix_t *matrix,  double xx,  double yx,  double xy,  double yy,  double x0,  double y0);
127 		cairo_matrix_init(cairo_matrix, xx, yx, xy, yy, x0, y0);
128 	}
129 	
130 	/**
131 	 * Modifies matrix to be an identity transformation.
132 	 * Since 1.0
133 	 */
134 	public void initIdentity()
135 	{
136 		// void cairo_matrix_init_identity (cairo_matrix_t *matrix);
137 		cairo_matrix_init_identity(cairo_matrix);
138 	}
139 	
140 	/**
141 	 * Initializes matrix to a transformation that translates by tx and
142 	 * ty in the X and Y dimensions, respectively.
143 	 * Since 1.0
144 	 * Params:
145 	 * tx = amount to translate in the X direction
146 	 * ty = amount to translate in the Y direction
147 	 */
148 	public void initTranslate(double tx, double ty)
149 	{
150 		// void cairo_matrix_init_translate (cairo_matrix_t *matrix,  double tx,  double ty);
151 		cairo_matrix_init_translate(cairo_matrix, tx, ty);
152 	}
153 	
154 	/**
155 	 * Initializes matrix to a transformation that scales by sx and sy
156 	 * in the X and Y dimensions, respectively.
157 	 * Since 1.0
158 	 * Params:
159 	 * sx = scale factor in the X direction
160 	 * sy = scale factor in the Y direction
161 	 */
162 	public void initScale(double sx, double sy)
163 	{
164 		// void cairo_matrix_init_scale (cairo_matrix_t *matrix,  double sx,  double sy);
165 		cairo_matrix_init_scale(cairo_matrix, sx, sy);
166 	}
167 	
168 	/**
169 	 * Initialized matrix to a transformation that rotates by radians.
170 	 * Since 1.0
171 	 * Params:
172 	 * radians = angle of rotation, in radians. The direction of rotation
173 	 * is defined such that positive angles rotate in the direction from
174 	 * the positive X axis toward the positive Y axis. With the default
175 	 * axis orientation of cairo, positive angles rotate in a clockwise
176 	 * direction.
177 	 */
178 	public void initRotate(double radians)
179 	{
180 		// void cairo_matrix_init_rotate (cairo_matrix_t *matrix,  double radians);
181 		cairo_matrix_init_rotate(cairo_matrix, radians);
182 	}
183 	
184 	/**
185 	 * Applies a translation by tx, ty to the transformation in
186 	 * matrix. The effect of the new transformation is to first translate
187 	 * the coordinates by tx and ty, then apply the original transformation
188 	 * to the coordinates.
189 	 * Since 1.0
190 	 * Params:
191 	 * tx = amount to translate in the X direction
192 	 * ty = amount to translate in the Y direction
193 	 */
194 	public void translate(double tx, double ty)
195 	{
196 		// void cairo_matrix_translate (cairo_matrix_t *matrix,  double tx,  double ty);
197 		cairo_matrix_translate(cairo_matrix, tx, ty);
198 	}
199 	
200 	/**
201 	 * Applies scaling by sx, sy to the transformation in matrix. The
202 	 * effect of the new transformation is to first scale the coordinates
203 	 * by sx and sy, then apply the original transformation to the coordinates.
204 	 * Since 1.0
205 	 * Params:
206 	 * sx = scale factor in the X direction
207 	 * sy = scale factor in the Y direction
208 	 */
209 	public void scale(double sx, double sy)
210 	{
211 		// void cairo_matrix_scale (cairo_matrix_t *matrix,  double sx,  double sy);
212 		cairo_matrix_scale(cairo_matrix, sx, sy);
213 	}
214 	
215 	/**
216 	 * Applies rotation by radians to the transformation in
217 	 * matrix. The effect of the new transformation is to first rotate the
218 	 * coordinates by radians, then apply the original transformation
219 	 * to the coordinates.
220 	 * Since 1.0
221 	 * Params:
222 	 * radians = angle of rotation, in radians. The direction of rotation
223 	 * is defined such that positive angles rotate in the direction from
224 	 * the positive X axis toward the positive Y axis. With the default
225 	 * axis orientation of cairo, positive angles rotate in a clockwise
226 	 * direction.
227 	 */
228 	public void rotate(double radians)
229 	{
230 		// void cairo_matrix_rotate (cairo_matrix_t *matrix,  double radians);
231 		cairo_matrix_rotate(cairo_matrix, radians);
232 	}
233 	
234 	/**
235 	 * Changes matrix to be the inverse of its original value. Not
236 	 * all transformation matrices have inverses; if the matrix
237 	 * collapses points together (it is degenerate),
238 	 * then it has no inverse and this function will fail.
239 	 * Since 1.0
240 	 * Returns: If matrix has an inverse, modifies matrix to be the inverse matrix and returns CAIRO_STATUS_SUCCESS. Otherwise, returns CAIRO_STATUS_INVALID_MATRIX.
241 	 */
242 	public cairo_status_t invert()
243 	{
244 		// cairo_status_t cairo_matrix_invert (cairo_matrix_t *matrix);
245 		return cairo_matrix_invert(cairo_matrix);
246 	}
247 	
248 	/**
249 	 * Multiplies the affine transformations in a and b together
250 	 * and stores the result in result. The effect of the resulting
251 	 * transformation is to first apply the transformation in a to the
252 	 * coordinates and then apply the transformation in b to the
253 	 * coordinates.
254 	 * It is allowable for result to be identical to either a or b.
255 	 * Since 1.0
256 	 * Params:
257 	 * a = a cairo_matrix_t
258 	 * b = a cairo_matrix_t
259 	 */
260 	public void multiply(Matrix a, Matrix b)
261 	{
262 		// void cairo_matrix_multiply (cairo_matrix_t *result,  const cairo_matrix_t *a,  const cairo_matrix_t *b);
263 		cairo_matrix_multiply(cairo_matrix, (a is null) ? null : a.getMatrixStruct(), (b is null) ? null : b.getMatrixStruct());
264 	}
265 	
266 	/**
267 	 * Transforms the distance vector (dx,dy) by matrix. This is
268 	 * similar to cairo_matrix_transform_point() except that the translation
269 	 * components of the transformation are ignored. The calculation of
270 	 * Since 1.0
271 	 * Params:
272 	 * dx = X component of a distance vector. An in/out parameter
273 	 * dy = Y component of a distance vector. An in/out parameter
274 	 */
275 	public void transformDistance(ref double dx, ref double dy)
276 	{
277 		// void cairo_matrix_transform_distance (const cairo_matrix_t *matrix,  double *dx,  double *dy);
278 		cairo_matrix_transform_distance(cairo_matrix, &dx, &dy);
279 	}
280 	
281 	/**
282 	 * Transforms the point (x, y) by matrix.
283 	 * Since 1.0
284 	 * Params:
285 	 * x = X position. An in/out parameter
286 	 * y = Y position. An in/out parameter
287 	 */
288 	public void transformPoint(ref double x, ref double y)
289 	{
290 		// void cairo_matrix_transform_point (const cairo_matrix_t *matrix,  double *x,  double *y);
291 		cairo_matrix_transform_point(cairo_matrix, &x, &y);
292 	}
293 }