graphene/auto/
triangle.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, Box, Plane, Point3D, Vec2, Vec3};
use glib::translate::*;

glib::wrapper! {
    pub struct Triangle(BoxedInline<ffi::graphene_triangle_t>);

    match fn {
        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_triangle_get_type(), ptr as *mut _) as *mut ffi::graphene_triangle_t,
        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_triangle_get_type(), ptr as *mut _),
        type_ => || ffi::graphene_triangle_get_type(),
    }
}

impl Triangle {
    #[doc(alias = "graphene_triangle_contains_point")]
    pub fn contains_point(&self, p: &Point3D) -> bool {
        unsafe { ffi::graphene_triangle_contains_point(self.to_glib_none().0, p.to_glib_none().0) }
    }

    #[doc(alias = "graphene_triangle_equal")]
    fn equal(&self, b: &Triangle) -> bool {
        unsafe { ffi::graphene_triangle_equal(self.to_glib_none().0, b.to_glib_none().0) }
    }

    #[doc(alias = "graphene_triangle_get_area")]
    #[doc(alias = "get_area")]
    pub fn area(&self) -> f32 {
        unsafe { ffi::graphene_triangle_get_area(self.to_glib_none().0) }
    }

    #[doc(alias = "graphene_triangle_get_barycoords")]
    #[doc(alias = "get_barycoords")]
    pub fn barycoords(&self, p: Option<&Point3D>) -> Option<Vec2> {
        unsafe {
            let mut res = Vec2::uninitialized();
            let ret = ffi::graphene_triangle_get_barycoords(
                self.to_glib_none().0,
                p.to_glib_none().0,
                res.to_glib_none_mut().0,
            );
            if ret {
                Some(res)
            } else {
                None
            }
        }
    }

    #[doc(alias = "graphene_triangle_get_bounding_box")]
    #[doc(alias = "get_bounding_box")]
    pub fn bounding_box(&self) -> Box {
        unsafe {
            let mut res = Box::uninitialized();
            ffi::graphene_triangle_get_bounding_box(
                self.to_glib_none().0,
                res.to_glib_none_mut().0,
            );
            res
        }
    }

    #[doc(alias = "graphene_triangle_get_midpoint")]
    #[doc(alias = "get_midpoint")]
    pub fn midpoint(&self) -> Point3D {
        unsafe {
            let mut res = Point3D::uninitialized();
            ffi::graphene_triangle_get_midpoint(self.to_glib_none().0, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_triangle_get_normal")]
    #[doc(alias = "get_normal")]
    pub fn normal(&self) -> Vec3 {
        unsafe {
            let mut res = Vec3::uninitialized();
            ffi::graphene_triangle_get_normal(self.to_glib_none().0, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_triangle_get_plane")]
    #[doc(alias = "get_plane")]
    pub fn plane(&self) -> Plane {
        unsafe {
            let mut res = Plane::uninitialized();
            ffi::graphene_triangle_get_plane(self.to_glib_none().0, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_triangle_get_points")]
    #[doc(alias = "get_points")]
    pub fn points(&self) -> (Point3D, Point3D, Point3D) {
        unsafe {
            let mut a = Point3D::uninitialized();
            let mut b = Point3D::uninitialized();
            let mut c = Point3D::uninitialized();
            ffi::graphene_triangle_get_points(
                self.to_glib_none().0,
                a.to_glib_none_mut().0,
                b.to_glib_none_mut().0,
                c.to_glib_none_mut().0,
            );
            (a, b, c)
        }
    }

    #[doc(alias = "graphene_triangle_get_uv")]
    #[doc(alias = "get_uv")]
    pub fn uv(&self, p: Option<&Point3D>, uv_a: &Vec2, uv_b: &Vec2, uv_c: &Vec2) -> Option<Vec2> {
        unsafe {
            let mut res = Vec2::uninitialized();
            let ret = ffi::graphene_triangle_get_uv(
                self.to_glib_none().0,
                p.to_glib_none().0,
                uv_a.to_glib_none().0,
                uv_b.to_glib_none().0,
                uv_c.to_glib_none().0,
                res.to_glib_none_mut().0,
            );
            if ret {
                Some(res)
            } else {
                None
            }
        }
    }

    #[doc(alias = "graphene_triangle_get_vertices")]
    #[doc(alias = "get_vertices")]
    pub fn vertices(&self) -> (Vec3, Vec3, Vec3) {
        unsafe {
            let mut a = Vec3::uninitialized();
            let mut b = Vec3::uninitialized();
            let mut c = Vec3::uninitialized();
            ffi::graphene_triangle_get_vertices(
                self.to_glib_none().0,
                a.to_glib_none_mut().0,
                b.to_glib_none_mut().0,
                c.to_glib_none_mut().0,
            );
            (a, b, c)
        }
    }
}

impl PartialEq for Triangle {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.equal(other)
    }
}

impl Eq for Triangle {}