Skip to content

icavalheiro/BuddyTween

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BuddyTween

BuddyTween is a lightweight, high-performance, and zero-allocation (for core logic) tweening library for .NET. Built with simplicity in mind, it provides a flexible way to generate eased values for games, UI animations, or data simulations.

✨ Features

  • Lightweight: Minimal footprint with no heavy dependencies.
  • Enumeration Based: Uses IEnumerable<float> to allow for easy integration into custom game loops or coroutines.
  • Extensive Easing Library: Support for Linear, Quad, Cubic, Bounce, Elastic, Sine, Expo, Circ, and Back easing types.

πŸ“– About This Project

This library has been a core part of my personal development toolkit for many years, powering animations and transitions across numerous private projects. I am now open-sourcing it "as is" for the community to use.

BuddyTween is considered feature-complete. It is stable and battle-tested. Moving forward, primary maintenance will focus on ensuring compatibility with newer .NET versions.

The project is not closed, I'm happy to consider new PRs for new features, optimizations, or additional easing functions.

πŸ“¦ Installation

Install the package via the .NET CLI:

dotnet add package BuddyTween

Or via the NuGet Package Manager:

Install-Package BuddyTween

πŸ›  Usage

BuddyTween generates a sequence of values over a specified number of steps. You can iterate through these values to apply them to your objects.

Basic Example (C#) with while

using BuddyTween;
using BuddyTween.Enums;

int durationSteps = 60; // e.g., 60 frames
var tween = BuddyTween.Create(0f, 10f, durationSteps, EaseType.CubicOut);
var tweenEnumerator = tween.GetEnumerator();

while (tweenEnumerator.MoveNext())
{
    float currentValue = tweenEnumerator.Current;
    Console.WriteLine($"Current Value: {currentValue}");
    // Apply currentValue to your Transform, Alpha, or UI element here
}

Integration with Unity Coroutines using foreach

IEnumerator StartTween()
{
    var tween = BuddyTween.Create(0, 1, 100, EaseType.BounceOut);
    
    foreach (var val in tween)
    {
        myUIElement.alpha = val;
        yield return null; // Wait for next frame
    }
}

πŸ“ˆ Supported Easing Types

BuddyTween supports a wide array of easing functions to make your animations feel natural, the most common being:

In Out InOut
QuadIn QuadOut QuadInOut
CubicIn CubicOut CubicInOut
BounceIn BounceOut -
ElasticIn ElasticOut ElasticInOut
SineIn SineOut SineInOut

Feel free to contribute with new ease functions.

🀝 Contributing

Contributions are welcome, but keep in mind the zero-allocation principle, easy of use and current project standards.

To contribute you should:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the GNU General Public License v2.0. See LICENSE for more information.

About

A micro lib for using ease curves on .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages