Skip to main content

gsk4/
path_point.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{Path, PathDirection, PathPoint, ffi};
6
7impl PathPoint {
8    /// /picture
9    /// ## `path`
10    /// the path that @self is on
11    /// ## `direction`
12    /// the direction for which to return the curvature
13    ///
14    /// # Returns
15    ///
16    /// the curvature of the path at the given point
17    ///
18    /// ## `center`
19    /// return location for
20    ///   the center of the osculating circle
21    #[doc(alias = "gsk_path_point_get_curvature")]
22    #[doc(alias = "get_curvature")]
23    pub fn curvature(
24        &self,
25        path: &Path,
26        direction: PathDirection,
27    ) -> (f32, Option<graphene::Point>) {
28        unsafe {
29            let mut center = graphene::Point::uninitialized();
30            let ret = ffi::gsk_path_point_get_curvature(
31                self.to_glib_none().0,
32                path.to_glib_none().0,
33                direction.into_glib(),
34                center.to_glib_none_mut().0,
35            );
36
37            if ret == 0.0 {
38                (ret, None)
39            } else {
40                (ret, Some(center))
41            }
42        }
43    }
44}