Skip to content

Commit

Permalink
Add Readme playground
Browse files Browse the repository at this point in the history
  • Loading branch information
modzelewski committed Oct 24, 2016
1 parent d441a23 commit aaf2333
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
67 changes: 67 additions & 0 deletions Readme.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions Readme.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>
2 changes: 2 additions & 0 deletions TRX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
6699A1971D51FE3400F530F6 /* Morphable+CATransform3D.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Morphable+CATransform3D.swift"; sourceTree = "<group>"; };
669DCE2D1D6B240B0005CB15 /* Morphable+CGAffineTransformSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Morphable+CGAffineTransformSpec.swift"; sourceTree = "<group>"; };
669DCE2F1D6B24290005CB15 /* Morphable+CATransform3DSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Morphable+CATransform3DSpec.swift"; sourceTree = "<group>"; };
66DB23EB1DBE4A260093096B /* Readme.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Readme.playground; sourceTree = "<group>"; };
66E5EC391D461C3C00C2B1DA /* Tween.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tween.swift; sourceTree = "<group>"; };
66E5EC3B1D461C3C00C2B1DA /* TimeLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimeLine.swift; sourceTree = "<group>"; };
66E5EC3D1D461C3C00C2B1DA /* Tween+Double.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Tween+Double.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -242,6 +243,7 @@
66D55E8D1D45FA7400A4DA1C = {
isa = PBXGroup;
children = (
66DB23EB1DBE4A260093096B /* Readme.playground */,
663E814A1D45FCBD00130EB5 /* Sources */,
667AEFD41D460A7D004E291C /* TRXTests */,
663E81421D45FC6F00130EB5 /* Products */,
Expand Down

0 comments on commit aaf2333

Please sign in to comment.