forked from gucio321/giu-animations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
73 lines (66 loc) · 1.82 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"image/color"
"time"
"golang.org/x/image/colornames"
"github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
animations "github.com/gucio321/giu-animations"
)
var easingAlg = animations.EasingAlgNone
func loop() {
a := int32(easingAlg)
animations.Animator(
animations.Transition(
func(starter func()) {
giu.Window("window1").Layout(
giu.Label("I'm a window 1"),
animations.Animator(
animations.ColorFlow(
giu.Button("start transition").OnClick(func() {
starter()
}),
func() color.RGBA {
return colornames.Red
},
func() color.RGBA {
return colornames.Blue
},
giu.StyleColorButtonHovered,
giu.StyleColorButton,
),
).Duration(time.Second).FPS(60),
animations.Animator(
animations.Move(func(starter animations.StarterFunc) giu.Widget {
return giu.Child().Layout(
giu.Row(
giu.Label("Set easing alg:"),
giu.SliderInt(&a, 0, int32(animations.EasingAlgMax-1)).Size(100).OnChange(func() {
easingAlg = animations.EasingAlgorithmType(a)
}),
),
giu.Button("move me!").OnClick(func() {
starter(animations.PlayForward)
}),
).Size(200, 80)
}, imgui.Vec2{X: 20, Y: 100}).
StartPos(imgui.Vec2{X: 5, Y: 80}).
Bezier(imgui.Vec2{X: 20, Y: 20}, imgui.Vec2{X: 90}),
).Duration(time.Second*3).FPS(120).EasingAlgorithm(easingAlg).Trigger(animations.TriggerOnTrue, giu.IsItemHovered),
)
},
func(starter func()) {
giu.Window("window2").Layout(
giu.Label("I'm a window 1"),
giu.Button("start transition").OnClick(func() {
starter()
}),
)
},
),
).Build()
}
func main() {
wnd := giu.NewMasterWindow("Animations presentation [example]", 640, 480, 0)
wnd.Run(loop)
}