mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Added Zero, One, Linear and Clamp to Easings
This commit is contained in:
parent
62a7a89834
commit
2c7ffee427
2 changed files with 28 additions and 0 deletions
|
@ -16,6 +16,7 @@ Jump to version:
|
||||||
### MLEM
|
### MLEM
|
||||||
Additions
|
Additions
|
||||||
- Added GraphicsExtensions.WithRenderTargets, a multi-target version of WithRenderTarget
|
- Added GraphicsExtensions.WithRenderTargets, a multi-target version of WithRenderTarget
|
||||||
|
- Added Zero, One, Linear and Clamp to Easings
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed TextInput not working correctly when using surrogate pairs
|
- Fixed TextInput not working correctly when using surrogate pairs
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
namespace MLEM.Misc {
|
namespace MLEM.Misc {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -8,6 +9,21 @@ namespace MLEM.Misc {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Easings {
|
public static class Easings {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An easing function that constantly returns 0, regardless of the input percentage.
|
||||||
|
/// This is useful for chaining using <see cref="AndThen(MLEM.Misc.Easings.Easing,MLEM.Misc.Easings.Easing)"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly Easing Zero = p => 0;
|
||||||
|
/// <summary>
|
||||||
|
/// An easing function that constantly returns 1, regardless of the input percentage.
|
||||||
|
/// This is useful for chaining using <see cref="AndThen(MLEM.Misc.Easings.Easing,MLEM.Misc.Easings.Easing)"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly Easing One = p => 1;
|
||||||
|
/// <summary>
|
||||||
|
/// A linear easing function that returns the input percentage without modifying it.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly Easing Linear = p => p;
|
||||||
|
|
||||||
/// <summary>https://easings.net/#easeInSine</summary>
|
/// <summary>https://easings.net/#easeInSine</summary>
|
||||||
public static readonly Easing InSine = p => 1 - (float) Math.Cos(p * Math.PI / 2);
|
public static readonly Easing InSine = p => 1 - (float) Math.Cos(p * Math.PI / 2);
|
||||||
/// <summary>https://easings.net/#easeOutSine</summary>
|
/// <summary>https://easings.net/#easeOutSine</summary>
|
||||||
|
@ -170,6 +186,17 @@ namespace MLEM.Misc {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Causes output from the easing function to be clamped between the <paramref name="min"/> and <paramref name="max"/> values passed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="easing">The easing function to clamp.</param>
|
||||||
|
/// <param name="min">The minimum output value to clamp to, defaults to 0.</param>
|
||||||
|
/// <param name="max">The maximum output value to clamp to, defaults to 1.</param>
|
||||||
|
/// <returns>A clamped easing function.</returns>
|
||||||
|
public static Easing Clamp(this Easing easing, float min = 0, float max = 1) {
|
||||||
|
return p => MathHelper.Clamp(easing(p), min, max);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A delegate method used by <see cref="Easings"/>.
|
/// A delegate method used by <see cref="Easings"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue