graphene/auto/
triangle.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, Plane, Point3D, Vec2, Vec3};
6use glib::translate::*;
7
8glib::wrapper! {
9    pub struct Triangle(BoxedInline<ffi::graphene_triangle_t>);
10
11    match fn {
12        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_triangle_get_type(), ptr as *mut _) as *mut ffi::graphene_triangle_t,
13        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_triangle_get_type(), ptr as *mut _),
14        type_ => || ffi::graphene_triangle_get_type(),
15    }
16}
17
18impl Triangle {
19    #[doc(alias = "graphene_triangle_contains_point")]
20    pub fn contains_point(&self, p: &Point3D) -> bool {
21        unsafe { ffi::graphene_triangle_contains_point(self.to_glib_none().0, p.to_glib_none().0) }
22    }
23
24    #[doc(alias = "graphene_triangle_equal")]
25    fn equal(&self, b: &Triangle) -> bool {
26        unsafe { ffi::graphene_triangle_equal(self.to_glib_none().0, b.to_glib_none().0) }
27    }
28
29    #[doc(alias = "graphene_triangle_get_area")]
30    #[doc(alias = "get_area")]
31    pub fn area(&self) -> f32 {
32        unsafe { ffi::graphene_triangle_get_area(self.to_glib_none().0) }
33    }
34
35    #[doc(alias = "graphene_triangle_get_barycoords")]
36    #[doc(alias = "get_barycoords")]
37    pub fn barycoords(&self, p: Option<&Point3D>) -> Option<Vec2> {
38        unsafe {
39            let mut res = Vec2::uninitialized();
40            let ret = ffi::graphene_triangle_get_barycoords(
41                self.to_glib_none().0,
42                p.to_glib_none().0,
43                res.to_glib_none_mut().0,
44            );
45            if ret {
46                Some(res)
47            } else {
48                None
49            }
50        }
51    }
52
53    #[doc(alias = "graphene_triangle_get_bounding_box")]
54    #[doc(alias = "get_bounding_box")]
55    pub fn bounding_box(&self) -> Box {
56        unsafe {
57            let mut res = Box::uninitialized();
58            ffi::graphene_triangle_get_bounding_box(
59                self.to_glib_none().0,
60                res.to_glib_none_mut().0,
61            );
62            res
63        }
64    }
65
66    #[doc(alias = "graphene_triangle_get_midpoint")]
67    #[doc(alias = "get_midpoint")]
68    pub fn midpoint(&self) -> Point3D {
69        unsafe {
70            let mut res = Point3D::uninitialized();
71            ffi::graphene_triangle_get_midpoint(self.to_glib_none().0, res.to_glib_none_mut().0);
72            res
73        }
74    }
75
76    #[doc(alias = "graphene_triangle_get_normal")]
77    #[doc(alias = "get_normal")]
78    pub fn normal(&self) -> Vec3 {
79        unsafe {
80            let mut res = Vec3::uninitialized();
81            ffi::graphene_triangle_get_normal(self.to_glib_none().0, res.to_glib_none_mut().0);
82            res
83        }
84    }
85
86    #[doc(alias = "graphene_triangle_get_plane")]
87    #[doc(alias = "get_plane")]
88    pub fn plane(&self) -> Plane {
89        unsafe {
90            let mut res = Plane::uninitialized();
91            ffi::graphene_triangle_get_plane(self.to_glib_none().0, res.to_glib_none_mut().0);
92            res
93        }
94    }
95
96    #[doc(alias = "graphene_triangle_get_points")]
97    #[doc(alias = "get_points")]
98    pub fn points(&self) -> (Point3D, Point3D, Point3D) {
99        unsafe {
100            let mut a = Point3D::uninitialized();
101            let mut b = Point3D::uninitialized();
102            let mut c = Point3D::uninitialized();
103            ffi::graphene_triangle_get_points(
104                self.to_glib_none().0,
105                a.to_glib_none_mut().0,
106                b.to_glib_none_mut().0,
107                c.to_glib_none_mut().0,
108            );
109            (a, b, c)
110        }
111    }
112
113    #[doc(alias = "graphene_triangle_get_uv")]
114    #[doc(alias = "get_uv")]
115    pub fn uv(&self, p: Option<&Point3D>, uv_a: &Vec2, uv_b: &Vec2, uv_c: &Vec2) -> Option<Vec2> {
116        unsafe {
117            let mut res = Vec2::uninitialized();
118            let ret = ffi::graphene_triangle_get_uv(
119                self.to_glib_none().0,
120                p.to_glib_none().0,
121                uv_a.to_glib_none().0,
122                uv_b.to_glib_none().0,
123                uv_c.to_glib_none().0,
124                res.to_glib_none_mut().0,
125            );
126            if ret {
127                Some(res)
128            } else {
129                None
130            }
131        }
132    }
133
134    #[doc(alias = "graphene_triangle_get_vertices")]
135    #[doc(alias = "get_vertices")]
136    pub fn vertices(&self) -> (Vec3, Vec3, Vec3) {
137        unsafe {
138            let mut a = Vec3::uninitialized();
139            let mut b = Vec3::uninitialized();
140            let mut c = Vec3::uninitialized();
141            ffi::graphene_triangle_get_vertices(
142                self.to_glib_none().0,
143                a.to_glib_none_mut().0,
144                b.to_glib_none_mut().0,
145                c.to_glib_none_mut().0,
146            );
147            (a, b, c)
148        }
149    }
150}
151
152impl PartialEq for Triangle {
153    #[inline]
154    fn eq(&self, other: &Self) -> bool {
155        self.equal(other)
156    }
157}
158
159impl Eq for Triangle {}