One Logo Pool Ball
PencilKit · IOS API REFERENCE

PKStrokePath

struct · iOS 14.0+ · SDK 27.1

struct PKStrokePath

Members (14)

get · iOS 14.0+

startIndex

TypeScript
get startIndex(): number
Swift declaration
var startIndex: Int { get }

The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.

get · iOS 14.0+

creationDate

TypeScript
get creationDate(): globalThis.Date
Swift declaration
var creationDate: Date { get }
init · iOS 27.0+

init

TypeScript
static initControlPointsCreationDateId(controlPoints: Array<PKStrokePoint>, creationDate: globalThis.Date, id: string): PKStrokePath
Swift declaration
init<T>(controlPoints: T, creationDate: Date, id: UUID) where T : Sequence, T.Element == PKStrokePoint

Creates a stroke path with the specified cubic B-spline control points and a unique identifier. - Parameters: - controlPoints: An array of control points for a cubic B-spline. - creationDate: The start time of this path. - id: The unique identity of the path. > Warning: Using multiple stroke paths with identical IDs but different control points will result in undefined rendering behavior. Ensure each stroke path has a unique identifier.

init · iOS 14.0+

init

TypeScript
static initControlPointsCreationDate(controlPoints: Array<PKStrokePoint>, creationDate: globalThis.Date): PKStrokePath
Swift declaration
init<T>(controlPoints: T, creationDate: Date) where T : Sequence, T.Element == PKStrokePoint

Creates a stroke path with the specified cubic B-spline control points. - Parameters: - controlPoints: An array of control points for a cubic B-spline. - creationDate: The start time of this path.

method · iOS 14.0+

parametricValue

TypeScript
parametricValue(parametricValue: number, step: PKStrokePath_InterpolatedSlice_Stride): number
Swift declaration
func parametricValue(_ parametricValue: CGFloat, offsetBy step: PKStrokePath.InterpolatedSlice.Stride) -> CGFloat

Returns the parametric value offset from the given value by the specified step. - parameter parametricValue: The floating point [0, count-1] parametric value. - parameter step: The distance to offset `parametricValue`. `step` can be positive or negative, distance or time. - returns: A parametric value offset by `step` from `parametricValue`.

method · iOS 14.0+

interpolatedPoint

TypeScript
interpolatedPoint(parametricValue: number): PKStrokePoint
Swift declaration
func interpolatedPoint(at parametricValue: CGFloat) -> PKStrokePoint

Returns the on-curve stroke point for the specified parametric value.

method · iOS 14.0+

interpolatedPoints

TypeScript
interpolatedPoints(range: ("animatableData" | SDKHandle) | null, stride: PKStrokePath_InterpolatedSlice_Stride): PKStrokePath_InterpolatedSlice
Swift declaration
func interpolatedPoints(in range: ClosedRange<CGFloat>? = nil, by stride: PKStrokePath.InterpolatedSlice.Stride) -> PKStrokePath.InterpolatedSlice

Returns an interpolated slice that strides across the specified range of the stroke path. - parameter range: The parametric range to create a slice in. - parameter stride: The stride to use between points - returns: A new slice that strides across this stroke path with `stride`.

get · iOS 27.0+

bezierRepresentation

TypeScript
get bezierRepresentation(): _CoreGraphics_CGPath
Swift declaration
var bezierRepresentation: CGPath { get }

A Bézier path representation of the path's curve, computed in linear time.

method · iOS 14.0+

interpolatedLocation

TypeScript
interpolatedLocation(parametricValue: number): { x: number; y: number }
Swift declaration
func interpolatedLocation(at parametricValue: CGFloat) -> CGPoint

Returns the on-curve location for the specified parametric value. The floating-point `parametricValue` must be in the range [0, count-1]. This has better performance than `interpolatedPoint(at: parametricValue).location` when only the location is required.

get · iOS 27.0+

id

TypeScript
get id(): string
Swift declaration
var id: UUID { get }

The unique identity of the stroke path. > Warning: Using multiple stroke paths with identical IDs but different control points will result in undefined rendering behavior. Ensure each stroke path has a unique identifier.

get · iOS 14.0+

endIndex

TypeScript
get endIndex(): number
Swift declaration
var endIndex: Int { get }

The collection's "past the end" position---that is, the position one greater than the last valid subscript argument. When you need a range that includes the last element of a collection, use the half-open range operator (`..<`) with `endIndex`. The `..<` operator creates a range that doesn't include the upper bound, so it's always safe to use with `endIndex`. For example: let numbers = [10, 20, 30, 40, 50] if let index = numbers.firstIndex(of: 30) { print(numbers[index ..< numbers.endIndex]) } // Prints "[30, 40, 50]" If the collection is empty, `endIndex` is equal to `startIndex`.

init · iOS 14.0+

init

TypeScript
static init(): PKStrokePath
Swift declaration
init()
subscript · iOS 14.0+

subscript

TypeScript
subscript(index: number): PKStrokePoint
Swift declaration
subscript(index: PKStrokePath.Index) -> PKStrokePoint { get }

Accesses the element at the specified position. The following example accesses an element of an array through its subscript to print its value: var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] print(streets[1]) // Prints "Bryant" You can subscript a collection with any valid index other than the collection's end index. The end index refers to the position one past the last element of a collection, so it doesn't correspond with an element. - Parameter position: The position of the element to access. `position` must be a valid index of the collection that is not equal to the `endIndex` property. - Complexity: O(1)

subscript · iOS 27.0+

subscript

TypeScript
subscript52479(range: "animatableData" | SDKHandle): PKStrokePath
Swift declaration
subscript(range: ClosedRange<CGFloat>) -> PKStrokePath { get }

Returns a copy of the path containing the control points in the specified parametric range. - Important: This subscript returns a new stroke path with points always starting at index zero. This differs from the `Range<Int>` subscript, which returns a `Slice` with points at their original index. - Parameter range: The parametric range to copy. Values must be within [0, count-1]. - Returns: A new stroke path containing the portion within the specified parametric range.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

PKStrokePath.init(bezierPath:creationDate:pointProvider:)

callback cannot propagate synchronous failure

All PencilKit types →