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 cairo.c.types;
57 
58 private import cairo.c.functions;
59 private import glib.ConstructionException;
60 
61 private import glib.Str;
62 
63 
64 
65 /**
66  * cairo_matrix_t is used throughout cairo to convert between different
67  * coordinate spaces. A cairo_matrix_t holds an affine transformation,
68  * such as a scale, rotation, shear, or a combination of these.
69  * The transformation of a point (x,y)
70  * is given by:
71  *
72  * x_new = xx * x + xy * y + x0;
73  * y_new = yx * x + yy * y + y0;
74  *
75  * The current transformation matrix of a cairo_t, represented as a
76  * cairo_matrix_t, defines the transformation from user-space
77  * coordinates to device-space coordinates. See cairo_get_matrix() and
78  * cairo_set_matrix().
79  */
80 public class Matrix
81 {
82 	
83 	/** the main Gtk struct */
84 	protected cairo_matrix_t* cairo_matrix;
85 	
86 	
87 	/** Get the main Gtk struct */
88 	public cairo_matrix_t* getMatrixStruct()
89 	{
90 		return cairo_matrix;
91 	}
92 	
93 	
94 	/** the main Gtk struct as a void* */
95 	protected void* getStruct()
96 	{
97 		return cast(void*)cairo_matrix;
98 	}
99 	
100 	/**
101 	 * Sets our main struct and passes it to the parent class
102 	 */
103 	public this (cairo_matrix_t* cairo_matrix, bool ownedRef = false)
104 	{
105 		this.cairo_matrix = cairo_matrix;
106 	}
107 	
108 	/**
109 	 */
110 	
111 	/**
112 	 * Sets matrix to be the affine transformation given by
113 	 * xx, yx, xy, yy, x0, y0. The transformation is given
114 	 * Since 1.0
115 	 * Params:
116 	 * xx = xx component of the affine transformation
117 	 * yx = yx component of the affine transformation
118 	 * xy = xy component of the affine transformation
119 	 * yy = yy component of the affine transformation
120 	 * x0 = X translation component of the affine transformation
121 	 * y0 = Y translation component of the affine transformation
122 	 */
123 	public void init(double xx, double yx, double xy, double yy, double x0, double y0)
124 	{
125 		// void cairo_matrix_init (cairo_matrix_t *matrix,  double xx,  double yx,  double xy,  double yy,  double x0,  double y0);
126 		cairo_matrix_init(cairo_matrix, xx, yx, xy, yy, x0, y0);
127 	}
128 	
129 	/**
130 	 * Modifies matrix to be an identity transformation.
131 	 * Since 1.0
132 	 */
133 	public void initIdentity()
134 	{
135 		// void cairo_matrix_init_identity (cairo_matrix_t *matrix);
136 		cairo_matrix_init_identity(cairo_matrix);
137 	}
138 	
139 	/**
140 	 * Initializes matrix to a transformation that translates by tx and
141 	 * ty in the X and Y dimensions, respectively.
142 	 * Since 1.0
143 	 * Params:
144 	 * tx = amount to translate in the X direction
145 	 * ty = amount to translate in the Y direction
146 	 */
147 	public void initTranslate(double tx, double ty)
148 	{
149 		// void cairo_matrix_init_translate (cairo_matrix_t *matrix,  double tx,  double ty);
150 		cairo_matrix_init_translate(cairo_matrix, tx, ty);
151 	}
152 	
153 	/**
154 	 * Initializes matrix to a transformation that scales by sx and sy
155 	 * in the X and Y dimensions, respectively.
156 	 * Since 1.0
157 	 * Params:
158 	 * sx = scale factor in the X direction
159 	 * sy = scale factor in the Y direction
160 	 */
161 	public void initScale(double sx, double sy)
162 	{
163 		// void cairo_matrix_init_scale (cairo_matrix_t *matrix,  double sx,  double sy);
164 		cairo_matrix_init_scale(cairo_matrix, sx, sy);
165 	}
166 	
167 	/**
168 	 * Initialized matrix to a transformation that rotates by radians.
169 	 * Since 1.0
170 	 * Params:
171 	 * radians = angle of rotation, in radians. The direction of rotation
172 	 * is defined such that positive angles rotate in the direction from
173 	 * the positive X axis toward the positive Y axis. With the default
174 	 * axis orientation of cairo, positive angles rotate in a clockwise
175 	 * direction.
176 	 */
177 	public void initRotate(double radians)
178 	{
179 		// void cairo_matrix_init_rotate (cairo_matrix_t *matrix,  double radians);
180 		cairo_matrix_init_rotate(cairo_matrix, radians);
181 	}
182 	
183 	/**
184 	 * Applies a translation by tx, ty to the transformation in
185 	 * matrix. The effect of the new transformation is to first translate
186 	 * the coordinates by tx and ty, then apply the original transformation
187 	 * to the coordinates.
188 	 * Since 1.0
189 	 * Params:
190 	 * tx = amount to translate in the X direction
191 	 * ty = amount to translate in the Y direction
192 	 */
193 	public void translate(double tx, double ty)
194 	{
195 		// void cairo_matrix_translate (cairo_matrix_t *matrix,  double tx,  double ty);
196 		cairo_matrix_translate(cairo_matrix, tx, ty);
197 	}
198 	
199 	/**
200 	 * Applies scaling by sx, sy to the transformation in matrix. The
201 	 * effect of the new transformation is to first scale the coordinates
202 	 * by sx and sy, then apply the original transformation to the coordinates.
203 	 * Since 1.0
204 	 * Params:
205 	 * sx = scale factor in the X direction
206 	 * sy = scale factor in the Y direction
207 	 */
208 	public void scale(double sx, double sy)
209 	{
210 		// void cairo_matrix_scale (cairo_matrix_t *matrix,  double sx,  double sy);
211 		cairo_matrix_scale(cairo_matrix, sx, sy);
212 	}
213 	
214 	/**
215 	 * Applies rotation by radians to the transformation in
216 	 * matrix. The effect of the new transformation is to first rotate the
217 	 * coordinates by radians, then apply the original transformation
218 	 * to the coordinates.
219 	 * Since 1.0
220 	 * Params:
221 	 * radians = angle of rotation, in radians. The direction of rotation
222 	 * is defined such that positive angles rotate in the direction from
223 	 * the positive X axis toward the positive Y axis. With the default
224 	 * axis orientation of cairo, positive angles rotate in a clockwise
225 	 * direction.
226 	 */
227 	public void rotate(double radians)
228 	{
229 		// void cairo_matrix_rotate (cairo_matrix_t *matrix,  double radians);
230 		cairo_matrix_rotate(cairo_matrix, radians);
231 	}
232 	
233 	/**
234 	 * Changes matrix to be the inverse of its original value. Not
235 	 * all transformation matrices have inverses; if the matrix
236 	 * collapses points together (it is degenerate),
237 	 * then it has no inverse and this function will fail.
238 	 * Since 1.0
239 	 * Returns: If matrix has an inverse, modifies matrix to be the inverse matrix and returns CAIRO_STATUS_SUCCESS. Otherwise, returns CAIRO_STATUS_INVALID_MATRIX.
240 	 */
241 	public cairo_status_t invert()
242 	{
243 		// cairo_status_t cairo_matrix_invert (cairo_matrix_t *matrix);
244 		return cairo_matrix_invert(cairo_matrix);
245 	}
246 	
247 	/**
248 	 * Multiplies the affine transformations in a and b together
249 	 * and stores the result in result. The effect of the resulting
250 	 * transformation is to first apply the transformation in a to the
251 	 * coordinates and then apply the transformation in b to the
252 	 * coordinates.
253 	 * It is allowable for result to be identical to either a or b.
254 	 * Since 1.0
255 	 * Params:
256 	 * a = a cairo_matrix_t
257 	 * b = a cairo_matrix_t
258 	 */
259 	public void multiply(Matrix a, Matrix b)
260 	{
261 		// void cairo_matrix_multiply (cairo_matrix_t *result,  const cairo_matrix_t *a,  const cairo_matrix_t *b);
262 		cairo_matrix_multiply(cairo_matrix, (a is null) ? null : a.getMatrixStruct(), (b is null) ? null : b.getMatrixStruct());
263 	}
264 	
265 	/**
266 	 * Transforms the distance vector (dx,dy) by matrix. This is
267 	 * similar to cairo_matrix_transform_point() except that the translation
268 	 * components of the transformation are ignored. The calculation of
269 	 * Since 1.0
270 	 * Params:
271 	 * dx = X component of a distance vector. An in/out parameter
272 	 * dy = Y component of a distance vector. An in/out parameter
273 	 */
274 	public void transformDistance(ref double dx, ref double dy)
275 	{
276 		// void cairo_matrix_transform_distance (const cairo_matrix_t *matrix,  double *dx,  double *dy);
277 		cairo_matrix_transform_distance(cairo_matrix, &dx, &dy);
278 	}
279 	
280 	/**
281 	 * Transforms the point (x, y) by matrix.
282 	 * Since 1.0
283 	 * Params:
284 	 * x = X position. An in/out parameter
285 	 * y = Y position. An in/out parameter
286 	 */
287 	public void transformPoint(ref double x, ref double y)
288 	{
289 		// void cairo_matrix_transform_point (const cairo_matrix_t *matrix,  double *x,  double *y);
290 		cairo_matrix_transform_point(cairo_matrix, &x, &y);
291 	}
292 }