Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
Created April 5, 2010 20:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simonwhitaker/356845 to your computer and use it in GitHub Desktop.
Save simonwhitaker/356845 to your computer and use it in GitHub Desktop.
A simple Objective-C program to show the control point values for the constants in the CAMediaTimingFunction class
/*
show-constants.m
Show the control point values for the CAMediaTimingFunction class constants
To compile:
clang -framework QuartzCore -framework Foundation show-constants.m -o show-constants
*/
#import <QuartzCore/QuartzCore.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSArray* functions = @[
kCAMediaTimingFunctionLinear,
kCAMediaTimingFunctionEaseIn,
kCAMediaTimingFunctionEaseOut,
kCAMediaTimingFunctionEaseInEaseOut,
kCAMediaTimingFunctionDefault,
];
float coords[2];
for (id obj in functions) {
NSString* function_name = (NSString*) obj;
CAMediaTimingFunction* func = [CAMediaTimingFunction functionWithName:function_name];
printf("%-13s ", [function_name cStringUsingEncoding:NSUTF8StringEncoding]);
for (int i = 0; i <= 3; i++) {
[func getControlPointAtIndex:i values:coords];
printf("(%.2f, %.2f)%s", coords[0], coords[1], i < 3 ? ", " : "\n");
}
}
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment