diff --git a/Readme.playground/Contents.swift b/Readme.playground/Contents.swift new file mode 100644 index 0000000..7a938c5 --- /dev/null +++ b/Readme.playground/Contents.swift @@ -0,0 +1,67 @@ +import TRX +import UIKit + +struct ExampleObject { + var value: Double +} + +var object = ExampleObject(value: 0) +var anOtherObject = object + +struct ExampleLayer { + var position: CGPoint +} + +var layer = ExampleLayer(position: CGPoint.zero) +var myView = UIView() +var someFrame = CGRect() + +Tween(from: 0, to: 20, time: 0.3) { + object.value = $0 +}.start() + +1.trx(to: 20) { object.value = $0 }.start() + +Tween(from: CGPoint.zero, to: CGPoint(x: 20, y: 15), time: 0.3) { + layer.position = $0 +}.start() + +Tween(from: 0, + to: 1, + time: 0.3, + delay: 0.1, + ease: Ease.Elastic.easeOut, + key: "MyOwnKey", + onStart: { print("start") }, + onComplete: { done in print("complete and done: \(done)") }) { value in + object.value = value +}.start() + +TimeLine(tweens: [ + 1.trx(to: 20) { object.value = $0 }, + 30.trx(to: 40) { object.value = $0 }, + 40.trx(to: 50) { object.value = $0 }, +]).start() + + +let timeline: TimeLine = [ + 1.trx(to: 20) { object.value = $0 }: 0, + 30.trx(to: 40) { anOtherObject.value = $0 }: -0.5, + 40.trx(to: 50) { anOtherObject.value = $0 }: -0.5 +] +timeline.start() + +let tween = Tween(from: 0, + to: 1, + time: 0.5) { print($0) } + +tween.scale = 2 // duration: 1s +tween.duration = 2.0 // scale: 4 + +myView.trxCenter(to: CGPoint(x: 10, y: 15)) + +myView.trxCenter(from: CGPoint.zero) + +myView.trxFrame(to: someFrame) + +myView.trxFrame(to: someFrame) diff --git a/Readme.playground/contents.xcplayground b/Readme.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/Readme.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TRX.xcodeproj/project.pbxproj b/TRX.xcodeproj/project.pbxproj index b9a1095..066d200 100644 --- a/TRX.xcodeproj/project.pbxproj +++ b/TRX.xcodeproj/project.pbxproj @@ -117,6 +117,7 @@ 6699A1971D51FE3400F530F6 /* Morphable+CATransform3D.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Morphable+CATransform3D.swift"; sourceTree = ""; }; 669DCE2D1D6B240B0005CB15 /* Morphable+CGAffineTransformSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Morphable+CGAffineTransformSpec.swift"; sourceTree = ""; }; 669DCE2F1D6B24290005CB15 /* Morphable+CATransform3DSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Morphable+CATransform3DSpec.swift"; sourceTree = ""; }; + 66DB23EB1DBE4A260093096B /* Readme.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Readme.playground; sourceTree = ""; }; 66E5EC391D461C3C00C2B1DA /* Tween.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tween.swift; sourceTree = ""; }; 66E5EC3B1D461C3C00C2B1DA /* TimeLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimeLine.swift; sourceTree = ""; }; 66E5EC3D1D461C3C00C2B1DA /* Tween+Double.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Tween+Double.swift"; sourceTree = ""; }; @@ -242,6 +243,7 @@ 66D55E8D1D45FA7400A4DA1C = { isa = PBXGroup; children = ( + 66DB23EB1DBE4A260093096B /* Readme.playground */, 663E814A1D45FCBD00130EB5 /* Sources */, 667AEFD41D460A7D004E291C /* TRXTests */, 663E81421D45FC6F00130EB5 /* Products */,