rusty_spine/
path_attachment.rs

1use crate::{
2    c::{c_float, spAttachment, spPathAttachment, spVertexAttachment},
3    c_interface::{NewFromPtr, SyncPtr},
4};
5
6/// An attachment of vertices forming a Bezier curve.
7///
8/// [Spine API Reference](http://esotericsoftware.com/spine-api-reference#PathAttachment)
9#[derive(Debug)]
10pub struct PathAttachment {
11    c_path_attachment: SyncPtr<spPathAttachment>,
12}
13
14impl NewFromPtr<spPathAttachment> for PathAttachment {
15    unsafe fn new_from_ptr(c_path_attachment: *mut spPathAttachment) -> Self {
16        Self {
17            c_path_attachment: SyncPtr(c_path_attachment),
18        }
19    }
20}
21
22impl PathAttachment {
23    fn attachment(&self) -> &spAttachment {
24        unsafe { &self.c_ptr_ref().super_0.super_0 }
25    }
26
27    fn vertex_attachment(&self) -> &spVertexAttachment {
28        unsafe { &self.c_ptr_ref().super_0 }
29    }
30
31    c_attachment_accessors!();
32    c_vertex_attachment_accessors!();
33    c_accessor_bool_mut!(
34        /// If `true, the start and end knots are connected.
35        closed,
36        /// Set closed, see [`closed`](`Self::closed`).
37        set_closed,
38        closed
39    );
40    c_accessor_color_mut!(
41        /// The color of the path as it was in Spine, or a default color if nonessential data was
42        /// not exported. Paths are not usually rendered at runtime.
43        color,
44        color_mut,
45        color
46    );
47    c_accessor_bool_mut!(
48        /// If `true`, additional calculations are performed to make computing positions along the
49        /// path more accurate and movement along the path have a constant speed.
50        constant_speed,
51        set_constant_speed,
52        constantSpeed
53    );
54    // TODO: do not use passthrough
55    c_accessor_passthrough!(
56        /// The lengths along the path in the setup pose from the start of the path to the end of
57        /// each Bezier curve.
58        lengths,
59        lengths,
60        *mut c_float
61    );
62    c_ptr!(c_path_attachment, spPathAttachment);
63}
64
65/// Functions available if using the `mint` feature.
66#[cfg(feature = "mint")]
67impl PathAttachment {
68    c_vertex_attachment_accessors_mint!();
69}