forked from twolivesleft/Codea-Documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animation.yaml
882 lines (750 loc) · 21.9 KB
/
Animation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
id: animation
name: Animation
subtitle: Animate values and objects using tweens
ordering:
- Animating Values
- Looping Types
- Easing Types
functions:
#---------------------------------
# tween
#---------------------------------
- category: function
description: >
Animates values in `subject` until they are equal to the key value pairs specified the table `target` over `time` seconds. The optional `easing` type and `callback` can also be specified.
`callback` is a function that will be called when the tween has finished animating. Any additional parameters passed to `tween`
are forwarded to the `callback` function as additional arguments.
`tween` returns a table that can be used as a unique identifier to identify the tween. This table can be passed to `tween.stop` and `tween.reset`.
Note that the `easing` parameter may be passed in place of the `options` table, this will assume the default loop type of `tween.loop.once`. If you would like to specify a custom
loop type, then pass a table for `options` with the keys 'loop' and 'easing' set to the desired values.
group: Animating Values
id: tween
name: tween(time, subject, target)
parameters:
- description: float, the duration of the tween in seconds.
name: time
- description: table or userdata, the object to animate.
name: subject
- description: >
table, a table of key-value pairs that will be animated in subject, i.e. {x = 10} will animate x to the value 10 in subject.
name: target
- description: |
string or function, an optional easing type for the tween which can be specified as a function or string. There is a complete set of easing functions that fall into the general categories:
**linear** The default easing function
**quad, cubic, quart, quint, expo, sine** Different variations of smooth acceleration and deceleration
**back** Causes the subject to overshoot and then pull back
**bounce** Causes the subject to hit the target and bounce several times
**elastic** Causes the subject to oscillate like a guitar string around the target
Each easing curve has four variants with the exception of **linear**
**in**
**out**
**inOut**
**outIn**
Easing functions a combination of type and variant, such as 'elasticIn', 'quadInOut' and 'backOut'.
These easing functions were adapted from Emmanuel Oga’s easing library
name: easing
- description: >
table, may contain a loop type specified under the 'loop' key and an easing type specified under the 'easing' key
name: options
- description: function, a function to call when this tween has completed
name: callback
related:
- tween.stop
- tween.stopAll
- tween.reset
- tween.resetAll
returns:
table, returns a tween identifier that can be used to pause, reset or stop the tween
examples:
- example: |
box = { x = 10, y = 10,
width = 20, height = 20,
fillColor = color(255) }
tween(1, box, {x = 100, y = 100})
tween(1, box,
{fillColor = color(255,0,0)})
tween(1, box, {x = 100, y = 100},
tween.easing.quadIn)
tween(1, box, {x = 100, y = 100},
tween.easing.linear)
tween(1, box, {x = 100, y = 100},
tween.easing.linear,
function()
print("Tween Ended")
end)
tween(1, box, {x = 100, y = 100},
tween.easing.linear,
function(param)
print(param)
end, "Tween Ended")
syntax: |
tween( time, subject, target )
tween( time, subject, target, easing )
tween( time, subject, target, easing,
callback )
tween( time, subject, target, options,
callback )
tween( time, subject, target, options,
callback, ... )
tween( time, subject, target, options,
callback, ... )
#---------------------------------
#---------------------------------
# tween.stop
#---------------------------------
- category: function
description: |
Stops the tween specified by `id`. This does not reset the subject's values to their initial state.
group: Animating Values
id: tween.stop
name: tween.stop(id)
parameters:
- description: table, the id of the tween to stop
name: id
related:
- tween.stop
- tween.stopAll
- tween.reset
- tween.resetAll
examples:
- example: |
point = { x = 10, y = 10}
id = tween(1, point, {x = 100})
tween.stop(id)
syntax: |
tween.stop( id )
#---------------------------------
#---------------------------------
# tween.stopAll
#---------------------------------
- category: function
description: |
Stops all active tweens without resetting them.
group: Animating Values
id: tween.stopAll
name: tween.stopAll()
related:
- tween.stop
- tween.stopAll
- tween.reset
- tween.resetAll
examples:
- example: |
point = { x = 10, y = 10}
tween(1, point, {x = 100})
tween(2, point, {x = 200})
-- all tweens will now cease animating
tween.stopAll()
syntax: |
tween.stopAll()
#---------------------------------
#---------------------------------
# tween.reset
#---------------------------------
- category: function
description: |
Stops the tween specified by `id` and resets the subject's values to their initial state.
group: Animating Values
id: tween.reset
name: tween.reset(id)
parameters:
- description: table, the id of the tween to reset
name: id
related:
- tween.stop
- tween.stopAll
- tween.reset
- tween.resetAll
examples:
- example: |
point = { x = 10, y = 10}
id = tween(1, point, {x = 100})
-- point.x will now now return to 10
tween.reset(id)
syntax: |
tween.reset( id )
#---------------------------------
#---------------------------------
# tween.resetAll
#---------------------------------
- category: function
description: |
Resets all active tweens, returning all subject's to their state before the animation.
group: Animating Values
id: tween.resetAll
name: tween.resetAll()
related:
- tween.stop
- tween.stopAll
- tween.reset
- tween.resetAll
examples:
- example: |
point = { x = 10, y = 10}
tween(1, point, {x = 100})
tween(2, point, {x = 200})
-- point will now return to {x = 10, y = 10}
tween.resetAll()
syntax: |
tween.resetAll()
#---------------------------------
#---------------------------------
# tween.delay
#---------------------------------
- category: function
description: >
This function creates a tween that simply waits for the specified duration. You might
use this to create a pause within a `tween.sequence`, or to delay the calling of
a particular function.
Any additional arguments specified after the `callback` parameter will be passed as
arguments to the `callback` function.
group: Animating Values
id: tween.delay
name: tween.delay(duration, callback)
parameters:
- description: number, the duration of the delay
name: duration
- description: function, optional callback function
name: callback
related:
- tween
- tween.sequence
examples:
- example: |
point = {x = 10, y = 10}
t1 = tween(1, point, {x = 100})
-- Create a delay
delay = tween.delay(1.0)
t2 = tween(1, point, {y = 150})
tween.sequence( t1, delay, t2 )
syntax: |
tween.delay( duration )
tween.delay( duration, callback )
tween.delay( duration, callback, ... )
returns:
table, returns the tween identifier for the delay
#---------------------------------
#---------------------------------
# tween.sequence
#---------------------------------
- category: function
description: >
This function allows you to compose sequences made up of multiple tweens. Each call to the `tween` function
returns an **id**, `tween.sequence` accepts a list of these **id**s and plays them back one after the other.
group: Animating Values
id: tween.sequence
name: tween.sequence( t1, t2, ... )
parameters:
- description: the id of a tween in the sequence
name: t1
related:
- tween
- tween.path
- tween.resetAll
examples:
- example: |
point = {x = 10, y = 10}
t1 = tween(1, point, {x = 100})
t2 = tween(1, point, {x = 50})
t3 = tween(1, point, {y = 150})
tween.sequence( t1, t2, t3 )
syntax: |
tween.sequence( t1, t2, t3, ... )
returns:
table, returns the tween identifier for the first tween in the sequence
#---------------------------------
#---------------------------------
# tween.path
#---------------------------------
- category: function
description: >
`tween.path` is similar to `tween` except it accepts an array of target values. The resulting animation
interpolates across all the values in `targets` using a spline.
group: Animating Values
id: tween.path
name: tween.path( time, subject, targets )
parameters:
- description: float, the duration of the tween
name: time
- description: table or userdata, the object to animate
name: subject
- description: table, an array of tables containing key-value pairs for each point along the path
name: targets
- description: >
table, may contain a loop type specified under the 'loop' key and an easing type specified under the 'easing' key
name: options
- description: >
function, one of the easing functions specified in `tween.easing`
name: easing
- description: function, triggered when the animation is complete
name: callback
related:
- tween
examples:
- example: |
point = {x = 10, y = 10}
p1 = {x = 10, y = 10}
p2 = {x = 100, y = 10}
p3 = {x = 100, y = 100}
p4 = {x = 10, y = 100 }
tween.path( 4.0, point, {p1,p2,p3,p4,p1} )
syntax: |
tween.path( time, subject, targets )
tween.path( time, subject,
targets, easing )
tween.path( time, subject,
targets, options )
tween.path( time, subject,
targets, options, callback )
tween.path( time, subject,
targets, options,
callback, ... )
returns:
table, returns a tween identifier that can be used to pause, reset or stop the tween
#---------------------------------
#---------------------------------
# tween.loop.once
#---------------------------------
- category: const
description: >
Plays the tween once. This is the default loop type.
group: Looping Types
id: tween.loop.once
name: tween.loop.once
related:
- tween
syntax: tween.loop.once
#---------------------------------
#---------------------------------
# tween.loop.forever
#---------------------------------
- category: const
description: >
Plays the tween over and over again, restarting it each time.
group: Looping Types
id: tween.loop.forever
name: tween.loop.forever
related:
- tween
syntax: tween.loop.forever
#---------------------------------
#---------------------------------
# tween.loop.pingpong
#---------------------------------
- category: const
description: >
Plays the tween backwards after it finishes, and then continues to repeat it back and forth.
group: Looping Types
id: tween.loop.pingpong
name: tween.loop.pingpong
related:
- tween
syntax: tween.loop.pingpong
#---------------------------------
#---------------------------------
# tween.easing.linear
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.linear
name: tween.easing.linear
related:
- tween
syntax: tween.easing.linear
#---------------------------------
#---------------------------------
# tween.easing.quadIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quadIn
name: tween.easing.quadIn
related:
- tween
syntax: tween.easing.quadIn
#---------------------------------
#---------------------------------
# tween.easing.quadOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quadOut
name: tween.easing.quadOut
related:
- tween
syntax: tween.easing.quadOut
#---------------------------------
#---------------------------------
# tween.easing.quadInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quadInOut
name: tween.easing.quadInOut
related:
- tween
syntax: tween.easing.quadInOut
#---------------------------------
#---------------------------------
# tween.easing.quadOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quadOutIn
name: tween.easing.quadOutIn
related:
- tween
syntax: tween.easing.quadOutIn
#---------------------------------
#---------------------------------
# tween.easing.cubicIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.cubicIn
name: tween.easing.cubicIn
related:
- tween
syntax: tween.easing.cubicIn
#---------------------------------
#---------------------------------
# tween.easing.cubicOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.cubicOut
name: tween.easing.cubicOut
related:
- tween
syntax: tween.easing.cubicOut
#---------------------------------
#---------------------------------
# tween.easing.cubicInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.cubicInOut
name: tween.easing.cubicInOut
related:
- tween
syntax: tween.easing.cubicInOut
#---------------------------------
#---------------------------------
# tween.easing.cubicOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.cubicOutIn
name: tween.easing.cubicOutIn
related:
- tween
syntax: tween.easing.cubicOutIn
#---------------------------------
#---------------------------------
# tween.easing.quartIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quartIn
name: tween.easing.quartIn
related:
- tween
syntax: tween.easing.quartIn
#---------------------------------
#---------------------------------
# tween.easing.quartOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quartOut
name: tween.easing.quartOut
related:
- tween
syntax: tween.easing.quartOut
#---------------------------------
#---------------------------------
# tween.easing.quartInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quartInOut
name: tween.easing.quartInOut
related:
- tween
syntax: tween.easing.quartInOut
#---------------------------------
#---------------------------------
# tween.easing.quartOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quartOutIn
name: tween.easing.quartOutIn
related:
- tween
syntax: tween.easing.quartOutIn
#---------------------------------
#---------------------------------
# tween.easing.quintIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quintIn
name: tween.easing.quintIn
related:
- tween
syntax: tween.easing.quintIn
#---------------------------------
#---------------------------------
# tween.easing.quintOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quintOut
name: tween.easing.quintOut
related:
- tween
syntax: tween.easing.quintOut
#---------------------------------
#---------------------------------
# tween.easing.quintInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quintInOut
name: tween.easing.quintInOut
related:
- tween
syntax: tween.easing.quintInOut
#---------------------------------
#---------------------------------
# tween.easing.quintOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.quintOutIn
name: tween.easing.quintOutIn
related:
- tween
syntax: tween.easing.quintOutIn
#---------------------------------
#---------------------------------
# tween.easing.expoIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.expoIn
name: tween.easing.expoIn
related:
- tween
syntax: tween.easing.expoIn
#---------------------------------
#---------------------------------
# tween.easing.expoOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.expoOut
name: tween.easing.expoOut
related:
- tween
syntax: tween.easing.expoOut
#---------------------------------
#---------------------------------
# tween.easing.expoInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.expoInOut
name: tween.easing.expoInOut
related:
- tween
syntax: tween.easing.expoInOut
#---------------------------------
#---------------------------------
# tween.easing.expoOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.expoOutIn
name: tween.easing.expoOutIn
related:
- tween
syntax: tween.easing.expoOutIn
#---------------------------------
#---------------------------------
# tween.easing.sineIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.sineIn
name: tween.easing.sineIn
related:
- tween
syntax: tween.easing.sineIn
#---------------------------------
#---------------------------------
# tween.easing.sineOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.sineOut
name: tween.easing.sineOut
related:
- tween
syntax: tween.easing.sineOut
#---------------------------------
#---------------------------------
# tween.easing.sineInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.sineInOut
name: tween.easing.sineInOut
related:
- tween
syntax: tween.easing.sineInOut
#---------------------------------
#---------------------------------
# tween.easing.sineOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.sineOutIn
name: tween.easing.sineOutIn
related:
- tween
syntax: tween.easing.sineOutIn
#---------------------------------
#---------------------------------
# tween.easing.backIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.backIn
name: tween.easing.backIn
related:
- tween
syntax: tween.easing.backIn
#---------------------------------
#---------------------------------
# tween.easing.backOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.backOut
name: tween.easing.backOut
related:
- tween
syntax: tween.easing.backOut
#---------------------------------
#---------------------------------
# tween.easing.backInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.backInOut
name: tween.easing.backInOut
related:
- tween
syntax: tween.easing.backInOut
#---------------------------------
#---------------------------------
# tween.easing.backOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.backOutIn
name: tween.easing.backOutIn
related:
- tween
syntax: tween.easing.backOutIn
#---------------------------------
#---------------------------------
# tween.easing.bounceIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.bounceIn
name: tween.easing.bounceIn
related:
- tween
syntax: tween.easing.bounceIn
#---------------------------------
#---------------------------------
# tween.easing.bounceOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.bounceOut
name: tween.easing.bounceOut
related:
- tween
syntax: tween.easing.bounceOut
#---------------------------------
#---------------------------------
# tween.easing.bounceInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.bounceInOut
name: tween.easing.bounceInOut
related:
- tween
syntax: tween.easing.bounceInOut
#---------------------------------
#---------------------------------
# tween.easing.bounceOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.bounceOutIn
name: tween.easing.bounceOutIn
related:
- tween
syntax: tween.easing.bounceOutIn
#---------------------------------
#---------------------------------
# tween.easing.elasticIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.elasticIn
name: tween.easing.elasticIn
related:
- tween
syntax: tween.easing.elasticIn
#---------------------------------
#---------------------------------
# tween.easing.elasticOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.elasticOut
name: tween.easing.elasticOut
related:
- tween
syntax: tween.easing.elasticOut
#---------------------------------
#---------------------------------
# tween.easing.elasticInOut
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.elasticInOut
name: tween.easing.elasticInOut
related:
- tween
syntax: tween.easing.elasticInOut
#---------------------------------
#---------------------------------
# tween.easing.elasticOutIn
#---------------------------------
- category: const
group: Easing Types
id: tween.easing.elasticOutIn
name: tween.easing.elasticOutIn
related:
- tween
syntax: tween.easing.elasticOutIn
#---------------------------------