diff --git a/CHANGELOG.md b/CHANGELOG.md index 562a04c..f21f58a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Jump to version: ### MLEM Additions - Added GraphicsExtensions.WithRenderTargets, a multi-target version of WithRenderTarget +- Added Zero, One, Linear and Clamp to Easings Fixes - Fixed TextInput not working correctly when using surrogate pairs diff --git a/MLEM/Misc/Easings.cs b/MLEM/Misc/Easings.cs index a252c36..3c83b03 100644 --- a/MLEM/Misc/Easings.cs +++ b/MLEM/Misc/Easings.cs @@ -1,4 +1,5 @@ using System; +using Microsoft.Xna.Framework; namespace MLEM.Misc { /// @@ -8,6 +9,21 @@ namespace MLEM.Misc { /// public static class Easings { + /// + /// An easing function that constantly returns 0, regardless of the input percentage. + /// This is useful for chaining using . + /// + public static readonly Easing Zero = p => 0; + /// + /// An easing function that constantly returns 1, regardless of the input percentage. + /// This is useful for chaining using . + /// + public static readonly Easing One = p => 1; + /// + /// A linear easing function that returns the input percentage without modifying it. + /// + public static readonly Easing Linear = p => p; + /// https://easings.net/#easeInSine public static readonly Easing InSine = p => 1 - (float) Math.Cos(p * Math.PI / 2); /// https://easings.net/#easeOutSine @@ -170,6 +186,17 @@ namespace MLEM.Misc { }; } + /// + /// Causes output from the easing function to be clamped between the and values passed. + /// + /// The easing function to clamp. + /// The minimum output value to clamp to, defaults to 0. + /// The maximum output value to clamp to, defaults to 1. + /// A clamped easing function. + public static Easing Clamp(this Easing easing, float min = 0, float max = 1) { + return p => MathHelper.Clamp(easing(p), min, max); + } + /// /// A delegate method used by . ///