alternative to assert
[gtkD.git] / gtkD / src / cairoLib / Matrix.d
blobd602960429fb5ca88bebd2e9378b0a7824868d68
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = cairo-cairo-matrix-t.html
26 * outPack = cairoLib
27 * outFile = Matrix
28 * strct = cairo_matrix_t
29 * realStrct=
30 * ctorStrct=
31 * clss = Matrix
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - cairo_matrix_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * structWrap:
46 * - surfaceT* -> Surface
47 * module aliases:
48 * local aliases:
51 module cairoLib.Matrix;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gtkc.cairoLibtypes;
63 private import gtkc.cairoLib;
66 private import glib.Str;
71 /**
72 * Description
73 * cairo_matrix_t is used throughout cairo to convert between different
74 * coordinate spaces. A cairo_matrix_t holds an affine transformation,
75 * such as a scale, rotation, shear, or a combination of these.
76 * The transformation of a point (x,y)
77 * is given by:
78 * x_new = xx * x + xy * y + x0;
79 * y_new = yx * x + yy * y + y0;
80 * The current transformation matrix of a cairo_t, represented as a
81 * cairo_matrix_t, defines the transformation from user-space
82 * coordinates to device-space coordinates. See cairo_get_matrix() and
83 * cairo_set_matrix().
85 public class Matrix
88 /** the main Gtk struct */
89 protected cairo_matrix_t* cairo_matrix;
92 public cairo_matrix_t* getMatrixStruct()
94 return cairo_matrix;
98 /** the main Gtk struct as a void* */
99 protected void* getStruct()
101 return cast(void*)cairo_matrix;
105 * Sets our main struct and passes it to the parent class
107 public this (cairo_matrix_t* cairo_matrix)
109 version(noAssert)
111 if ( cairo_matrix is null )
113 int zero = 0;
114 version(Tango)
116 Stdout("struct cairo_matrix is null on constructor").newline;
118 else
120 printf("struct cairo_matrix is null on constructor");
122 zero = zero / zero;
125 else
127 assert(cairo_matrix !is null, "struct cairo_matrix is null on constructor");
129 this.cairo_matrix = cairo_matrix;
137 * Sets matrix to be the affine transformation given by
138 * xx, yx, xy, yy, x0, y0. The transformation is given
139 * by:
140 * x_new = xx * x + xy * y + x0;
141 * y_new = yx * x + yy * y + y0;
142 * matrix:
143 * a cairo_matrix_t
144 * xx:
145 * xx component of the affine transformation
146 * yx:
147 * yx component of the affine transformation
148 * xy:
149 * xy component of the affine transformation
150 * yy:
151 * yy component of the affine transformation
152 * x0:
153 * X translation component of the affine transformation
154 * y0:
155 * Y translation component of the affine transformation
157 public void init(double xx, double yx, double xy, double yy, double x0, double y0)
159 // void cairo_matrix_init (cairo_matrix_t *matrix, double xx, double yx, double xy, double yy, double x0, double y0);
160 cairo_matrix_init(cairo_matrix, xx, yx, xy, yy, x0, y0);
164 * Modifies matrix to be an identity transformation.
165 * matrix:
166 * a cairo_matrix_t
168 public void initIdentity()
170 // void cairo_matrix_init_identity (cairo_matrix_t *matrix);
171 cairo_matrix_init_identity(cairo_matrix);
175 * Initializes matrix to a transformation that translates by tx and
176 * ty in the X and Y dimensions, respectively.
177 * matrix:
178 * a cairo_matrix_t
179 * tx:
180 * amount to translate in the X direction
181 * ty:
182 * amount to translate in the Y direction
184 public void initTranslate(double tx, double ty)
186 // void cairo_matrix_init_translate (cairo_matrix_t *matrix, double tx, double ty);
187 cairo_matrix_init_translate(cairo_matrix, tx, ty);
191 * Initializes matrix to a transformation that scales by sx and sy
192 * in the X and Y dimensions, respectively.
193 * matrix:
194 * a cairo_matrix_t
195 * sx:
196 * scale factor in the X direction
197 * sy:
198 * scale factor in the Y direction
200 public void initScale(double sx, double sy)
202 // void cairo_matrix_init_scale (cairo_matrix_t *matrix, double sx, double sy);
203 cairo_matrix_init_scale(cairo_matrix, sx, sy);
207 * Initialized matrix to a transformation that rotates by radians.
208 * matrix:
209 * a cairo_matrix_t
210 * radians:
211 * angle of rotation, in radians. The direction of rotation
212 * is defined such that positive angles rotate in the direction from
213 * the positive X axis toward the positive Y axis. With the default
214 * axis orientation of cairo, positive angles rotate in a clockwise
215 * direction.
217 public void initRotate(double radians)
219 // void cairo_matrix_init_rotate (cairo_matrix_t *matrix, double radians);
220 cairo_matrix_init_rotate(cairo_matrix, radians);
224 * Applies a translation by tx, ty to the transformation in
225 * matrix. The effect of the new transformation is to first translate
226 * the coordinates by tx and ty, then apply the original transformation
227 * to the coordinates.
228 * matrix:
229 * a cairo_matrix_t
230 * tx:
231 * amount to translate in the X direction
232 * ty:
233 * amount to translate in the Y direction
235 public void translate(double tx, double ty)
237 // void cairo_matrix_translate (cairo_matrix_t *matrix, double tx, double ty);
238 cairo_matrix_translate(cairo_matrix, tx, ty);
242 * Applies scaling by tx, ty to the transformation in matrix. The
243 * effect of the new transformation is to first scale the coordinates
244 * by sx and sy, then apply the original transformation to the coordinates.
245 * matrix:
246 * a cairo_matrix_t
247 * sx:
248 * scale factor in the X direction
249 * sy:
250 * scale factor in the Y direction
252 public void scale(double sx, double sy)
254 // void cairo_matrix_scale (cairo_matrix_t *matrix, double sx, double sy);
255 cairo_matrix_scale(cairo_matrix, sx, sy);
259 * Applies rotation by radians to the transformation in
260 * matrix. The effect of the new transformation is to first rotate the
261 * coordinates by radians, then apply the original transformation
262 * to the coordinates.
263 * matrix:
264 * a cairo_matrix_t
265 * radians:
266 * angle of rotation, in radians. The direction of rotation
267 * is defined such that positive angles rotate in the direction from
268 * the positive X axis toward the positive Y axis. With the default
269 * axis orientation of cairo, positive angles rotate in a clockwise
270 * direction.
272 public void rotate(double radians)
274 // void cairo_matrix_rotate (cairo_matrix_t *matrix, double radians);
275 cairo_matrix_rotate(cairo_matrix, radians);
279 * Changes matrix to be the inverse of it's original value. Not
280 * all transformation matrices have inverses; if the matrix
281 * collapses points together (it is degenerate),
282 * then it has no inverse and this function will fail.
283 * Returns: If matrix has an inverse, modifies matrix to
284 * be the inverse matrix and returns CAIRO_STATUS_SUCCESS. Otherwise,
285 * matrix:
286 * a cairo_matrix_t
287 * Returns:
288 * CAIRO_STATUS_INVALID_MATRIX.
290 public cairo_status_t invert()
292 // cairo_status_t cairo_matrix_invert (cairo_matrix_t *matrix);
293 return cairo_matrix_invert(cairo_matrix);
297 * Multiplies the affine transformations in a and b together
298 * and stores the result in result. The effect of the resulting
299 * transformation is to first apply the transformation in a to the
300 * coordinates and then apply the transformation in b to the
301 * coordinates.
302 * It is allowable for result to be identical to either a or b.
303 * result:
304 * a cairo_matrix_t in which to store the result
305 * a:
306 * a cairo_matrix_t
307 * b:
308 * a cairo_matrix_t
310 public void multiply(cairo_matrix_t* a, cairo_matrix_t* b)
312 // void cairo_matrix_multiply (cairo_matrix_t *result, const cairo_matrix_t *a, const cairo_matrix_t *b);
313 cairo_matrix_multiply(cairo_matrix, a, b);
317 * Transforms the distance vector (dx,dy) by matrix. This is
318 * similar to cairo_matrix_transform_point() except that the translation
319 * components of the transformation are ignored. The calculation of
320 * the returned vector is as follows:
321 * dx2 = dx1 * a + dy1 * c;
322 * dy2 = dx1 * b + dy1 * d;
323 * Affine transformations are position invariant, so the same vector
324 * always transforms to the same vector. If (x1,y1) transforms
325 * to (x2,y2) then (x1+dx1,y1+dy1) will transform to
326 * (x1+dx2,y1+dy2) for all values of x1 and x2.
327 * matrix:
328 * a cairo_matrix_t
329 * dx:
330 * X component of a distance vector. An in/out parameter
331 * dy:
332 * Y component of a distance vector. An in/out parameter
334 public void transformDistance(double* dx, double* dy)
336 // void cairo_matrix_transform_distance (const cairo_matrix_t *matrix, double *dx, double *dy);
337 cairo_matrix_transform_distance(cairo_matrix, dx, dy);
341 * Transforms the point (x, y) by matrix.
342 * matrix:
343 * a cairo_matrix_t
344 * x:
345 * X position. An in/out parameter
346 * y:
347 * Y position. An in/out parameter
349 public void transformPoint(double* x, double* y)
351 // void cairo_matrix_transform_point (const cairo_matrix_t *matrix, double *x, double *y);
352 cairo_matrix_transform_point(cairo_matrix, x, y);