objc2_pencil_kit/generated/
PKStrokePath.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// A uniform cubic B-spline representing the point data of a `PKStroke`.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/pencilkit/pkstrokepath?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct PKStrokePath;
19);
20
21unsafe impl Send for PKStrokePath {}
22
23unsafe impl Sync for PKStrokePath {}
24
25extern_conformance!(
26    unsafe impl NSCopying for PKStrokePath {}
27);
28
29unsafe impl CopyingHelper for PKStrokePath {
30    type Result = Self;
31}
32
33extern_conformance!(
34    unsafe impl NSObjectProtocol for PKStrokePath {}
35);
36
37impl PKStrokePath {
38    extern_methods!(
39        #[cfg(feature = "PKStrokePoint")]
40        /// Create a stroke path value with the given cubic B-spline control points.
41        ///
42        ///
43        /// Parameter `controlPoints`: An array of control points for a cubic B-spline.
44        ///
45        /// Parameter `creationDate`: The start time of this path.
46        #[unsafe(method(initWithControlPoints:creationDate:))]
47        #[unsafe(method_family = init)]
48        pub unsafe fn initWithControlPoints_creationDate(
49            this: Allocated<Self>,
50            control_points: &NSArray<PKStrokePoint>,
51            creation_date: &NSDate,
52        ) -> Retained<Self>;
53
54        /// The number of control points in this stroke path.
55        ///
56        /// This property is not atomic.
57        ///
58        /// # Safety
59        ///
60        /// This might not be thread-safe.
61        #[unsafe(method(count))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn count(&self) -> NSUInteger;
64
65        /// The time at which this stroke path was started.
66        /// The `timeOffset` of contained PKStrokePoints is relative to this date.
67        ///
68        /// This property is not atomic.
69        ///
70        /// # Safety
71        ///
72        /// This might not be thread-safe.
73        #[unsafe(method(creationDate))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn creationDate(&self) -> Retained<NSDate>;
76
77        #[cfg(feature = "PKStrokePoint")]
78        /// Returns B-spline control point at index `i`.
79        #[unsafe(method(pointAtIndex:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn pointAtIndex(&self, i: NSUInteger) -> Retained<PKStrokePoint>;
82
83        #[cfg(feature = "PKStrokePoint")]
84        /// Returns B-spline control point at index `i`.
85        #[unsafe(method(objectAtIndexedSubscript:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn objectAtIndexedSubscript(&self, i: NSUInteger) -> Retained<PKStrokePoint>;
88
89        #[cfg(feature = "objc2-core-foundation")]
90        /// The on-curve location for the floating point [0, count-1] `parametricValue` parameter.
91        ///
92        /// This has better performance than `[self interpolatedPointAt: parametricValue].location`
93        /// for when only the location is required.
94        #[unsafe(method(interpolatedLocationAt:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn interpolatedLocationAt(&self, parametric_value: CGFloat) -> CGPoint;
97
98        #[cfg(all(feature = "PKStrokePoint", feature = "objc2-core-foundation"))]
99        /// The on-curve point for the floating point [0, count-1] `parametricValue` parameter.
100        #[unsafe(method(interpolatedPointAt:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn interpolatedPointAt(
103            &self,
104            parametric_value: CGFloat,
105        ) -> Retained<PKStrokePoint>;
106
107        #[cfg(all(
108            feature = "PKFloatRange",
109            feature = "PKStrokePoint",
110            feature = "block2",
111            feature = "objc2-core-foundation"
112        ))]
113        /// Executes a given block using each point in a range with a distance step.
114        ///
115        ///
116        /// Parameter `range`: The parametric range to enumerate points in.
117        ///
118        /// Parameter `distanceStep`: The distance to step between points.
119        ///
120        /// Parameter `block`: The block to execute for each point. This block takes two parameters
121        /// point The interpolated point on the spline.
122        /// stop A reference to a Boolean value. Setting the value to YES within the block stops further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished.
123        #[unsafe(method(enumerateInterpolatedPointsInRange:strideByDistance:usingBlock:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn enumerateInterpolatedPointsInRange_strideByDistance_usingBlock(
126            &self,
127            range: &PKFloatRange,
128            distance_step: CGFloat,
129            block: &block2::DynBlock<dyn Fn(NonNull<PKStrokePoint>, NonNull<Bool>)>,
130        );
131
132        #[cfg(all(
133            feature = "PKFloatRange",
134            feature = "PKStrokePoint",
135            feature = "block2"
136        ))]
137        /// Executes a given block using each point in a range with a time step.
138        ///
139        ///
140        /// Parameter `range`: The parametric range to enumerate points in.
141        ///
142        /// Parameter `timeStep`: The time interval to step between points.
143        ///
144        /// Parameter `block`: The block to execute for each point. This block takes two parameters
145        /// point The interpolated point on the spline.
146        /// stop A reference to a Boolean value. Setting the value to YES within the block stops further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished.
147        #[unsafe(method(enumerateInterpolatedPointsInRange:strideByTime:usingBlock:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn enumerateInterpolatedPointsInRange_strideByTime_usingBlock(
150            &self,
151            range: &PKFloatRange,
152            time_step: NSTimeInterval,
153            block: &block2::DynBlock<dyn Fn(NonNull<PKStrokePoint>, NonNull<Bool>)>,
154        );
155
156        #[cfg(all(
157            feature = "PKFloatRange",
158            feature = "PKStrokePoint",
159            feature = "block2",
160            feature = "objc2-core-foundation"
161        ))]
162        /// Executes a given block using each point in a range with a parametric step.
163        ///
164        ///
165        /// Parameter `range`: The parametric range to enumerate points in.
166        ///
167        /// Parameter `parametricStep`: The parametric step between points.
168        ///
169        /// Parameter `block`: The block to execute for each point. This block takes two parameters
170        /// point The interpolated point on the spline.
171        /// stop A reference to a Boolean value. Setting the value to YES within the block stops further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished.
172        #[unsafe(method(enumerateInterpolatedPointsInRange:strideByParametricStep:usingBlock:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn enumerateInterpolatedPointsInRange_strideByParametricStep_usingBlock(
175            &self,
176            range: &PKFloatRange,
177            parametric_step: CGFloat,
178            block: &block2::DynBlock<dyn Fn(NonNull<PKStrokePoint>, NonNull<Bool>)>,
179        );
180
181        #[cfg(feature = "objc2-core-foundation")]
182        /// Returns a parametric value on the B-spline that is a specified distance from the given parametric value.
183        ///
184        ///
185        /// Parameter `parametricValue`: The floating point [0, count-1] parametric value.
186        ///
187        /// Parameter `distanceStep`: The distance to offset `parametricValue`. `distanceStep` can be positive or negative.
188        ///
189        /// Returns: A parametric value offset by `distanceStep` from `parametricValue`.
190        #[unsafe(method(parametricValue:offsetByDistance:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn parametricValue_offsetByDistance(
193            &self,
194            parametric_value: CGFloat,
195            distance_step: CGFloat,
196        ) -> CGFloat;
197
198        #[cfg(feature = "objc2-core-foundation")]
199        /// Returns a parametric value on the B-spline that is a specified time from the given parametric value.
200        ///
201        ///
202        /// Parameter `parametricValue`: The floating point [0, count-1] parametric value.
203        ///
204        /// Parameter `timeStep`: The time to offset `parametricValue`. `timeStep` can be positive or negative.
205        ///
206        /// Returns: A parametric value offset by `timeStep` from `parametricValue`.
207        #[unsafe(method(parametricValue:offsetByTime:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn parametricValue_offsetByTime(
210            &self,
211            parametric_value: CGFloat,
212            time_step: NSTimeInterval,
213        ) -> CGFloat;
214    );
215}
216
217/// Methods declared on superclass `NSObject`.
218impl PKStrokePath {
219    extern_methods!(
220        #[unsafe(method(init))]
221        #[unsafe(method_family = init)]
222        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
223
224        #[unsafe(method(new))]
225        #[unsafe(method_family = new)]
226        pub unsafe fn new() -> Retained<Self>;
227    );
228}