An interpolation framework for Cocoa and Cocoa Touch.
The framework defines a protocol,
Interpolable in Swift), defining a common API for interpolating between two values.
The protocol defines two methods.
- (instancetype)interpolateToValue:(id)toValue progress:(double)progress; - (instancetype)interpolateToValue:(id)toValue progress:(double)progress behavior:(LNInterpolationBehavior)behavior;
public func interpolate(to toValue: Any, progress: Double) -> Self public func interpolate(to toValue: Any, progress: Double, behavior: InterpolationBehavior) -> Self
The first variant returns an interpolated value between the original and
toValue according to progress, using the default behavior.
The second is similar, but receives a behavior modifier. Each implementation can use this to choose how to implement the interpolation between the values. A default value of
.useDefault in Swift) is always available.
The framework provides implementation for the most common cases where interpolation may be needed.
An implementation is provided for
NSValue, which provides support for the following values:
An implementation is provided for colors (both for iOS and macOS). By default, color interpolation is performed in Lab colorspace for best possible interpolation quality. If performance is an issue, you may use
.useRGBColorSpace in Swift) to specify a behavior where RGB colorspace is used.
A demo playground is provided. Open LNInterpolationExample/LNInterpolationExample.xcworkspace and build the framework for macOS. Open the playground and explore the available pages.
Swift Package Manager is the recommended way to integrate
LNInterpolation in your project.
LNInterpolation supports SPM versions 5.1.0 and above. To use SPM, you should use Xcode 11 to open your project. Click
Swift Packages ->
Add Package Dependency, enter
https://github.com/LeoNatan/LNInterpolation. Select the version you’d like to use.
You can also manually add the package to your
.package(url: "https://github.com/LeoNatan/LNInterpolation.git", from: "1.0")
And the dependency in your target:
.target(name: "BestExampleApp", dependencies: ["LNInterpolation"]),
Add the following to your Cartfile:
LNInterpolation.xcodeproj project to your project, and add
LNInterpolation.framework to Embedded Binaries in your project target's General tab. Xcode should sort everything else on its own.
|Last commit: 1 week ago|