Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b97509a
Showing
69 changed files
with
15,842 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Mac OS X Finder and whatnot | ||
.DS_Store | ||
|
||
# rvm files | ||
.ruby-version | ||
.ruby-gemset | ||
Gemfile | ||
Gemfile.lock | ||
|
||
# Xcode | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
*.xcworkspace | ||
!default.xcworkspace | ||
xcuserdata | ||
profile | ||
*.moved-aside | ||
DerivedData | ||
.idea/ | ||
|
||
# Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
.build/ | ||
Packages/ | ||
|
||
# Project meta files | ||
docs_build/ | ||
Documentation/ | ||
development/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#### 1.0.0 | ||
Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// CATempo.swift | ||
// MotionMachine | ||
// | ||
// Created by Brett Walker on 4/19/16. | ||
// Copyright © 2016 Poet & Mountain, LLC. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import UIKit | ||
|
||
/** | ||
* CATempo uses a `CADisplayLink` object to send out tempo updates that are synchronized with the refresh rate of the display on iOS. | ||
*/ | ||
public class CATempo : Tempo { | ||
|
||
/** | ||
* This `CADisplayLink` object is used to provide tempo updates. | ||
* | ||
* - remarks: This class provides several mechanisms for adjusting the update rate. See the `CADisplayLink` documentation for more information. | ||
* | ||
* - warning: Do not call the `addToRunLoop:forMode:`, `removeFromRunLoop:forMode:`, or `invalidate` methods on this object, as its state is handled by CATempo directly. | ||
*/ | ||
public var displayLink: CADisplayLink? | ||
|
||
/** | ||
* Initializes a new `CATempo` object and adds the internal `CADisplayLink` object to the main run loop. | ||
* | ||
*/ | ||
public override init() { | ||
super.init() | ||
displayLink = CADisplayLink.init(target: self, selector: #selector(update)) | ||
displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes) | ||
} | ||
|
||
deinit { | ||
displayLink?.invalidate() | ||
} | ||
|
||
|
||
@objc func update() -> Void { | ||
let time_stamp: CFTimeInterval = self.displayLink?.timestamp ?? 0.0 | ||
delegate?.tempoBeatUpdate(time_stamp) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// EasingBack.swift | ||
// MotionMachine | ||
// | ||
// Created by Brett Walker on 5/3/16. | ||
// Copyright © 2016 Poet & Mountain, LLC. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import Foundation | ||
|
||
/** | ||
* EasingBack provides easing equations which move beyond the specified starting and ending values and snap back, as if attached to a rubber band. | ||
* | ||
* - warning: These equations produce easing values extending beyond the starting and ending values, which may produce unpredictable results for properties which have strict bounds limits. | ||
*/ | ||
public struct EasingBack { | ||
|
||
private static let magic100 = 1.70158 * 10 | ||
|
||
/** | ||
* This function provides an equation in which the value moves beyond the starting value before moving to the ending value. | ||
* | ||
* - parameter overshoot: Provides a way to modify how far the starting value will be overshot. 0.0 to 1.0 is a reasonable range to use. | ||
*/ | ||
public static func easeIn(overshoot over: Double=0.1) -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
let time = elapsedTime / duration | ||
let overshoot = over * magic100 | ||
let easing_value = valueRange * time*time*((overshoot + 1.0)*time - overshoot) + startValue | ||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
/** | ||
* This function provides an equation in which the value moves beyond the ending value before moving to the ending value. | ||
* | ||
* - parameter overshoot: Provides a way to modify how far the ending value will be overshot. 0.0 to 1.0 is a reasonable range to use. | ||
*/ | ||
public static func easeOut(overshoot over: Double=0.1) -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
let time = elapsedTime / duration - 1 | ||
let overshoot = over * magic100 | ||
let easing_value = valueRange * (time*time * ((overshoot+1.0) * time + overshoot) + 1.0) + startValue | ||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
/** | ||
* This function provides an equation in which the value moves beyond both the starting and ending values. | ||
* | ||
* - parameter overshoot: Provides a way to modify how far the starting and ending values will be overshot. 0.0 to 1.0 is a reasonable range to use. | ||
*/ | ||
public static func easeInOut(overshoot over: Double=0.1) -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
var easing_value = 0.0 | ||
var time = elapsedTime / (duration * 0.5) | ||
let overshoot = (over * magic100) * 1.525 | ||
|
||
if (time < 1.0) { | ||
easing_value = (valueRange * 0.5) * (time*time*((overshoot + 1.0)*time - overshoot)) + startValue; | ||
} else { | ||
time -= 2.0; | ||
easing_value = (valueRange * 0.5) * (time*time*((overshoot + 1.0)*time + overshoot) + 2.0) + startValue; | ||
} | ||
|
||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// EasingBounce.swift | ||
// MotionMachine | ||
// | ||
// Created by Brett Walker on 5/3/16. | ||
// Copyright © 2016 Poet & Mountain, LLC. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import Foundation | ||
|
||
/** | ||
* EasingBounce provides easing equations that have successively smaller value peaks, like a bouncing ball. | ||
* | ||
*/ | ||
public struct EasingBounce { | ||
|
||
static let magic100 = 1.70158 * 10 | ||
|
||
public static func easeIn() -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
|
||
let easing_closure = EasingBounce.easeOut() | ||
let time = duration - elapsedTime | ||
let easing_value = valueRange - easing_closure(elapsedTime: time, startValue: 0.0, valueRange: valueRange, duration: duration) + startValue | ||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
public static func easeOut() -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
var time = elapsedTime / duration | ||
let easing_value: Double | ||
if (time < (1/2.75)) { | ||
easing_value = valueRange * (7.5625 * time*time) + startValue; | ||
} else if (time < (2 / 2.75)) { | ||
time -= (1.5 / 2.75); | ||
easing_value = valueRange * (7.5625 * time*time + 0.75) + startValue; | ||
} else if (time < (2.5/2.75)) { | ||
time -= (2.25/2.75); | ||
easing_value = valueRange * (7.5625 * time*time + 0.9375) + startValue; | ||
} else { | ||
time -= (2.625/2.75); | ||
easing_value = valueRange * (7.5625 * time*time + 0.984375) + startValue; | ||
} | ||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
public static func easeInOut() -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
let easing_value: Double | ||
let easing_closure = EasingBounce.easeOut() | ||
|
||
if (elapsedTime < (duration * 0.5)) { | ||
easing_value = easing_closure(elapsedTime: (elapsedTime*2), startValue: 0, valueRange: valueRange, duration: duration) * 0.5 + startValue; | ||
} else { | ||
easing_value = easing_closure(elapsedTime: (elapsedTime*2-duration), startValue: 0, valueRange: valueRange, duration: duration) * 0.5 + (valueRange*0.5) + startValue; | ||
} | ||
|
||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// EasingCircular.swift | ||
// MotionMachine | ||
// | ||
// Created by Brett Walker on 5/3/16. | ||
// Copyright © 2016 Poet & Mountain, LLC. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import Foundation | ||
|
||
/** | ||
* EasingCircular provides circular easing equations. | ||
*/ | ||
public struct EasingCircular { | ||
|
||
public static func easeIn() -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
let time = elapsedTime / duration | ||
let easing_value = -valueRange * (sqrt(1 - time*time) - 1) + startValue | ||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
public static func easeOut() -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
var time = elapsedTime / duration | ||
time -= 1 | ||
let easing_value = valueRange * sqrt(1 - time*time) + startValue | ||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
public static func easeInOut() -> EasingUpdateClosure { | ||
|
||
func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double { | ||
var easing_value = 0.0 | ||
var time = elapsedTime / (duration * 0.5) | ||
|
||
if (time < 1) { | ||
easing_value = (-valueRange * 0.5) * (sqrt(1 - time*time) - 1) + startValue; | ||
} else { | ||
time -= 2; | ||
easing_value = (valueRange * 0.5) * (sqrt(1 - time*time) + 1) + startValue; | ||
} | ||
|
||
|
||
return easing_value | ||
} | ||
|
||
return easing | ||
} | ||
|
||
} |
Oops, something went wrong.