Skip to content

Repository files navigation

CiderKit.Tween

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.

Lint, Build & Test

Features

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 (+ SIMD2 to SIMD64 variants)
    • UInt (+ SIMD2 to SIMD64 variants)
    • Float (+ SIMD2 to SIMD64 variants)
    • Double (+ SIMD2 to SIMD64 variants)
    • String (with optional scrambled text)
  • Core Graphics Types
    • CGColor
    • CGFloat
    • CGPoint
    • CGRect
    • CGSize
    • CGVector

Planned Features and Improvements

  • SpriteKit specialized tweens (in progress)
  • Bridge to SKAction
  • watchOS Support
  • String specialized tweens (between two strings, with scrambled text, etc.)
  • Loops
  • Sequences

Getting Started

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
    }
}

Installation with Swift Package Manager

CiderKit.Tween is available through Swift Package Manager.

As a Package Dependency

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"]),
]

As a Project Dependency in Xcode

  • In Xcode, select File > Add Packages... and enter https://github.com/chsxf/CiderKit.Tween.git in the search field (top-right).
  • Then select Up to Next Major Version as the Dependency Rule with 0.7.0 in the associated text field.
  • Then select the project of your choice in the Add to Project list.
  • Finally, click the Add Package button.

Support

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.

License

Unless stated otherwise, all source code and assets are distributed under the MIT License.

Releases

Contributors

Languages