MMMAnimation
Objective-C
@interface MMMAnimation : NSObject
Swift
class MMMAnimation : NSObject
Minimalistic animation helpers.
Terminology:
- Normalized time — time value from the [0; 1] range.
- Curved time — normalized time transformed using one of the predefined animation curves.
-
Time obtained by curving the given normalized time (from [0; 1] range).
Declaration
Objective-C
+ (CGFloat)curvedTimeForTime:(CGFloat)time curve:(MMMAnimationCurve)curve;
Swift
class func curvedTime(forTime time: CGFloat, curve: MMMAnimationCurve) -> CGFloat
-
Inverse function for curvedTimeForTime:curve:, i.e. when we know the value returned by curvedTimeForTime:curve: and want the time value passed there. This should be used sparingly (not every frame) as the implementation is no very efficient.
Declaration
Objective-C
+ (CGFloat)timeForCurvedTime:(CGFloat)time curve:(MMMAnimationCurve)curve;
Swift
class func time(forCurvedTime time: CGFloat, curve: MMMAnimationCurve) -> CGFloat
-
Time obtained by clamping the given time into [startTime; startTime + duration], normalizing to [0; 1] range, and then curving using a preset curve.
Declaration
Objective-C
+ (CGFloat)curvedTimeForTime:(CGFloat)t startTime:(CGFloat)startTime duration:(CGFloat)duration curve:(MMMAnimationCurve)curve;
Swift
class func curvedTime(forTime t: CGFloat, startTime: CGFloat, duration: CGFloat, curve: MMMAnimationCurve) -> CGFloat
-
A float between ‘from’ and ‘to’ corresponding to already normalized and curved time.
Declaration
Objective-C
+ (CGFloat)interpolateFrom:(CGFloat)from to:(CGFloat)to time:(CGFloat)time;
Swift
class func interpolate(from: CGFloat, to: CGFloat, time: CGFloat) -> CGFloat
-
Deprecated
This has been renamed. Use the version above.
Declaration
Objective-C
+ (CGFloat)interpolateFrom:(CGFloat)from to:(CGFloat)to curvedTime:(CGFloat)time;
Swift
class func interpolate(from: CGFloat, to: CGFloat, curvedTime time: CGFloat) -> CGFloat
-
Value between two floats corresponding to the given time and timing curve. If the time is less then startTime, then ‘from’ is returned. If the time is greater then startTime + duration, then ‘to’ is returned.
Declaration
Objective-C
+ (CGFloat)interpolateFrom:(CGFloat)from to:(CGFloat)to time:(CGFloat)time startTime:(CGFloat)startTime duration:(CGFloat)duration curve:(MMMAnimationCurve)curve;
Swift
class func interpolate(from: CGFloat, to: CGFloat, time: CGFloat, startTime: CGFloat, duration: CGFloat, curve: MMMAnimationCurve) -> CGFloat
-
A color between ‘from’ and ‘to’ corresponding to already normalized and curved time. Only RGB colors are supported. Interpolation is done along a straight line in the RGB space.
Declaration
Objective-C
+ (nonnull UIColor *)colorFrom:(nonnull UIColor *)from to:(nonnull UIColor *)to time:(CGFloat)time;
Swift
class func color(from: UIColor, to: UIColor, time: CGFloat) -> UIColor
-
A point on the line between given points corresponding to already normalized and curved time.
Declaration
Objective-C
+ (CGPoint)pointFrom:(CGPoint)from to:(CGPoint)to time:(CGFloat)time;
Swift
class func point(from: CGPoint, to: CGPoint, time: CGFloat) -> CGPoint