graphene/auto/
point.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, Vec2};
6use glib::translate::*;
7
8glib::wrapper! {
9    pub struct Point(BoxedInline<ffi::graphene_point_t>);
10
11    match fn {
12        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_point_get_type(), ptr as *mut _) as *mut ffi::graphene_point_t,
13        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_point_get_type(), ptr as *mut _),
14        type_ => || ffi::graphene_point_get_type(),
15    }
16}
17
18impl Point {
19    #[doc(alias = "graphene_point_distance")]
20    pub fn distance(&self, b: &Point) -> (f32, f32, f32) {
21        unsafe {
22            let mut d_x = std::mem::MaybeUninit::uninit();
23            let mut d_y = std::mem::MaybeUninit::uninit();
24            let ret = ffi::graphene_point_distance(
25                self.to_glib_none().0,
26                b.to_glib_none().0,
27                d_x.as_mut_ptr(),
28                d_y.as_mut_ptr(),
29            );
30            (ret, d_x.assume_init(), d_y.assume_init())
31        }
32    }
33
34    #[doc(alias = "graphene_point_equal")]
35    fn equal(&self, b: &Point) -> bool {
36        unsafe { ffi::graphene_point_equal(self.to_glib_none().0, b.to_glib_none().0) }
37    }
38
39    #[doc(alias = "graphene_point_interpolate")]
40    #[must_use]
41    pub fn interpolate(&self, b: &Point, factor: f64) -> Point {
42        unsafe {
43            let mut res = Point::uninitialized();
44            ffi::graphene_point_interpolate(
45                self.to_glib_none().0,
46                b.to_glib_none().0,
47                factor,
48                res.to_glib_none_mut().0,
49            );
50            res
51        }
52    }
53
54    #[doc(alias = "graphene_point_near")]
55    pub fn near(&self, b: &Point, epsilon: f32) -> bool {
56        unsafe { ffi::graphene_point_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) }
57    }
58
59    #[doc(alias = "graphene_point_to_vec2")]
60    pub fn to_vec2(&self) -> Vec2 {
61        unsafe {
62            let mut v = Vec2::uninitialized();
63            ffi::graphene_point_to_vec2(self.to_glib_none().0, v.to_glib_none_mut().0);
64            v
65        }
66    }
67
68    #[doc(alias = "graphene_point_zero")]
69    pub fn zero() -> Point {
70        assert_initialized_main_thread!();
71        unsafe { from_glib_none(ffi::graphene_point_zero()) }
72    }
73}
74
75impl PartialEq for Point {
76    #[inline]
77    fn eq(&self, other: &Self) -> bool {
78        self.equal(other)
79    }
80}
81
82impl Eq for Point {}