Skip to content

Commit f9dec17

Browse files
authored
Update README.md
1 parent a90b148 commit f9dec17

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

README.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,55 @@ handler.Update(200); // point.X == 4
2929
handler.Update(200); // point.X == 6
3030
handler.Update(200); // point.X == 8
3131
handler.Update(200); // point.X == 10
32-
handler.Update(100); // point.X == 10 (Tween has ended)
32+
handler.Update(100); // point.X == 10 (tween has ended)
3333
```
34-
Ideally you create own handler instance and update it everytime your scene renders.
34+
Ideally you create one handler instance and update it everytime your scene renders. For example for WPF the CompositionTarget.Rendering event.
3535

3636
### Fine tuning
3737
You can use easing functions, delays and concatination of multiple properties.
3838
```C#
39-
point.Tween(x => x.X).And(x => x.Y).To(20).In(1.5).Ease(Easing.BackEaseIn).Delay(0.5);
39+
point.Tween(x => x.X)
40+
.And(x => x.Y) // tween multiple properties at once
41+
.To(20).In(1.5)
42+
.Ease(Easing.BackEaseIn) // specify custom easing functions
43+
.Delay(0.5); // specify a delay before the tweening starts
4044
````
4145
See the Easing.cs class for all available easing methods.
4246

47+
### Sequence
48+
Use .ToSequence() to nest multiple tweens into one
49+
```C#
50+
var tweens = new List<Timeline>(); // timeline is the base class for tweens
51+
tweens.Add(point.Tween(x => x.X).To(20).In(1));
52+
tweens.Add(point.Tween(x => x.Y).To(10).In(1));
53+
handler.Add(tweens.ToSequence()); // a sequence is a single instance which contains multiple tweens
54+
````
55+
56+
### AlwaysOnCurrentValue
57+
React to interrupting value changes.
58+
AlwaysOnCurrentValue tells the tween to always use the current value instead of initializing it once the tweens starts.
59+
```C#
60+
// with AlwaysOnCurrentValue = false (default)
61+
handler.Add(point.Tween(x => x.X).To(10).In(0.5));
62+
handler.Update(100); // point.X == 2, initialized start value with the current value of point.X (0)
63+
handler.Update(100); // point.X == 4
64+
handler.Update(100); // point.X == 6
65+
point.X = 0;
66+
// the current value is calculated with the progress (80%) of the start value (0) and target value (10):
67+
handler.Update(100); // point.X == 8 // note that updating point.X did not have an effect on the tween
68+
handler.Update(100); // point.X == 10
69+
70+
// with AlwaysOnCurrentValue = true
71+
handler.Add(point.Tween(x => x.X).To(10).In(0.5).AlwaysOnCurrentValue(false));
72+
handler.Update(100); // point.X == 2
73+
handler.Update(100); // point.X == 4
74+
handler.Update(100); // point.X == 6
75+
point.X = 0;
76+
// the current value is calculated with the progress (80%) of the CURRENT value (0) and target value (10):
77+
handler.Update(100); // point.X == 5
78+
handler.Update(100); // point.X == 10
79+
````
80+
4381
### Events
4482
```C#
4583
point.Tween(x => x.X).To(20).In(0.5).Delay(1.0)
@@ -58,9 +96,7 @@ handler.Update(200); // point.X == 4 OnUpdate called
5896
handler.Update(200); // point.X == 6 OnUpdate called
5997
handler.Update(200); // point.X == 8 OnUpdate called
6098
handler.Update(200); // point.X == 10 OnUpdate called, OnComplete called
61-
handler.Update(100); // point.X == 10 (Tween has ended)
62-
63-
99+
handler.Update(100); // point.X == 10 (tween has ended)
64100
````
65101
### Repeat
66102
You can specifiy repeat actions.
@@ -78,6 +114,16 @@ point.Tween(x => x.X).To(20).In(0.5).Delay(1.0).Repeat(1)
78114
.OnComplete(OnCompleteHandler); // gets called after 2 seconds (delay + duration + repeat duration)
79115
````
80116

117+
### Time
118+
Through time modifiying you can achieve slow- or fast-motion effects.
119+
```C#
120+
handler.TimeModifier = 0.5; // runs tweens at half speed
121+
handler.TimeModifier = 2; // runs tweens at double speed
122+
123+
// You can even tween this property
124+
handler.Add(handler.Tween(x => x.TimeModifier).To(0.5).In(0.5).Yoyo(true).Repeat(1));
125+
````
126+
81127
### Custom tween operations
82128
You can specify custom functions for tweening properties
83129
```C#
@@ -114,6 +160,7 @@ public static UInt32 ColorProgressFunction(UInt32 startValue, UInt32 endValue, d
114160
}
115161

116162
var someObjectWithColor = new SomeObjectWithColor { Color = 0xff0000ff } // Color is UInt32
163+
117164
// tween blue to red in 1 second
118165
someObjectWithColor(x => x.Color, ColorProgressFunction).To(0xffff0000).In(1.0);
119166
````

0 commit comments

Comments
 (0)