graphene/auto/
sphere.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, Box, Point3D};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// A sphere, represented by its center and radius.
10    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    /// Checks whether the given `point` is contained in the volume
21    /// of a [`Sphere`][crate::Sphere].
22    /// ## `point`
23    /// a [`Point3D`][crate::Point3D]
24    ///
25    /// # Returns
26    ///
27    /// `true` if the sphere contains the point
28    #[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    /// Computes the distance of the given `point` from the surface of
36    /// a [`Sphere`][crate::Sphere].
37    /// ## `point`
38    /// a [`Point3D`][crate::Point3D]
39    ///
40    /// # Returns
41    ///
42    /// the distance of the point
43    #[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    /// Computes the bounding box capable of containing the
54    /// given [`Sphere`][crate::Sphere].
55    ///
56    /// # Returns
57    ///
58    ///
59    /// ## `box_`
60    /// return location for the bounding box
61    #[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    /// Retrieves the coordinates of the center of a [`Sphere`][crate::Sphere].
72    ///
73    /// # Returns
74    ///
75    ///
76    /// ## `center`
77    /// return location for the coordinates of
78    ///  the center
79    #[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    /// Retrieves the radius of a [`Sphere`][crate::Sphere].
90    #[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    /// Checks whether the sphere has a zero radius.
97    ///
98    /// # Returns
99    ///
100    /// `true` if the sphere is empty
101    #[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    /// Translates the center of the given [`Sphere`][crate::Sphere] using the `point`
107    /// coordinates as the delta of the translation.
108    /// ## `point`
109    /// the coordinates of the translation
110    ///
111    /// # Returns
112    ///
113    ///
114    /// ## `res`
115    /// return location for the translated sphere
116    #[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 {}