Skip to content

Instantly share code, notes, and snippets.

@aashishdhawan
Created January 25, 2017 11:41
Show Gist options
  • Save aashishdhawan/829dfdb8ab804196520081806f7dac50 to your computer and use it in GitHub Desktop.
Save aashishdhawan/829dfdb8ab804196520081806f7dac50 to your computer and use it in GitHub Desktop.
Print control points for default `CAMediaTimingFunctions`
import QuartzCore
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let cords: UnsafeMutablePointer<Float> = UnsafeMutablePointer.allocate(capacity: 2)
let defaultTimingFunctionOptions = [kCAMediaTimingFunctionLinear, kCAMediaTimingFunctionEaseIn, kCAMediaTimingFunctionEaseOut, kCAMediaTimingFunctionEaseInEaseOut, kCAMediaTimingFunctionDefault]
let timingFunctions = defaultTimingFunctionOptions.map({ CAMediaTimingFunction(name: $0) })
for timingFunction in timingFunctions {
print("\n" + timingFunction.description)
for i in 0..<4 {
timingFunction.getControlPoint(at: i, values: cords)
let string = String(format: "(%.2f, %.2f)", cords[0], cords[1])
print(string)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment