AnimationKit 1.0.0
it is the same
dotnet add package AnimationKit --version 1.0.0
NuGet\Install-Package AnimationKit -Version 1.0.0
<PackageReference Include="AnimationKit" Version="1.0.0" />
paket add AnimationKit --version 1.0.0
#r "nuget: AnimationKit, 1.0.0"
// Install AnimationKit as a Cake Addin #addin nuget:?package=AnimationKit&version=1.0.0 // Install AnimationKit as a Cake Tool #tool nuget:?package=AnimationKit&version=1.0.0
AnimationKit
AnimationKit is a versatile animation library for C# developers, allowing you to easily create and manage animations using keyframes and customizable interpolation strategies. This package is designed for games, UI, or any other applications requiring smooth, keyframe-based animations.
Features
- Keyframe-Based Animations: Define animations with specific keyframes for precise control.
- Custom Interpolation Strategies: Use built-in interpolation methods (linear, ease in/out, bounce, etc.) or implement your own.
- Looping and Timing Controls: Easily configure animation looping and duration scaling.
- Animation Management: Manage multiple animations and control playback through the
AnimationPlayer
.
Installation
To install AnimationKit via NuGet, use the following command:
dotnet add package AnimationKit
Usage
1. Define Keyframes
Start by defining keyframes in your animation using the Animation<T>
class.
var animation = new Animation<float>(new LinearInterpolationFloat());
animation.AddKeyFrame(0, 0f);
animation.AddKeyFrame(500, 1f);
animation.AddKeyFrame(1000, 0f);
2. Play the Animation
Use AnimationPlayer
to manage and play animations. Add your animation and control playback.
var player = new AnimationPlayer();
player.AddAnimation("MyAnimation", animation);
player.Play("MyAnimation");
3. Update and Retrieve Values
Update the player regularly (e.g., in a game loop) and retrieve the interpolated value at the current time.
player.Update(deltaTime);
float currentValue = player.GetValue<float>("MyAnimation");
Classes and Interfaces
AnimationBase
Abstract base class for animations, supporting properties like Duration
, Loop
, and playback state.
Animation<T>
A generic animation class that uses keyframes and an interpolation strategy. This class lets you define animations for different data types (float
, Vector2
, etc.).
AnimationPlayer
Handles playback and timing for multiple animations. Controls like Play
, Pause
, and Update
are provided.
KeyFrame<T>
Represents a keyframe in an animation, with a specific time and value.
IInterpolationStrategy<T>
An interface for defining custom interpolation strategies. Use one of the provided strategies or implement your own.
Interpolation Strategies
Several interpolation strategies are included for smooth animations:
- Linear: Simple, linear interpolation.
- EaseIn/EaseOut: Smooth easing in or out.
- Bounce: Adds a bouncing effect.
- Elastic: Adds an elastic, spring-like effect.
- Quadratic/Cubic: Non-linear interpolations for smooth curves.
Example
// Create an animation with easing
var easingAnimation = new Animation<float>(new EaseInOutInterpolationFloat());
easingAnimation.AddKeyFrame(0, 0f);
easingAnimation.AddKeyFrame(500, 100f);
easingAnimation.AddKeyFrame(1000, 0f);
var player = new AnimationPlayer();
player.AddAnimation("EasingAnimation", easingAnimation);
player.Play("EasingAnimation");
// In your update loop
player.Update(deltaTime);
float value = player.GetValue<float>("EasingAnimation");
License
AnimationKit is open-source and available under the MIT license.
AnimationKit brings flexible, keyframe-based animations to your C# projects. Whether for games, UIs, or other animated content, get started and bring your animations to life!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.0.0 | 79 | 11/5/2024 |