Rephidock.AtomicAnimations 0.7.0

dotnet add package Rephidock.AtomicAnimations --version 0.7.0
                    
NuGet\Install-Package Rephidock.AtomicAnimations -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rephidock.AtomicAnimations" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rephidock.AtomicAnimations" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Rephidock.AtomicAnimations" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rephidock.AtomicAnimations --version 0.7.0
                    
#r "nuget: Rephidock.AtomicAnimations, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Rephidock.AtomicAnimations@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Rephidock.AtomicAnimations&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Rephidock.AtomicAnimations&version=0.7.0
                    
Install as a Cake Tool

Rephidock.AtomicAnimations

GitHub License Badge Nuget Version Badge

Basic callback-based animations and coroutines written in vanilla C#.

About

Provides animation 'atoms', which mutate float values using callbacks, and coroutines – animations based on IEnumerable<T>, allowing for state and logic.

Does not create additional clocks or threads for transparency. Use Update(TimeSpan deltaTime) to provide time flow to animations, runners and queues.

Contents

Animation Summary
(abstract) .Base.Animation Base class for all animations
(abstract) .Base.TimedAnimation Animation with a defined Duration
(abstract) .Base.Ease TimedAnimation with defined easing and progress value
Shift1D, 2D, 3D, 4D Changes 1 to 4 values by adding differences between updates
Move1D, 2D, 3D, 4D Changes 1 to 4 values by setting values directly
.Waves.WaveEase Calls an update delegate with a moving Wave (curve)
.Coroutines.CoroutineAnimation Structures others animations, timing, state and logic
Runner Summary
AnimationRunner Runs animations in parallel. Starts animations the moment they are added
AnimationQueue Runs animations in series. Supports Lazy<Animation>

For simplicity, prefer using Shift and Move atoms with delegates. Inheriting from the base classes is not required, but is useful sometimes.

To control the easing of values use the static methods in the Easing class. All easing functions are normalized.

The animations can be run manually or added to an AnimationRunner or an AnimationQueue. AnimationQueues and CoroutineAnimations also account for excess time since each atom finishes for better accuracy when chaining animations together.

Usage example:

public float X { get; set; }
public float Y { get; set; }

readonly AnimationRunner animationRunner = new AnimationRunner();

// ...

// In a method that is run every frame
// (commonly Update(float deltaTime) or similar)
animationRunner.Update(TimeSpan.FromSeconds(deltaTime));

// ...

animationRunner.Run( 
    new Shift2D(
        100, 200,
        TimeSpan.FromSeconds(0.5),
        Easing.Linear,
        (x, y) => {
            this.X += x;
            this.Y += y;
        }
    ) 
);

.Waves namespace

The .Waves namespaces allows for animations that can be interpreted as a moving wave.

Use the WaveBuilder to scale and join multiple EasingCurves together, forming a more complex Wave. The waves do not have to start and end at the same value, and they extend infinitely out of bounds as flat lines.

This example below creates a wave that looks like a bump or hill with a width of 600 and a height of 1.

new WaveBuilder()
    .Add(Easing.QuadOut).To(1).Over(300)
    .Add(Easing.QuadIn).To(0).Over(300)
    .ToWave()

The WaveEase.CreateRunthrough will create an animation atom that moves a given wave through a span of known width calling a delegate with a ShiftedWave each update.

Waves can be sampled with the GetValueAt method.

.Coroutines namespace

The CoroutineAnimation allows for building more complex animations. It is based on IEnumerable<CoroutineYield>, which can hold state and logic if made using a custom iterator/generator.

A CoroutineYield is immutable and holds either

  • an animation that is to play the moment it is returned or
  • a delay instruction

The Animations can be implicitly cast to CoroutineYields, while delays are static instances or created through static methods:

  • CoroutineYield.WaitPrevious: Waits for the previous animation to finish
  • CoroutineYield.Join: Waits for all previous animations to finish
  • CoroutineYield.Sleep(TimeSpan): Waits for a delay of specified time
  • CoroutineYield.SleepUntil(TimeSpan): Waits until a timestamp (since the animation has begun)
  • CoroutineYield.SleepUntilTrue(Func<bool>): Waits until a condition is satisfied
  • CoroutineYield.Suspend: Suspends an update without influencing the flow of time

This allows mixing both serial and parallel execution.

Example:

public float X { get; set; }
public float Y { get; set; }
public float Rotation { get; set; }

// ...

IEnumerable<CoroutineYield> ExampleCoroutine(float targetY, bool doSpin) {
    
    yield return new Move1D(
        this.Y,
        targetY,
        TimeSpan.FromSeconds(2),
        Easing.Linear,
        y => { this.Y = y; }
    );
    
    if (doSpin) 
    {
        yield return CoroutineYield.Sleep(TimeSpan.FromSeconds(1));

        yield return new Shift1D(
            360,
            TimeSpan.FromSeconds(1),
            Easing.QuadOut,
            r => { this.Rotation += r; }
        );
    }
    
    yield return CoroutineYield.Join;
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.7.0 89 4/17/2026
0.6.1 104 3/6/2026
0.6.0 212 11/2/2024
0.5.0 202 5/28/2024
0.4.2 198 5/15/2024
0.4.1 196 5/4/2024
0.4.0 182 4/19/2024
0.3.3 229 4/8/2024

- (breaking) CoroutineYield.Suspend now overrules other delays
     - Prevented corrupted state inside runners
     - Added a coroutine shortcut in AnimationRunner.Run
     - Added a ShiftedWave(Wave, float) constructor
     - Added CoroutineYield.SleepUntil(TimeSpan)
     - Added CoroutineYield.SleepUntilTrue(Func<bool>)