1 module pango.matrix;
2 
3 import pango.utils;
4 import pango.types;
5 import pango.c.matrix;
6 
7 
8 /**
9  * Matrix:
10  * @xx: 1st component of the transformation matrix
11  * @xy: 2nd component of the transformation matrix
12  * @yx: 3rd component of the transformation matrix
13  * @yy: 4th component of the transformation matrix
14  * @x0: x translation
15  * @y0: y translation
16  *
17  * A structure specifying a transformation between user-space
18  * coordinates and device coordinates. The transformation
19  * is given by
20  *
21  * <programlisting>
22  * x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
23  * y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;
24  * </programlisting>
25  *
26  * Since: 1.6
27  **/
28 
29 struct Matrix
30 {
31     private PangoMatrix * nativePtr_;
32 
33 
34     @disable this();
35     package this(PangoMatrix *ptr) { nativePtr_ = ptr; }
36 
37 
38     pure @property inout(PangoMatrix)* nativePtr() inout { return nativePtr_; }
39 
40     Matrix copy() const {
41         return Matrix(pango_matrix_copy(nativePtr));
42     }
43 
44     void free() {
45         pango_matrix_free(nativePtr_);
46         nativePtr_ = null;
47     }
48 
49     void translate(double tx, double ty) {
50         pango_matrix_translate(nativePtr, tx, ty);
51     }
52 
53     void scale(double sx, double sy) {
54         pango_matrix_scale(nativePtr, sx, sy);
55     }
56 
57     void rotate(double degrees) {
58         pango_matrix_rotate(nativePtr, degrees);
59     }
60 
61     void concat(const(Matrix) newMatrix) {
62         pango_matrix_concat(nativePtr, newMatrix.nativePtr);
63     }
64 
65     void transformPoint(ref double x, ref double y) const {
66         pango_matrix_transform_point(nativePtr, &x, &y);
67     }
68 
69     void transformDistance(ref double dx, ref double dy) const {
70         pango_matrix_transform_distance(nativePtr, &dx, &dy);
71     }
72 
73     void transformRectangle(ref Rectangle rect) const {
74         pango_matrix_transform_rectangle(nativePtr, &rect);
75     }
76 
77     void transformPixelRectangle(ref Rectangle rect) const {
78         pango_matrix_transform_pixel_rectangle(nativePtr, &rect);
79     }
80 
81     pure @property double fontScaleFactor() const {
82         return pango_matrix_get_font_scale_factor(nativePtr);
83     }
84 }
85 
86