This repository has been archived by the owner on Jan 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test2.nim
84 lines (75 loc) · 2.57 KB
/
test2.nim
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
# --- Test 2. Work with default nodes. --- #
import
nodesnim,
unittest
suite "Work with default nodes.":
test "Setup window":
Window("default nodes test")
test "Setup scene":
build:
- Scene main
addMainScene(main)
test "Canvas test":
build:
- Canvas canvas:
call:
resize(256, 256)
fill(Color("#ffaacc"))
point(5, 5, Color("#64ffff"))
line(8, 16, 128, 64, Color("#ffff64ff"))
circle(0, 240, 32, Color("#aaff6456"))
line(200, -150, 0, 256, Color("#0e1317ff"))
bezier(0, 0, 256, 0, 256, 256, Color("#227"))
cubic_bezier(0, 0, 256, 0, 0, 256, 256, 256, Color("#272"))
move(74.4, 89.4)
text("hello!,\nworld!", 64, 64, Vector2(1, 1))
saveAs("assets/canvas.png") # save result in file.
getSceneByName("main").addChild(canvas)
test "AudioStreamPlayer test":
build:
- AudioStreamPlayer audio1:
stream: loadAudio("assets/vug_ost_Weh.ogg")
call setVolume(64) # 64/100
call play()
getSceneByName("main").addChild(audio1)
test "Duplicate nodes":
build:
- Node node(name: "MyOwnNode")
var node1 = node.duplicate()
assert node.name == node1.name
test "AnimationPlayer node":
build:
- ColorRect rect:
color: Color(0, 0, 0)
call resize(100, 100)
- ColorRect rect1:
color: Color(0, 0, 0)
call resize(100, 100)
call move(0, 150)
- ColorRect rect2:
color: Color(0.5, 0.8, 0.5)
call resize(100, 100)
call move(0, 300)
- AnimationPlayer animation:
mode: ANIMATION_NORMAL # Default animation mode.
call:
addState(rect.color.r.addr, @[(tick: 0, value: 0.0), (tick: 200, value: 1.0)])
addState(rect.position.x.addr, @[(tick: 0, value: 0.0), (tick: 100, value: 250.0)])
setDuration(200)
play()
- AnimationPlayer animation1:
mode: ANIMATION_EASE
call:
addState(rect1.position.x.addr, @[(tick: 0, value: 0.0), (tick: 100, value: 250.0)])
setDuration(200)
play()
- AnimationPlayer animation2:
mode: ANIMATION_BEZIER
bezier: (0.8, 0.9)
call:
addState(rect2.position.x.addr, @[(tick: 0, value: 0.0), (tick: 100, value: 250.0)])
setDuration(200)
play()
getSceneByName("main").addChildren(rect, rect1, rect2, animation, animation1, animation2)
test "Launch window":
runApp()