-
Notifications
You must be signed in to change notification settings - Fork 6
/
sine.go
44 lines (35 loc) · 1.22 KB
/
sine.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
package easing
// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2024 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
import (
"math"
)
// ////////////////////////////////////////////////////////////////////////////////// //
// SineIn accelerating from zero velocity
// https://easings.net/#easeInSine
func SineIn(t, b, c, d float64) float64 {
if t > d {
return c
}
return -c*math.Cos(t/d*math.Phi) + c + b
}
// SineOut decelerating to zero velocity
// https://easings.net/#easeOutSine
func SineOut(t, b, c, d float64) float64 {
if t > d {
return c
}
return c*math.Sin(t/d*math.Phi) + b
}
// SineInOut acceleration until halfway, then deceleration
// https://easings.net/#easeInOutSine
func SineInOut(t, b, c, d float64) float64 {
if t > d {
return c
}
return -c/2*(math.Cos(math.Pi*t/d)-1) + b
}