A pure Swift tweening library that complies with Swift 6 Strict Concurrency.
It was primarily designed to work with CiderKit, but it is completely agnostic and can be used within any project.
This package provides tweens to animate values of various types with linear or non-linear interpolation.
The supported types are:
- Built-in Swift Types
Int(+SIMD2toSIMD64variants)UInt(+SIMD2toSIMD64variants)Float(+SIMD2toSIMD64variants)Double(+SIMD2toSIMD64variants)String(with optional scrambled text)
- Core Graphics Types
CGColorCGFloatCGPointCGRectCGSizeCGVector
-
SpriteKitspecialized tweens (in progress) - Bridge to
SKAction - watchOS Support
- String specialized tweens (between two strings, with scrambled text, etc.)
- Loops
- Sequences
Full documentation | Sample Project
CiderKit.Tween makes heavy use of AsyncStreams. Here is a short usage sample:
import CiderKit_Tween
// Create a linear tween that goes from 0 to 100 linearly over a period of 5 seconds
let tween = Float.tween(from: 0, to: 100, options: .init(duration: 5))
// ...
Task {
for await updatedValue in await tween.onUpdate {
print(updatedValue) // Will print values as the tween updates
}
}CiderKit.Tween is available through Swift Package Manager.
To install it, simply add the dependency to your Package.swift file:
dependencies: [
.package(url: "https://github.com/chsxf/CiderKit.Tween.git", from: "0.7.0"),
],
targets: [
.target(name: "YourTarget", dependencies: ["CiderKit.Tween"]),
]- In Xcode, select File > Add Packages... and enter
https://github.com/chsxf/CiderKit.Tween.gitin the search field (top-right). - Then select Up to Next Major Version as the Dependency Rule with
0.7.0in the associated text field. - Then select the project of your choice in the Add to Project list.
- Finally, click the Add Package button.
Development on CiderKit.Tween is still active.
However, support is not guaranteed in any way. Pull requests or issues are welcomed but you may wait for some time before getting any answer.
Unless stated otherwise, all source code and assets are distributed under the MIT License.