darling-cocotron/QuartzCore/CAMediaTimingFunction.m

79 lines
2.1 KiB
Mathematica
Raw Permalink Normal View History

2010-10-22 01:21:17 +00:00
#import <Foundation/NSRaise.h>
#import <Foundation/NSString.h>
#import <QuartzCore/CAMediaTimingFunction.h>
2010-10-22 01:21:17 +00:00
NSString *const kCAMediaTimingFunctionLinear = @"kCAMediaTimingFunctionLinear";
NSString *const kCAMediaTimingFunctionEaseIn = @"kCAMediaTimingFunctionEaseIn";
NSString *const kCAMediaTimingFunctionEaseOut =
2020-05-12 18:51:39 +00:00
@"kCAMediaTimingFunctionEaseOut";
NSString *const kCAMediaTimingFunctionEaseInEaseOut =
2020-05-12 18:51:39 +00:00
@"kCAMediaTimingFunctionEaseInEaseOut";
NSString *const kCAMediaTimingFunctionDefault =
2020-05-12 18:51:39 +00:00
@"kCAMediaTimingFunctionDefault";
2010-10-22 01:21:17 +00:00
@implementation CAMediaTimingFunction
- initWithControlPoints: (CGFloat)
c1x: (CGFloat) c1y
:(CGFloat) c2x
2020-05-12 00:04:26 +00:00
:(CGFloat) c2y
{
_c1x = c1x;
_c1y = c1y;
_c2x = c2x;
_c2y = c2y;
return self;
2010-10-22 01:21:17 +00:00
}
+ functionWithControlPoints: (CGFloat)
c1x: (CGFloat) c1y
:(CGFloat) c2x
2020-05-12 00:04:26 +00:00
:(CGFloat) c2y
{
return [[[self alloc] initWithControlPoints: c1x: c1y:c2x:c2y] autorelease];
2010-10-22 01:21:17 +00:00
}
+ functionWithName: (NSString *) name {
if ([name isEqualToString: kCAMediaTimingFunctionLinear])
return [self functionWithControlPoints: 0: 0:1:1];
if ([name isEqualToString: kCAMediaTimingFunctionEaseIn])
return [self functionWithControlPoints: 0.5: 0:1:1];
if ([name isEqualToString: kCAMediaTimingFunctionEaseOut])
return [self functionWithControlPoints: 0: 0:0.5:1];
if ([name isEqualToString: kCAMediaTimingFunctionEaseInEaseOut])
return [self functionWithControlPoints: 0.5: 0:0.5:1];
if ([name isEqualToString: kCAMediaTimingFunctionDefault])
return [self functionWithControlPoints: 0.25: 0.1:0.25:1];
return nil;
2010-10-22 01:21:17 +00:00
}
- (void) getControlPointAtIndex: (size_t) index values: (CGFloat[2]) ptr {
switch (index) {
2011-01-04 02:45:53 +00:00
default:
case 0:
ptr[0] = 0;
ptr[1] = 0;
break;
2011-01-04 02:45:53 +00:00
case 1:
ptr[0] = _c1x;
ptr[1] = _c1y;
break;
2011-01-04 02:45:53 +00:00
case 2:
ptr[0] = _c2x;
ptr[1] = _c2y;
break;
2011-01-04 02:45:53 +00:00
case 3:
ptr[0] = 1;
ptr[1] = 1;
break;
}
2010-10-22 01:21:17 +00:00
}
@end