objc2-pencil-kit 0.3.2

Bindings to the PencilKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// A uniform cubic B-spline representing the point data of a `PKStroke`.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/pencilkit/pkstrokepath?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct PKStrokePath;
);

unsafe impl Send for PKStrokePath {}

unsafe impl Sync for PKStrokePath {}

extern_conformance!(
    unsafe impl NSCopying for PKStrokePath {}
);

unsafe impl CopyingHelper for PKStrokePath {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for PKStrokePath {}
);

impl PKStrokePath {
    extern_methods!(
        #[cfg(feature = "PKStrokePoint")]
        /// Create a stroke path value with the given cubic B-spline control points.
        ///
        ///
        /// Parameter `controlPoints`: An array of control points for a cubic B-spline.
        ///
        /// Parameter `creationDate`: The start time of this path.
        #[unsafe(method(initWithControlPoints:creationDate:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithControlPoints_creationDate(
            this: Allocated<Self>,
            control_points: &NSArray<PKStrokePoint>,
            creation_date: &NSDate,
        ) -> Retained<Self>;

        /// The number of control points in this stroke path.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(count))]
        #[unsafe(method_family = none)]
        pub unsafe fn count(&self) -> NSUInteger;

        /// The time at which this stroke path was started.
        /// The `timeOffset` of contained PKStrokePoints is relative to this date.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(creationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationDate(&self) -> Retained<NSDate>;

        #[cfg(feature = "PKStrokePoint")]
        /// Returns B-spline control point at index `i`.
        #[unsafe(method(pointAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn pointAtIndex(&self, i: NSUInteger) -> Retained<PKStrokePoint>;

        #[cfg(feature = "PKStrokePoint")]
        /// Returns B-spline control point at index `i`.
        #[unsafe(method(objectAtIndexedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectAtIndexedSubscript(&self, i: NSUInteger) -> Retained<PKStrokePoint>;

        #[cfg(feature = "objc2-core-foundation")]
        /// The on-curve location for the floating point [0, count-1] `parametricValue` parameter.
        ///
        /// This has better performance than `[self interpolatedPointAt: parametricValue].location`
        /// for when only the location is required.
        #[unsafe(method(interpolatedLocationAt:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interpolatedLocationAt(&self, parametric_value: CGFloat) -> CGPoint;

        #[cfg(all(feature = "PKStrokePoint", feature = "objc2-core-foundation"))]
        /// The on-curve point for the floating point [0, count-1] `parametricValue` parameter.
        #[unsafe(method(interpolatedPointAt:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interpolatedPointAt(
            &self,
            parametric_value: CGFloat,
        ) -> Retained<PKStrokePoint>;

        #[cfg(all(
            feature = "PKFloatRange",
            feature = "PKStrokePoint",
            feature = "block2",
            feature = "objc2-core-foundation"
        ))]
        /// Executes a given block using each point in a range with a distance step.
        ///
        ///
        /// Parameter `range`: The parametric range to enumerate points in.
        ///
        /// Parameter `distanceStep`: The distance to step between points.
        ///
        /// Parameter `block`: The block to execute for each point. This block takes two parameters
        /// point The interpolated point on the spline.
        /// 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.
        #[unsafe(method(enumerateInterpolatedPointsInRange:strideByDistance:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateInterpolatedPointsInRange_strideByDistance_usingBlock(
            &self,
            range: &PKFloatRange,
            distance_step: CGFloat,
            block: &block2::DynBlock<dyn Fn(NonNull<PKStrokePoint>, NonNull<Bool>)>,
        );

        #[cfg(all(
            feature = "PKFloatRange",
            feature = "PKStrokePoint",
            feature = "block2"
        ))]
        /// Executes a given block using each point in a range with a time step.
        ///
        ///
        /// Parameter `range`: The parametric range to enumerate points in.
        ///
        /// Parameter `timeStep`: The time interval to step between points.
        ///
        /// Parameter `block`: The block to execute for each point. This block takes two parameters
        /// point The interpolated point on the spline.
        /// 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.
        #[unsafe(method(enumerateInterpolatedPointsInRange:strideByTime:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateInterpolatedPointsInRange_strideByTime_usingBlock(
            &self,
            range: &PKFloatRange,
            time_step: NSTimeInterval,
            block: &block2::DynBlock<dyn Fn(NonNull<PKStrokePoint>, NonNull<Bool>)>,
        );

        #[cfg(all(
            feature = "PKFloatRange",
            feature = "PKStrokePoint",
            feature = "block2",
            feature = "objc2-core-foundation"
        ))]
        /// Executes a given block using each point in a range with a parametric step.
        ///
        ///
        /// Parameter `range`: The parametric range to enumerate points in.
        ///
        /// Parameter `parametricStep`: The parametric step between points.
        ///
        /// Parameter `block`: The block to execute for each point. This block takes two parameters
        /// point The interpolated point on the spline.
        /// 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.
        #[unsafe(method(enumerateInterpolatedPointsInRange:strideByParametricStep:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateInterpolatedPointsInRange_strideByParametricStep_usingBlock(
            &self,
            range: &PKFloatRange,
            parametric_step: CGFloat,
            block: &block2::DynBlock<dyn Fn(NonNull<PKStrokePoint>, NonNull<Bool>)>,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// Returns a parametric value on the B-spline that is a specified distance from the given parametric value.
        ///
        ///
        /// Parameter `parametricValue`: The floating point [0, count-1] parametric value.
        ///
        /// Parameter `distanceStep`: The distance to offset `parametricValue`. `distanceStep` can be positive or negative.
        ///
        /// Returns: A parametric value offset by `distanceStep` from `parametricValue`.
        #[unsafe(method(parametricValue:offsetByDistance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn parametricValue_offsetByDistance(
            &self,
            parametric_value: CGFloat,
            distance_step: CGFloat,
        ) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Returns a parametric value on the B-spline that is a specified time from the given parametric value.
        ///
        ///
        /// Parameter `parametricValue`: The floating point [0, count-1] parametric value.
        ///
        /// Parameter `timeStep`: The time to offset `parametricValue`. `timeStep` can be positive or negative.
        ///
        /// Returns: A parametric value offset by `timeStep` from `parametricValue`.
        #[unsafe(method(parametricValue:offsetByTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn parametricValue_offsetByTime(
            &self,
            parametric_value: CGFloat,
            time_step: NSTimeInterval,
        ) -> CGFloat;
    );
}

/// Methods declared on superclass `NSObject`.
impl PKStrokePath {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}