1use crate::{ffi, Path, PathDirection, PathMeasure};
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct PathPoint(BoxedInline<ffi::GskPathPoint>);
10
11 match fn {
12 copy => |ptr| ffi::gsk_path_point_copy(mut_override(ptr)),
13 free => |ptr| ffi::gsk_path_point_free(ptr),
14 type_ => || ffi::gsk_path_point_get_type(),
15 }
16}
17
18impl PathPoint {
19 #[doc(alias = "gsk_path_point_compare")]
20 fn compare(&self, point2: &PathPoint) -> i32 {
21 unsafe { ffi::gsk_path_point_compare(self.to_glib_none().0, point2.to_glib_none().0) }
22 }
23
24 #[doc(alias = "gsk_path_point_equal")]
25 fn equal(&self, point2: &PathPoint) -> bool {
26 unsafe {
27 from_glib(ffi::gsk_path_point_equal(
28 self.to_glib_none().0,
29 point2.to_glib_none().0,
30 ))
31 }
32 }
33
34 #[doc(alias = "gsk_path_point_get_distance")]
35 #[doc(alias = "get_distance")]
36 pub fn distance(&self, measure: &PathMeasure) -> f32 {
37 unsafe { ffi::gsk_path_point_get_distance(self.to_glib_none().0, measure.to_glib_none().0) }
38 }
39
40 #[doc(alias = "gsk_path_point_get_position")]
41 #[doc(alias = "get_position")]
42 pub fn position(&self, path: &Path) -> graphene::Point {
43 unsafe {
44 let mut position = graphene::Point::uninitialized();
45 ffi::gsk_path_point_get_position(
46 self.to_glib_none().0,
47 path.to_glib_none().0,
48 position.to_glib_none_mut().0,
49 );
50 position
51 }
52 }
53
54 #[doc(alias = "gsk_path_point_get_rotation")]
55 #[doc(alias = "get_rotation")]
56 pub fn rotation(&self, path: &Path, direction: PathDirection) -> f32 {
57 unsafe {
58 ffi::gsk_path_point_get_rotation(
59 self.to_glib_none().0,
60 path.to_glib_none().0,
61 direction.into_glib(),
62 )
63 }
64 }
65
66 #[doc(alias = "gsk_path_point_get_tangent")]
67 #[doc(alias = "get_tangent")]
68 pub fn tangent(&self, path: &Path, direction: PathDirection) -> graphene::Vec2 {
69 unsafe {
70 let mut tangent = graphene::Vec2::uninitialized();
71 ffi::gsk_path_point_get_tangent(
72 self.to_glib_none().0,
73 path.to_glib_none().0,
74 direction.into_glib(),
75 tangent.to_glib_none_mut().0,
76 );
77 tangent
78 }
79 }
80}
81
82impl PartialOrd for PathPoint {
83 #[inline]
84 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
85 Some(self.cmp(other))
86 }
87}
88
89impl Ord for PathPoint {
90 #[inline]
91 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
92 self.compare(other).cmp(&0)
93 }
94}
95
96impl PartialEq for PathPoint {
97 #[inline]
98 fn eq(&self, other: &Self) -> bool {
99 self.equal(other)
100 }
101}
102
103impl Eq for PathPoint {}