graphene/auto/
point.rs
1use crate::{ffi, Vec2};
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct Point(BoxedInline<ffi::graphene_point_t>);
11
12 match fn {
13 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_point_get_type(), ptr as *mut _) as *mut ffi::graphene_point_t,
14 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_point_get_type(), ptr as *mut _),
15 type_ => || ffi::graphene_point_get_type(),
16 }
17}
18
19impl Point {
20 #[doc(alias = "graphene_point_distance")]
34 pub fn distance(&self, b: &Point) -> (f32, f32, f32) {
35 unsafe {
36 let mut d_x = std::mem::MaybeUninit::uninit();
37 let mut d_y = std::mem::MaybeUninit::uninit();
38 let ret = ffi::graphene_point_distance(
39 self.to_glib_none().0,
40 b.to_glib_none().0,
41 d_x.as_mut_ptr(),
42 d_y.as_mut_ptr(),
43 );
44 (ret, d_x.assume_init(), d_y.assume_init())
45 }
46 }
47
48 #[doc(alias = "graphene_point_equal")]
49 fn equal(&self, b: &Point) -> bool {
50 unsafe { ffi::graphene_point_equal(self.to_glib_none().0, b.to_glib_none().0) }
51 }
52
53 #[doc(alias = "graphene_point_interpolate")]
67 #[must_use]
68 pub fn interpolate(&self, b: &Point, factor: f64) -> Point {
69 unsafe {
70 let mut res = Point::uninitialized();
71 ffi::graphene_point_interpolate(
72 self.to_glib_none().0,
73 b.to_glib_none().0,
74 factor,
75 res.to_glib_none_mut().0,
76 );
77 res
78 }
79 }
80
81 #[doc(alias = "graphene_point_near")]
92 pub fn near(&self, b: &Point, epsilon: f32) -> bool {
93 unsafe { ffi::graphene_point_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) }
94 }
95
96 #[doc(alias = "graphene_point_to_vec2")]
105 pub fn to_vec2(&self) -> Vec2 {
106 unsafe {
107 let mut v = Vec2::uninitialized();
108 ffi::graphene_point_to_vec2(self.to_glib_none().0, v.to_glib_none_mut().0);
109 v
110 }
111 }
112
113 #[doc(alias = "graphene_point_zero")]
119 pub fn zero() -> Point {
120 assert_initialized_main_thread!();
121 unsafe { from_glib_none(ffi::graphene_point_zero()) }
122 }
123}
124
125impl PartialEq for Point {
126 #[inline]
127 fn eq(&self, other: &Self) -> bool {
128 self.equal(other)
129 }
130}
131
132impl Eq for Point {}