1use crate::{ffi, Box, Point3D};
6use glib::translate::*;
7
8glib::wrapper! {
9    pub struct Sphere(BoxedInline<ffi::graphene_sphere_t>);
11
12    match fn {
13        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_sphere_get_type(), ptr as *mut _) as *mut ffi::graphene_sphere_t,
14        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_sphere_get_type(), ptr as *mut _),
15        type_ => || ffi::graphene_sphere_get_type(),
16    }
17}
18
19impl Sphere {
20    #[doc(alias = "graphene_sphere_contains_point")]
29    pub fn contains_point(&self, point: &Point3D) -> bool {
30        unsafe {
31            ffi::graphene_sphere_contains_point(self.to_glib_none().0, point.to_glib_none().0)
32        }
33    }
34
35    #[doc(alias = "graphene_sphere_distance")]
44    pub fn distance(&self, point: &Point3D) -> f32 {
45        unsafe { ffi::graphene_sphere_distance(self.to_glib_none().0, point.to_glib_none().0) }
46    }
47
48    #[doc(alias = "graphene_sphere_equal")]
49    fn equal(&self, b: &Sphere) -> bool {
50        unsafe { ffi::graphene_sphere_equal(self.to_glib_none().0, b.to_glib_none().0) }
51    }
52
53    #[doc(alias = "graphene_sphere_get_bounding_box")]
62    #[doc(alias = "get_bounding_box")]
63    pub fn bounding_box(&self) -> Box {
64        unsafe {
65            let mut box_ = Box::uninitialized();
66            ffi::graphene_sphere_get_bounding_box(self.to_glib_none().0, box_.to_glib_none_mut().0);
67            box_
68        }
69    }
70
71    #[doc(alias = "graphene_sphere_get_center")]
80    #[doc(alias = "get_center")]
81    pub fn center(&self) -> Point3D {
82        unsafe {
83            let mut center = Point3D::uninitialized();
84            ffi::graphene_sphere_get_center(self.to_glib_none().0, center.to_glib_none_mut().0);
85            center
86        }
87    }
88
89    #[doc(alias = "graphene_sphere_get_radius")]
91    #[doc(alias = "get_radius")]
92    pub fn radius(&self) -> f32 {
93        unsafe { ffi::graphene_sphere_get_radius(self.to_glib_none().0) }
94    }
95
96    #[doc(alias = "graphene_sphere_is_empty")]
102    pub fn is_empty(&self) -> bool {
103        unsafe { ffi::graphene_sphere_is_empty(self.to_glib_none().0) }
104    }
105
106    #[doc(alias = "graphene_sphere_translate")]
117    #[must_use]
118    pub fn translate(&self, point: &Point3D) -> Sphere {
119        unsafe {
120            let mut res = Sphere::uninitialized();
121            ffi::graphene_sphere_translate(
122                self.to_glib_none().0,
123                point.to_glib_none().0,
124                res.to_glib_none_mut().0,
125            );
126            res
127        }
128    }
129}
130
131impl PartialEq for Sphere {
132    #[inline]
133    fn eq(&self, other: &Self) -> bool {
134        self.equal(other)
135    }
136}
137
138impl Eq for Sphere {}