Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@import QuartzCore.QuartzCore;
@interface CAMediaTimingFunction (TWTEasingFunctions)
+ (instancetype)twt_sineEaseInFunction;
+ (instancetype)twt_sineEaseOutFunction;
+ (instancetype)twt_sineEaseInOutFunction;
+ (instancetype)twt_quadraticEaseInFunction;
+ (instancetype)twt_quadraticEaseOutFunction;
+ (instancetype)twt_quadraticEaseInOutFunction;
+ (instancetype)twt_cubicEaseInFunction;
+ (instancetype)twt_cubicEaseOutFunction;
+ (instancetype)twt_cubicEaseInOutFunction;
+ (instancetype)twt_quarticEaseInFunction;
+ (instancetype)twt_quarticEaseOutFunction;
+ (instancetype)twt_quarticEaseInOutFunction;
+ (instancetype)twt_quinticEaseInFunction;
+ (instancetype)twt_quinticEaseOutFunction;
+ (instancetype)twt_quinticEaseInOutFunction;
+ (instancetype)twt_exponentialEaseInFunction;
+ (instancetype)twt_exponentialEaseOutFunction;
+ (instancetype)twt_exponentialEaseInOutFunction;
+ (instancetype)twt_circularEaseInFunction;
+ (instancetype)twt_circularEaseOutFunction;
+ (instancetype)twt_circularEaseInOutFunction;
+ (instancetype)twt_backEaseInFunction;
+ (instancetype)twt_backEaseOutFunction;
+ (instancetype)twt_backEaseInOutFunction;
@end
@implementation CAMediaTimingFunction (TWTEasingFunctions)
+ (instancetype)twt_sineEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.47 :0 :0.745 :0.715];
});
return function;
};
+ (instancetype)twt_sineEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.39 :0.575 :0.565 :1];
});
return function;
};
+ (instancetype)twt_sineEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.445 :0.05 :0.55 :0.95];
});
return function;
};
+ (instancetype)twt_quadraticEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.55 :0.085 :0.68 :0.53];
});
return function;
};
+ (instancetype)twt_quadraticEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.25 :0.46 :0.45 :0.94];
});
return function;
};
+ (instancetype)twt_quadraticEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.455 :0.03 :0.515 :0.955];
});
return function;
};
+ (instancetype)twt_cubicEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.55 :0.055 :0.675 :0.19];
});
return function;
};
+ (instancetype)twt_cubicEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.215 :0.61 :0.355 :1];
});
return function;
};
+ (instancetype)twt_cubicEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.645 :0.045 :0.355 :1];
});
return function;
};
+ (instancetype)twt_quarticEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.895 :0.03 :0.685 :0.22];
});
return function;
};
+ (instancetype)twt_quarticEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.165 :0.84 :0.44 :1];
});
return function;
};
+ (instancetype)twt_quarticEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.77 :0 :0.175 :1];
});
return function;
};
+ (instancetype)twt_quinticEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.755 :0.05 :0.855 :0.06];
});
return function;
};
+ (instancetype)twt_quinticEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.23 :1 :0.32 :1];
});
return function;
};
+ (instancetype)twt_quinticEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.86 :0 :0.07 :1];
});
return function;
};
+ (instancetype)twt_exponentialEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.95 :0.05 :0.795 :0.035];
});
return function;
};
+ (instancetype)twt_exponentialEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.19 :1 :0.22 :1];
});
return function;
};
+ (instancetype)twt_exponentialEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:1 :0 :0 :1];
});
return function;
};
+ (instancetype)twt_circularEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.6 :0.04 :0.98 :0.335];
});
return function;
};
+ (instancetype)twt_circularEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.075 :0.82 :0.165 :1];
});
return function;
};
+ (instancetype)twt_circularEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.785 :0.135 :0.15 :0.86];
});
return function;
};
+ (instancetype)twt_backEaseInFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.6 :-0.28 :0.735 :0.045];
});
return function;
};
+ (instancetype)twt_backEaseOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.175 :0.885 :0.32 :1.275];
});
return function;
};
+ (instancetype)twt_backEaseInOutFunction {
static CAMediaTimingFunction *function = ((void *)0);
static dispatch_once_t onceToken;
_dispatch_once(&onceToken, ^{
function = [[self alloc] initWithControlPoints:0.68 :-0.55 :0.265 :1.55];
});
return function;
};
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.