mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-22 11:13:47 +00:00
Added GTWeen
This commit is contained in:
parent
457998788e
commit
2036e4e748
152 changed files with 5889 additions and 7 deletions
|
|
@ -0,0 +1,34 @@
|
|||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class FloatInterpolator : IInterpolator<float>
|
||||
{
|
||||
public static readonly FloatInterpolator Instance = new();
|
||||
|
||||
FloatInterpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public float Evaluate(
|
||||
float initialValue,
|
||||
float finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
return easingDelegate(initialValue, finalValue, time);
|
||||
}
|
||||
|
||||
public float Subtract(float initialValue, float finalValue)
|
||||
{
|
||||
return finalValue - initialValue;
|
||||
}
|
||||
|
||||
public float Add(float initialValue, float finalValue)
|
||||
{
|
||||
return finalValue + initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b3m1wga6bh0qn
|
||||
37
GTweensGodot/GTweens/Source/Interpolators/IInterpolator.cs
Normal file
37
GTweensGodot/GTweens/Source/Interpolators/IInterpolator.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an interpolator for working with transitions between two values of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values to interpolate.</typeparam>
|
||||
public interface IInterpolator<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates the intermediate value between the initial and final values based on the specified time and easing function.
|
||||
/// </summary>
|
||||
/// <param name="initialValue">The initial value.</param>
|
||||
/// <param name="finalValue">The final value.</param>
|
||||
/// <param name="time">The interpolation time (usually between 0 and 1).</param>
|
||||
/// <param name="easingFunction">The easing function to apply during interpolation.</param>
|
||||
/// <returns>The interpolated value between <paramref name="initialValue"/> and <paramref name="finalValue"/>.</returns>
|
||||
T Evaluate(T initialValue, T finalValue, float time, EasingDelegate easingFunction);
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two values of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <param name="initialValue">The initial value.</param>
|
||||
/// <param name="finalValue">The final value.</param>
|
||||
/// <returns>The result of subtracting <paramref name="finalValue"/> from <paramref name="initialValue"/>.</returns>
|
||||
T Subtract(T initialValue, T finalValue);
|
||||
|
||||
/// <summary>
|
||||
/// Adds two values of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <param name="initialValue">The initial value.</param>
|
||||
/// <param name="finalValue">The final value.</param>
|
||||
/// <returns>The result of adding <paramref name="finalValue"/> to <paramref name="initialValue"/>.</returns>
|
||||
T Add(T initialValue, T finalValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://83qvtsiku48u
|
||||
34
GTweensGodot/GTweens/Source/Interpolators/IntInterpolator.cs
Normal file
34
GTweensGodot/GTweens/Source/Interpolators/IntInterpolator.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class IntInterpolator : IInterpolator<int>
|
||||
{
|
||||
public static readonly IntInterpolator Instance = new();
|
||||
|
||||
IntInterpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int Evaluate(
|
||||
int initialValue,
|
||||
int finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
return (int)easingDelegate(initialValue, finalValue, time);
|
||||
}
|
||||
|
||||
public int Subtract(int initialValue, int finalValue)
|
||||
{
|
||||
return finalValue - initialValue;
|
||||
}
|
||||
|
||||
public int Add(int initialValue, int finalValue)
|
||||
{
|
||||
return finalValue + initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://e1vtsq83j4g6
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System.Drawing;
|
||||
using GTweens.Easings;
|
||||
using GTweens.Extensions;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class SystemColorInterpolator : IInterpolator<Color>
|
||||
{
|
||||
public static readonly SystemColorInterpolator Instance = new();
|
||||
|
||||
SystemColorInterpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Color Evaluate(
|
||||
Color initialValue,
|
||||
Color finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
return SystemColorExtensions.FromRgba(
|
||||
easingDelegate!(initialValue.A, finalValue.A, time),
|
||||
easingDelegate(initialValue.R, finalValue.R, time),
|
||||
easingDelegate(initialValue.G, finalValue.G, time),
|
||||
easingDelegate(initialValue.B, finalValue.B, time)
|
||||
);
|
||||
}
|
||||
|
||||
public Color Subtract(Color initialValue, Color finalValue)
|
||||
{
|
||||
return Color.FromArgb(
|
||||
finalValue.A - initialValue.A,
|
||||
finalValue.R - initialValue.R,
|
||||
finalValue.G - initialValue.G,
|
||||
finalValue.B - initialValue.B
|
||||
);
|
||||
}
|
||||
|
||||
public Color Add(Color initialValue, Color finalValue)
|
||||
{
|
||||
return Color.FromArgb(
|
||||
finalValue.A + initialValue.A,
|
||||
finalValue.R + initialValue.R,
|
||||
finalValue.G + initialValue.G,
|
||||
finalValue.B + initialValue.B
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bthivyns1lr7a
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using System.Numerics;
|
||||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class SystemQuaternionInterpolator : IInterpolator<Quaternion>
|
||||
{
|
||||
public static readonly SystemQuaternionInterpolator Instance = new();
|
||||
|
||||
SystemQuaternionInterpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Quaternion Evaluate(
|
||||
Quaternion initialValue,
|
||||
Quaternion finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
float curveTime = easingDelegate(0f, 1f, time);
|
||||
|
||||
return Quaternion.Slerp(initialValue, finalValue, curveTime);
|
||||
}
|
||||
|
||||
public Quaternion Subtract(Quaternion initialValue, Quaternion finalValue)
|
||||
{
|
||||
return Quaternion.Inverse(initialValue) * finalValue;
|
||||
}
|
||||
|
||||
public Quaternion Add(Quaternion initialValue, Quaternion finalValue)
|
||||
{
|
||||
return initialValue * finalValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d2onw3tx1lfu7
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System.Numerics;
|
||||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class SystemVector2Interpolator : IInterpolator<Vector2>
|
||||
{
|
||||
public static readonly SystemVector2Interpolator Instance = new();
|
||||
|
||||
SystemVector2Interpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Vector2 Evaluate(
|
||||
Vector2 initialValue,
|
||||
Vector2 finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
return new Vector2(
|
||||
easingDelegate(initialValue.X, finalValue.X, time),
|
||||
easingDelegate(initialValue.Y, finalValue.Y, time)
|
||||
);
|
||||
}
|
||||
|
||||
public Vector2 Subtract(Vector2 initialValue, Vector2 finalValue)
|
||||
{
|
||||
return finalValue - initialValue;
|
||||
}
|
||||
|
||||
public Vector2 Add(Vector2 initialValue, Vector2 finalValue)
|
||||
{
|
||||
return finalValue + initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dvtde4b3gjv32
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
using System.Numerics;
|
||||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class SystemVector3Interpolator : IInterpolator<Vector3>
|
||||
{
|
||||
public static readonly SystemVector3Interpolator Instance = new();
|
||||
|
||||
SystemVector3Interpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Vector3 Evaluate(
|
||||
Vector3 initialValue,
|
||||
Vector3 finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
return new Vector3(
|
||||
easingDelegate(initialValue.X, finalValue.X, time),
|
||||
easingDelegate(initialValue.Y, finalValue.Y, time),
|
||||
easingDelegate(initialValue.Z, finalValue.Z, time)
|
||||
);
|
||||
}
|
||||
|
||||
public Vector3 Subtract(Vector3 initialValue, Vector3 finalValue)
|
||||
{
|
||||
return finalValue - initialValue;
|
||||
}
|
||||
|
||||
public Vector3 Add(Vector3 initialValue, Vector3 finalValue)
|
||||
{
|
||||
return finalValue + initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cdm8j104f7hgo
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// using Juce.Tweening.Easing;
|
||||
// using Juce.Tweening.Utils;
|
||||
// using System;
|
||||
// using System.Numerics;
|
||||
//
|
||||
// namespace Juce.Tweening.Interpolators
|
||||
// {
|
||||
// public class SystemVector3RotationInterpolator : IInterpolator<Vector3>
|
||||
// {
|
||||
// readonly RotationMode rotationMode;
|
||||
//
|
||||
// public SystemVector3RotationInterpolator(RotationMode rotationMode)
|
||||
// {
|
||||
// this.rotationMode = rotationMode;
|
||||
// }
|
||||
//
|
||||
// public Vector3 Evaluate(
|
||||
// Vector3 initialValue,
|
||||
// Vector3 finalValue,
|
||||
// float time,
|
||||
// EaseDelegate easeFunction
|
||||
// )
|
||||
// {
|
||||
// if (easeFunction == null)
|
||||
// {
|
||||
// throw new ArgumentNullException($"Tried to Evaluate with a " +
|
||||
// $"null {nameof(EaseDelegate)} on {nameof(SystemVector3Interpolator)}");
|
||||
// }
|
||||
//
|
||||
// if (rotationMode == RotationMode.Fast)
|
||||
// {
|
||||
// Vector3 deltaAngle = AngleUtils.DeltaAngle(initialValue, finalValue);
|
||||
//
|
||||
// finalValue = initialValue + deltaAngle;
|
||||
// }
|
||||
//
|
||||
// return new Vector3(
|
||||
// easeFunction(initialValue.X, finalValue.X, time),
|
||||
// easeFunction(initialValue.Y, finalValue.Y, time),
|
||||
// easeFunction(initialValue.Z, finalValue.Z, time)
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// public Vector3 Subtract(Vector3 initialValue, Vector3 finalValue)
|
||||
// {
|
||||
// return finalValue - initialValue;
|
||||
// }
|
||||
//
|
||||
// public Vector3 Add(Vector3 firstValue, Vector3 secondValue)
|
||||
// {
|
||||
// return secondValue + firstValue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c8hpkxetb6uyg
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using System.Numerics;
|
||||
using GTweens.Easings;
|
||||
|
||||
namespace GTweens.Interpolators
|
||||
{
|
||||
public sealed class SystemVector4Interpolator : IInterpolator<Vector4>
|
||||
{
|
||||
public static readonly SystemVector4Interpolator Instance = new();
|
||||
|
||||
SystemVector4Interpolator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Vector4 Evaluate(
|
||||
Vector4 initialValue,
|
||||
Vector4 finalValue,
|
||||
float time,
|
||||
EasingDelegate easingDelegate
|
||||
)
|
||||
{
|
||||
return new Vector4(
|
||||
easingDelegate(initialValue.X, finalValue.X, time),
|
||||
easingDelegate(initialValue.Y, finalValue.Y, time),
|
||||
easingDelegate(initialValue.Z, finalValue.Z, time),
|
||||
easingDelegate(initialValue.W, finalValue.W, time)
|
||||
);
|
||||
}
|
||||
|
||||
public Vector4 Subtract(Vector4 initialValue, Vector4 finalValue)
|
||||
{
|
||||
return finalValue - initialValue;
|
||||
}
|
||||
|
||||
public Vector4 Add(Vector4 initialValue, Vector4 finalValue)
|
||||
{
|
||||
return finalValue + initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cmwi4emxwsy8c
|
||||
Loading…
Add table
Add a link
Reference in a new issue