1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use crate::Vec2;
use glib::translate::*;
use std::mem;
glib::wrapper! {
pub struct Point(BoxedInline<ffi::graphene_point_t>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_point_get_type(), ptr as *mut _) as *mut ffi::graphene_point_t,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_point_get_type(), ptr as *mut _),
type_ => || ffi::graphene_point_get_type(),
}
}
impl Point {
#[doc(alias = "graphene_point_distance")]
pub fn distance(&self, b: &Point) -> (f32, f32, f32) {
unsafe {
let mut d_x = mem::MaybeUninit::uninit();
let mut d_y = mem::MaybeUninit::uninit();
let ret = ffi::graphene_point_distance(
self.to_glib_none().0,
b.to_glib_none().0,
d_x.as_mut_ptr(),
d_y.as_mut_ptr(),
);
let d_x = d_x.assume_init();
let d_y = d_y.assume_init();
(ret, d_x, d_y)
}
}
#[doc(alias = "graphene_point_equal")]
fn equal(&self, b: &Point) -> bool {
unsafe { ffi::graphene_point_equal(self.to_glib_none().0, b.to_glib_none().0) }
}
#[doc(alias = "graphene_point_interpolate")]
#[must_use]
pub fn interpolate(&self, b: &Point, factor: f64) -> Point {
unsafe {
let mut res = Point::uninitialized();
ffi::graphene_point_interpolate(
self.to_glib_none().0,
b.to_glib_none().0,
factor,
res.to_glib_none_mut().0,
);
res
}
}
#[doc(alias = "graphene_point_near")]
pub fn near(&self, b: &Point, epsilon: f32) -> bool {
unsafe { ffi::graphene_point_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) }
}
#[doc(alias = "graphene_point_to_vec2")]
pub fn to_vec2(&self) -> Vec2 {
unsafe {
let mut v = Vec2::uninitialized();
ffi::graphene_point_to_vec2(self.to_glib_none().0, v.to_glib_none_mut().0);
v
}
}
#[doc(alias = "graphene_point_zero")]
pub fn zero() -> Point {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::graphene_point_zero()) }
}
}
impl PartialEq for Point {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for Point {}