graphene/auto/
vec2.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    pub struct Vec2(BoxedInline<ffi::graphene_vec2_t>);
10
11    match fn {
12        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_vec2_get_type(), ptr as *mut _) as *mut ffi::graphene_vec2_t,
13        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_vec2_get_type(), ptr as *mut _),
14        type_ => || ffi::graphene_vec2_get_type(),
15    }
16}
17
18impl Vec2 {
19    #[doc(alias = "graphene_vec2_add")]
20    #[must_use]
21    pub fn add(&self, b: &Vec2) -> Vec2 {
22        unsafe {
23            let mut res = Vec2::uninitialized();
24            ffi::graphene_vec2_add(
25                self.to_glib_none().0,
26                b.to_glib_none().0,
27                res.to_glib_none_mut().0,
28            );
29            res
30        }
31    }
32
33    #[doc(alias = "graphene_vec2_divide")]
34    #[must_use]
35    pub fn divide(&self, b: &Vec2) -> Vec2 {
36        unsafe {
37            let mut res = Vec2::uninitialized();
38            ffi::graphene_vec2_divide(
39                self.to_glib_none().0,
40                b.to_glib_none().0,
41                res.to_glib_none_mut().0,
42            );
43            res
44        }
45    }
46
47    #[doc(alias = "graphene_vec2_dot")]
48    pub fn dot(&self, b: &Vec2) -> f32 {
49        unsafe { ffi::graphene_vec2_dot(self.to_glib_none().0, b.to_glib_none().0) }
50    }
51
52    #[doc(alias = "graphene_vec2_equal")]
53    fn equal(&self, v2: &Vec2) -> bool {
54        unsafe { ffi::graphene_vec2_equal(self.to_glib_none().0, v2.to_glib_none().0) }
55    }
56
57    #[doc(alias = "graphene_vec2_get_x")]
58    #[doc(alias = "get_x")]
59    pub fn x(&self) -> f32 {
60        unsafe { ffi::graphene_vec2_get_x(self.to_glib_none().0) }
61    }
62
63    #[doc(alias = "graphene_vec2_get_y")]
64    #[doc(alias = "get_y")]
65    pub fn y(&self) -> f32 {
66        unsafe { ffi::graphene_vec2_get_y(self.to_glib_none().0) }
67    }
68
69    #[doc(alias = "graphene_vec2_interpolate")]
70    #[must_use]
71    pub fn interpolate(&self, v2: &Vec2, factor: f64) -> Vec2 {
72        unsafe {
73            let mut res = Vec2::uninitialized();
74            ffi::graphene_vec2_interpolate(
75                self.to_glib_none().0,
76                v2.to_glib_none().0,
77                factor,
78                res.to_glib_none_mut().0,
79            );
80            res
81        }
82    }
83
84    #[doc(alias = "graphene_vec2_length")]
85    pub fn length(&self) -> f32 {
86        unsafe { ffi::graphene_vec2_length(self.to_glib_none().0) }
87    }
88
89    #[doc(alias = "graphene_vec2_max")]
90    #[must_use]
91    pub fn max(&self, b: &Vec2) -> Vec2 {
92        unsafe {
93            let mut res = Vec2::uninitialized();
94            ffi::graphene_vec2_max(
95                self.to_glib_none().0,
96                b.to_glib_none().0,
97                res.to_glib_none_mut().0,
98            );
99            res
100        }
101    }
102
103    #[doc(alias = "graphene_vec2_min")]
104    #[must_use]
105    pub fn min(&self, b: &Vec2) -> Vec2 {
106        unsafe {
107            let mut res = Vec2::uninitialized();
108            ffi::graphene_vec2_min(
109                self.to_glib_none().0,
110                b.to_glib_none().0,
111                res.to_glib_none_mut().0,
112            );
113            res
114        }
115    }
116
117    #[doc(alias = "graphene_vec2_multiply")]
118    #[must_use]
119    pub fn multiply(&self, b: &Vec2) -> Vec2 {
120        unsafe {
121            let mut res = Vec2::uninitialized();
122            ffi::graphene_vec2_multiply(
123                self.to_glib_none().0,
124                b.to_glib_none().0,
125                res.to_glib_none_mut().0,
126            );
127            res
128        }
129    }
130
131    #[doc(alias = "graphene_vec2_near")]
132    pub fn near(&self, v2: &Vec2, epsilon: f32) -> bool {
133        unsafe { ffi::graphene_vec2_near(self.to_glib_none().0, v2.to_glib_none().0, epsilon) }
134    }
135
136    #[doc(alias = "graphene_vec2_negate")]
137    #[must_use]
138    pub fn negate(&self) -> Vec2 {
139        unsafe {
140            let mut res = Vec2::uninitialized();
141            ffi::graphene_vec2_negate(self.to_glib_none().0, res.to_glib_none_mut().0);
142            res
143        }
144    }
145
146    #[doc(alias = "graphene_vec2_normalize")]
147    #[must_use]
148    pub fn normalize(&self) -> Vec2 {
149        unsafe {
150            let mut res = Vec2::uninitialized();
151            ffi::graphene_vec2_normalize(self.to_glib_none().0, res.to_glib_none_mut().0);
152            res
153        }
154    }
155
156    #[doc(alias = "graphene_vec2_scale")]
157    #[must_use]
158    pub fn scale(&self, factor: f32) -> Vec2 {
159        unsafe {
160            let mut res = Vec2::uninitialized();
161            ffi::graphene_vec2_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0);
162            res
163        }
164    }
165
166    #[doc(alias = "graphene_vec2_subtract")]
167    #[must_use]
168    pub fn subtract(&self, b: &Vec2) -> Vec2 {
169        unsafe {
170            let mut res = Vec2::uninitialized();
171            ffi::graphene_vec2_subtract(
172                self.to_glib_none().0,
173                b.to_glib_none().0,
174                res.to_glib_none_mut().0,
175            );
176            res
177        }
178    }
179
180    #[doc(alias = "graphene_vec2_one")]
181    pub fn one() -> Vec2 {
182        assert_initialized_main_thread!();
183        unsafe { from_glib_none(ffi::graphene_vec2_one()) }
184    }
185
186    #[doc(alias = "graphene_vec2_x_axis")]
187    pub fn x_axis() -> Vec2 {
188        assert_initialized_main_thread!();
189        unsafe { from_glib_none(ffi::graphene_vec2_x_axis()) }
190    }
191
192    #[doc(alias = "graphene_vec2_y_axis")]
193    pub fn y_axis() -> Vec2 {
194        assert_initialized_main_thread!();
195        unsafe { from_glib_none(ffi::graphene_vec2_y_axis()) }
196    }
197
198    #[doc(alias = "graphene_vec2_zero")]
199    pub fn zero() -> Vec2 {
200        assert_initialized_main_thread!();
201        unsafe { from_glib_none(ffi::graphene_vec2_zero()) }
202    }
203}
204
205impl PartialEq for Vec2 {
206    #[inline]
207    fn eq(&self, other: &Self) -> bool {
208        self.equal(other)
209    }
210}
211
212impl Eq for Vec2 {}