diff --git a/CHANGELOG.md b/CHANGELOG.md index ca42a71..f03860f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Additions - Added consuming variants of IsPressed methods to InputHandler and Keybind - Added SpriteBatchContext struct and extensions - Added InputHandler.InvertPressBehavior +- Added ReverseInput and ReverseOutput to Easings ### MLEM.Ui Additions diff --git a/MLEM/Misc/Easings.cs b/MLEM/Misc/Easings.cs index 46e30e4..457f195 100644 --- a/MLEM/Misc/Easings.cs +++ b/MLEM/Misc/Easings.cs @@ -114,6 +114,24 @@ namespace MLEM.Misc { return p => easing(p) * (max - min) + min; } + /// + /// Reverses the input of an easing function, which is usually between 0 and 1, to be passed into the easing function as if it were between 1 and 0. + /// + /// The easing function whose output to reverse. + /// The reversed easing function. + public static Easing ReverseInput(this Easing easing) { + return p => easing(1 - p); + } + + /// + /// Reverses the output of an easing function, which is usually between 0 and 1, to return as if it were between 1 and 0. + /// + /// The easing function whose input to reverse. + /// The reversed easing function. + public static Easing ReverseOutput(this Easing easing) { + return p => 1 - easing(p); + } + /// /// Causes the easing functino to play fully, and then play fully in reverse, in the span between an input of 0 and 1. /// In some places, this behavior is also called "auto-reversing".