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