Skip to content

Commit 8345158

Browse files
[Docs] Readme (#9)
* update readme - expressions * update readme - thank EXACTSports
1 parent 3ec39ac commit 8345158

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ $x->keyframe((new Keyframe)
7676

7777
> **Note** `new Timeline()` returns a _fluent_ api, meaning methods can be chained as well.
7878
79+
## Expression Helpers
80+
When writing _long_ and **complicated** evaluated expressions, it can be easy to lose track of extra/missing perentheses, missing parameters, or unescaped commas. Especially when the whole expression _has_ to be on one line without any linebreaks or whitespace.
81+
82+
The `Expr` class can help with this. If your expression is short enough this might be overkill, but for longer expressions this can really help with these issues.
83+
84+
```diff
85+
+ use ProjektGopher\FFMpegTween\Utils\Expr;
86+
87+
....
88+
89+
- return "if(eq(({$time})\\,0)\\,0\\,if(eq(({$time})\\,1)\\,1\\,pow(2\\,-10*({$time}))*sin((({$time})*10-0.75)*{$c4})+1))";
90+
+ return Expr::if(
91+
+ x: Expr::eq($time, '0'),
92+
+ y: '0',
93+
+ z: Expr::if(
94+
+ x: Expr::eq($time, '1'),
95+
+ y: '1',
96+
+ z: "pow(2\\,-10*({$time}))*sin((({$time})*10-0.75)*{$c4})+1",
97+
+ ),
98+
+ );
99+
```
100+
79101
## Testing
80102
```bash
81103
composer test
@@ -115,6 +137,8 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
115137
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
116138

117139
## Credits
140+
A **big** "Thank You" to [EXACTsports](https://github.com/EXACTsports) for supporting the development of this package.
141+
118142
- [Len Woodward](https://github.com/ProjektGopher)
119143
- [All Contributors](../../contributors)
120144

0 commit comments

Comments
 (0)