@@ -23,7 +23,8 @@ $x = (new Tween())
2323```
2424
2525The API is modelled after [ The GreenSock Animation Platform (GSAP)] ( https://greensock.com/get-started/#whatIsGSAP )
26- and all the math for the easings is ported from [ Easings.net] ( https://easings.net. )
26+ and all the math for the easings is ported from [ Easings.net] ( https://easings.net ) .
27+ The stringification of these math strings is ported from [ This Gitlab repo] ( https://gitlab.com/dak425/easing/-/blob/master/ffmpeg/ffmpeg.go )
2728
2829
2930## Installation
@@ -40,6 +41,7 @@ For now this package can only be used within a Laravel app, but there are plans
4041
4142## Usage
4243
44+ Simple tween with delay and duration
4345``` php
4446use ProjektGopher\FFMpegTween\Tween;
4547use ProjektGopher\FFMpegTween\Timing;
@@ -53,6 +55,32 @@ $x = (new Tween())
5355 ->ease(Ease::OutSine);
5456```
5557
58+ Animation sequences using keyframes
59+ ``` php
60+ use ProjektGopher\FFMpegTween\Keyframe;
61+ use ProjektGopher\FFMpegTween\Timeline;
62+ use ProjektGopher\FFMpegTween\Timing;
63+ use ProjektGopher\FFMpegTween\Enums\Ease;
64+
65+ $x = new Timeline()
66+ $x->keyframe((new Keyframe)
67+ ->value('-text_w') // outside left of frame
68+ ->hold(Timing::seconds(1))
69+ );
70+ $x->keyframe((new Keyframe)
71+ ->value('(main_w/2)-(text_w/2)') // center
72+ ->ease(Ease::OutElastic)
73+ ->duration(Timing::seconds(1))
74+ ->hold(Timing::seconds(3))
75+ );
76+ $x->keyframe((new Keyframe)
77+ ->value('main_w') // outside right of frame
78+ ->ease(Ease::InBack)
79+ ->duration(Timing::seconds(1))
80+ );
81+ ```
82+ > ** Note** ` new Timeline() ` returns a _ fluent_ api, meaning methods can be chained as well.
83+
5684## Testing
5785
5886``` bash
@@ -62,12 +90,20 @@ composer test
6290### Visual Snapshot Testing
6391To generate plots of all ` Ease ` methods, from the project root, run
6492``` bash
65- ./scripts/generateSnapshots
93+ ./scripts/generateEasings
6694```
67- The 256x256 PNGs will be generated in the ` tests/Snapshots ` directory.
95+ The 256x256 PNGs will be generated in the ` tests/Snapshots/Easings ` directory.
6896These snapshots will be ignored by git, but allow visual inspection of the plots to
6997compare against known good sources, like [ Easings.net] ( https://easings.net ) .
7098
99+ To generate a video using a ` Timeline ` with ` Keyframes ` , from the project root, run
100+ ``` bash
101+ ./scripts/generateTimeline
102+ ```
103+ The 256x256 MP4 will be generated in the ` tests/Snapshots/Timelines ` directory.
104+ These snapshots will also be ignored by git, but again allow for a visual
105+ inspection to ensure they match the expected output.
106+
71107> ** Note** The ` scripts ` directory _ may_ need to have its permissions changed to allow script execution
72108``` bash
73109chmod -R 777 ./scripts
0 commit comments