1use std::fmt;
4
5use glib::translate::*;
6
7use crate::{ffi, Matrix, Rectangle};
8
9impl Matrix {
10 pub fn new(xx: f64, xy: f64, yx: f64, yy: f64, x0: f64, y0: f64) -> Self {
11 unsafe {
12 Self::unsafe_from(ffi::PangoMatrix {
13 xx,
14 xy,
15 yx,
16 yy,
17 x0,
18 y0,
19 })
20 }
21 }
22
23 #[doc(alias = "pango_matrix_transform_pixel_rectangle")]
24 pub fn transform_pixel_rectangle(&self, rect: &mut Rectangle) {
25 unsafe {
26 ffi::pango_matrix_transform_pixel_rectangle(
27 self.to_glib_none().0,
28 rect.to_glib_none_mut().0,
29 )
30 }
31 }
32
33 #[doc(alias = "pango_matrix_transform_rectangle")]
34 pub fn transform_rectangle(&self, rect: &mut Rectangle) {
35 unsafe {
36 ffi::pango_matrix_transform_rectangle(self.to_glib_none().0, rect.to_glib_none_mut().0)
37 }
38 }
39
40 pub fn xx(&self) -> f64 {
41 self.inner.xx
42 }
43
44 pub fn xy(&self) -> f64 {
45 self.inner.xy
46 }
47
48 pub fn yx(&self) -> f64 {
49 self.inner.yx
50 }
51
52 pub fn yy(&self) -> f64 {
53 self.inner.yy
54 }
55
56 pub fn x0(&self) -> f64 {
57 self.inner.x0
58 }
59
60 pub fn y0(&self) -> f64 {
61 self.inner.y0
62 }
63}
64
65impl fmt::Debug for Matrix {
66 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
67 f.debug_struct("Matrix")
68 .field("xx", &self.xx())
69 .field("xy", &self.xy())
70 .field("yx", &self.yx())
71 .field("yy", &self.yy())
72 .field("x0", &self.x0())
73 .field("y0", &self.y0())
74 .finish()
75 }
76}