pango/auto/matrix.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 /// y0;
10 /// ```text
11 ///
12 pub struct Matrix(BoxedInline<ffi::PangoMatrix>);
13
14 match fn {
15 copy => |ptr| ffi::pango_matrix_copy(ptr),
16 free => |ptr| ffi::pango_matrix_free(ptr),
17 type_ => || ffi::pango_matrix_get_type(),
18 }
19}
20
21impl Matrix {
22 /// Changes the transformation represented by @self to be the
23 /// transformation given by first applying transformation
24 /// given by @new_matrix then applying the original transformation.
25 /// ## `new_matrix`
26 /// a [`Matrix`][crate::Matrix]
27 #[doc(alias = "pango_matrix_concat")]
28 pub fn concat(&mut self, new_matrix: &Matrix) {
29 unsafe {
30 ffi::pango_matrix_concat(self.to_glib_none_mut().0, new_matrix.to_glib_none().0);
31 }
32 }
33
34 /// Returns the scale factor of a matrix on the height of the font.
35 ///
36 /// That is, the scale factor in the direction perpendicular to the
37 /// vector that the X coordinate is mapped to. If the scale in the X
38 /// coordinate is needed as well, use [`font_scale_factors()`][Self::font_scale_factors()].
39 ///
40 /// # Returns
41 ///
42 /// the scale factor of @self on the height of the font,
43 /// or 1.0 if @self is [`None`].
44 #[doc(alias = "pango_matrix_get_font_scale_factor")]
45 #[doc(alias = "get_font_scale_factor")]
46 pub fn font_scale_factor(&self) -> f64 {
47 unsafe { ffi::pango_matrix_get_font_scale_factor(self.to_glib_none().0) }
48 }
49
50 /// Calculates the scale factor of a matrix on the width and height of the font.
51 ///
52 /// That is, @xscale is the scale factor in the direction of the X coordinate,
53 /// and @yscale is the scale factor in the direction perpendicular to the
54 /// vector that the X coordinate is mapped to.
55 ///
56 /// Note that output numbers will always be non-negative.
57 ///
58 /// # Returns
59 ///
60 ///
61 /// ## `xscale`
62 /// output scale factor in the x direction
63 ///
64 /// ## `yscale`
65 /// output scale factor perpendicular to the x direction
66 #[doc(alias = "pango_matrix_get_font_scale_factors")]
67 #[doc(alias = "get_font_scale_factors")]
68 pub fn font_scale_factors(&self) -> (f64, f64) {
69 unsafe {
70 let mut xscale = std::mem::MaybeUninit::uninit();
71 let mut yscale = std::mem::MaybeUninit::uninit();
72 ffi::pango_matrix_get_font_scale_factors(
73 self.to_glib_none().0,
74 xscale.as_mut_ptr(),
75 yscale.as_mut_ptr(),
76 );
77 (xscale.assume_init(), yscale.assume_init())
78 }
79 }
80
81 /// Gets the slant ratio of a matrix.
82 ///
83 /// For a simple shear matrix in the form:
84 ///
85 /// 1 λ
86 /// 0 1
87 ///
88 /// this is simply λ.
89 ///
90 /// # Returns
91 ///
92 /// the slant ratio of @self
93 #[cfg(feature = "v1_50")]
94 #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
95 #[doc(alias = "pango_matrix_get_slant_ratio")]
96 #[doc(alias = "get_slant_ratio")]
97 pub fn slant_ratio(&self) -> f64 {
98 unsafe { ffi::pango_matrix_get_slant_ratio(self.to_glib_none().0) }
99 }
100
101 /// Changes the transformation represented by @self to be the
102 /// transformation given by first rotating by @degrees degrees
103 /// counter-clockwise then applying the original transformation.
104 /// ## `degrees`
105 /// degrees to rotate counter-clockwise
106 #[doc(alias = "pango_matrix_rotate")]
107 pub fn rotate(&mut self, degrees: f64) {
108 unsafe {
109 ffi::pango_matrix_rotate(self.to_glib_none_mut().0, degrees);
110 }
111 }
112
113 /// Changes the transformation represented by @self to be the
114 /// transformation given by first scaling by @sx in the X direction
115 /// and @sy in the Y direction then applying the original
116 /// transformation.
117 /// ## `scale_x`
118 /// amount to scale by in X direction
119 /// ## `scale_y`
120 /// amount to scale by in Y direction
121 #[doc(alias = "pango_matrix_scale")]
122 pub fn scale(&mut self, scale_x: f64, scale_y: f64) {
123 unsafe {
124 ffi::pango_matrix_scale(self.to_glib_none_mut().0, scale_x, scale_y);
125 }
126 }
127
128 /// Transforms the distance vector (@dx,@dy) by @self.
129 ///
130 /// This is similar to [`transform_point()`][Self::transform_point()],
131 /// except that the translation components of the transformation
132 /// are ignored. The calculation of the returned vector is as follows:
133 ///
134 /// ```text
135 /// dx2 = dx1 * xx + dy1 * xy;
136 /// dy2 = dx1 * yx + dy1 * yy;
137 /// ```
138 ///
139 /// Affine transformations are position invariant, so the same vector
140 /// always transforms to the same vector. If (@x1,@y1) transforms
141 /// to (@x2,@y2) then (@x1+@dx1,@y1+@dy1) will transform to
142 /// (@x1+@dx2,@y1+@dy2) for all values of @x1 and @x2.
143 ///
144 /// # Returns
145 ///
146 ///
147 /// ## `dx`
148 /// in/out X component of a distance vector
149 ///
150 /// ## `dy`
151 /// in/out Y component of a distance vector
152 #[doc(alias = "pango_matrix_transform_distance")]
153 pub fn transform_distance(&self, dx: &mut f64, dy: &mut f64) {
154 unsafe {
155 ffi::pango_matrix_transform_distance(self.to_glib_none().0, dx, dy);
156 }
157 }
158
159 /// Transforms the point (@x, @y) by @self.
160 ///
161 /// # Returns
162 ///
163 ///
164 /// ## `x`
165 /// in/out X position
166 ///
167 /// ## `y`
168 /// in/out Y position
169 #[doc(alias = "pango_matrix_transform_point")]
170 pub fn transform_point(&self, x: &mut f64, y: &mut f64) {
171 unsafe {
172 ffi::pango_matrix_transform_point(self.to_glib_none().0, x, y);
173 }
174 }
175
176 /// Changes the transformation represented by @self to be the
177 /// transformation given by first translating by (@tx, @ty)
178 /// then applying the original transformation.
179 /// ## `tx`
180 /// amount to translate in the X direction
181 /// ## `ty`
182 /// amount to translate in the Y direction
183 #[doc(alias = "pango_matrix_translate")]
184 pub fn translate(&mut self, tx: f64, ty: f64) {
185 unsafe {
186 ffi::pango_matrix_translate(self.to_glib_none_mut().0, tx, ty);
187 }
188 }
189}