Skip to content

Instantly share code, notes, and snippets.

@IainS1986
IainS1986 / TimingFunction.cs
Created April 6, 2021 13:24
iOS Timing Function lookup to be able to get any value from within a given iOS timing curve (EaseIn, EaseOut, EaseInOut etc). This is itself a port of a port. Original logic found in RSTimingFunction (https://gist.github.com/raphaelschaad/6739676) and the Swift 4.2 port (https://gist.github.com/tcldr/204c4bc87c5239a53239a46728214715)
using System;
using CoreGraphics;
using UIKit;
// Xamarin port of the swift port of https://gist.github.com/raphaelschaad/6739676
// Swift 4.2 port https://gist.github.com/tcldr/204c4bc87c5239a53239a46728214715
//
// Basic Usage:
// var timingFunction = new TimingFunction(new UICubicTimingParameters(UIViewAnimationCurve.EaseInOut));
// var progress = timingFunction.Progress(time); // where time is 0->duration, use 0-1 for easier normalised look ups