Skip to main content

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    /// .
82    ///
83    /// # Returns
84    ///
85    /// the slant ratio of @self
86    #[cfg(feature = "v1_50")]
87    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
88    #[doc(alias = "pango_matrix_get_slant_ratio")]
89    #[doc(alias = "get_slant_ratio")]
90    pub fn slant_ratio(&self) -> f64 {
91        unsafe { ffi::pango_matrix_get_slant_ratio(self.to_glib_none().0) }
92    }
93
94    /// Changes the transformation represented by @self to be the
95    /// transformation given by first rotating by @degrees degrees
96    /// counter-clockwise then applying the original transformation.
97    /// ## `degrees`
98    /// degrees to rotate counter-clockwise
99    #[doc(alias = "pango_matrix_rotate")]
100    pub fn rotate(&mut self, degrees: f64) {
101        unsafe {
102            ffi::pango_matrix_rotate(self.to_glib_none_mut().0, degrees);
103        }
104    }
105
106    /// Changes the transformation represented by @self to be the
107    /// transformation given by first scaling by @sx in the X direction
108    /// and @sy in the Y direction then applying the original
109    /// transformation.
110    /// ## `scale_x`
111    /// amount to scale by in X direction
112    /// ## `scale_y`
113    /// amount to scale by in Y direction
114    #[doc(alias = "pango_matrix_scale")]
115    pub fn scale(&mut self, scale_x: f64, scale_y: f64) {
116        unsafe {
117            ffi::pango_matrix_scale(self.to_glib_none_mut().0, scale_x, scale_y);
118        }
119    }
120
121    /// Transforms the distance vector (@dx,@dy) by @self.
122    ///
123    /// This is similar to [`transform_point()`][Self::transform_point()],
124    /// except that the translation components of the transformation
125    /// are ignored. The calculation of the returned vector is as follows:
126    ///
127    /// ```text
128    /// dx2 = dx1 * xx + dy1 * xy;
129    /// dy2 = dx1 * yx + dy1 * yy;
130    /// ```
131    ///
132    /// Affine transformations are position invariant, so the same vector
133    /// always transforms to the same vector. If (@x1,@y1) transforms
134    /// to (@x2,@y2) then (@x1+@dx1,@y1+@dy1) will transform to
135    /// (@x1+@dx2,@y1+@dy2) for all values of @x1 and @x2.
136    ///
137    /// # Returns
138    ///
139    ///
140    /// ## `dx`
141    /// in/out X component of a distance vector
142    ///
143    /// ## `dy`
144    /// in/out Y component of a distance vector
145    #[doc(alias = "pango_matrix_transform_distance")]
146    pub fn transform_distance(&self, dx: &mut f64, dy: &mut f64) {
147        unsafe {
148            ffi::pango_matrix_transform_distance(self.to_glib_none().0, dx, dy);
149        }
150    }
151
152    /// Transforms the point (@x, @y) by @self.
153    ///
154    /// # Returns
155    ///
156    ///
157    /// ## `x`
158    /// in/out X position
159    ///
160    /// ## `y`
161    /// in/out Y position
162    #[doc(alias = "pango_matrix_transform_point")]
163    pub fn transform_point(&self, x: &mut f64, y: &mut f64) {
164        unsafe {
165            ffi::pango_matrix_transform_point(self.to_glib_none().0, x, y);
166        }
167    }
168
169    /// Changes the transformation represented by @self to be the
170    /// transformation given by first translating by (@tx, @ty)
171    /// then applying the original transformation.
172    /// ## `tx`
173    /// amount to translate in the X direction
174    /// ## `ty`
175    /// amount to translate in the Y direction
176    #[doc(alias = "pango_matrix_translate")]
177    pub fn translate(&mut self, tx: f64, ty: f64) {
178        unsafe {
179            ffi::pango_matrix_translate(self.to_glib_none_mut().0, tx, ty);
180        }
181    }
182}