-
Notifications
You must be signed in to change notification settings - Fork 0
/
newInOutCircular.go
54 lines (49 loc) · 1.76 KB
/
newInOutCircular.go
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
package factoryEasingTween
import (
"github.com/helmutkemper/iotmaker.webassembly/platform/easingTween"
"time"
)
// NewInOutCircular
//
// English: Ease tween in out circular
// duration: animation duration
// startValue: initial value
// endValue: final value
// onStepFunc: on step function
// loop: number of loops or -1 for infinite loops
// arguments: array of arguments passed for functions onStart, onEnd, onInvert and onStep.
// Example: ..., [arguments] x, y) will be onStartFunc(value, args...) { args[0]: x; args[1]: y}
//
// Português: Facilitador de interpolação in out circular
// duration: duração da animação
// startValue: valor inicial
// endValue: valor final
// onStepFunc: função para o evento passo
// loop: número de interações ou -1 para um número infinito de interações
// arguments: array de argumentos passados para as funções onStart, onEnd, onInvert e onStep.
// Exemplo: ..., [argumentos] x, y) será onStartFunc(value, args...) { args[0]: x; args[1]: y}
func NewInOutCircular(
duration time.Duration,
startValue,
endValue float64,
onStepFunc interface{},
loop int,
arguments ...interface{},
) *easingTween.Tween {
var function func(value, percentToComplete float64, arguments interface{})
switch converted := onStepFunc.(type) {
case func(value, percentToComplete float64, arguments interface{}):
function = converted
case func() (f func(value, percentToComplete float64, arguments interface{})):
function = converted()
}
t := &easingTween.Tween{}
t.SetDuration(duration).
SetValues(startValue, endValue).
SetOnStepFunc(function).
SetLoops(loop).
SetArgumentsFunc(arguments).
SetTweenFunc(easingTween.KEaseInOutCircular).
Start()
return t
}