mt-lang 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/index.html +4 -3
- data/lib/milk_tea/base.rb +1 -1
- data/std/asset_pack.mt +267 -0
- data/std/async/libuv_runtime.mt +539 -0
- data/std/async/mailbox.mt +191 -0
- data/std/async/runtime.mt +87 -0
- data/std/async.mt +87 -0
- data/std/base64.mt +185 -0
- data/std/behavior_tree.mt +396 -0
- data/std/binary.mt +314 -0
- data/std/binary_heap.mt +157 -0
- data/std/bitset.mt +239 -0
- data/std/box2d.mt +535 -0
- data/std/bytes.mt +46 -0
- data/std/c/box2d.mt +1254 -0
- data/std/c/cgltf.mt +647 -0
- data/std/c/cjson.mt +106 -0
- data/std/c/crypto.mt +11 -0
- data/std/c/crypto_support.h +51 -0
- data/std/c/ctype.mt +19 -0
- data/std/c/ctype_bindgen.h +29 -0
- data/std/c/curl.mt +1223 -0
- data/std/c/enet.mt +473 -0
- data/std/c/errno.mt +41 -0
- data/std/c/errno_bindgen.h +53 -0
- data/std/c/flecs.mt +2945 -0
- data/std/c/fs.linux.mt +43 -0
- data/std/c/fs.windows.mt +43 -0
- data/std/c/fs_support.h +954 -0
- data/std/c/gl.mt +2065 -0
- data/std/c/gl_registry_helpers.h +10748 -0
- data/std/c/glfw.mt +499 -0
- data/std/c/libc.mt +167 -0
- data/std/c/libuv.mt +1491 -0
- data/std/c/math.mt +22 -0
- data/std/c/math_bindgen.h +31 -0
- data/std/c/miniaudio.mt +3420 -0
- data/std/c/pcre2.mt +735 -0
- data/std/c/process.mt +58 -0
- data/std/c/process_support.h +1147 -0
- data/std/c/raygui.mt +1602 -0
- data/std/c/raylib.mt +1245 -0
- data/std/c/raymath.mt +163 -0
- data/std/c/rlgl.mt +434 -0
- data/std/c/rpng.mt +60 -0
- data/std/c/rres.mt +187 -0
- data/std/c/sdl3.mt +4132 -0
- data/std/c/sqlite3.mt +951 -0
- data/std/c/stb_image.mt +52 -0
- data/std/c/stb_image_resize2.mt +128 -0
- data/std/c/stb_image_write.mt +19 -0
- data/std/c/stb_rect_pack.mt +38 -0
- data/std/c/stb_truetype.mt +175 -0
- data/std/c/stb_vorbis.mt +31 -0
- data/std/c/stdio.mt +90 -0
- data/std/c/steamworks.h +5769 -0
- data/std/c/steamworks.mt +4771 -0
- data/std/c/string.mt +16 -0
- data/std/c/string_bindgen.h +36 -0
- data/std/c/sync.mt +33 -0
- data/std/c/sync_support.h +219 -0
- data/std/c/terminal.mt +24 -0
- data/std/c/terminal_support.h +408 -0
- data/std/c/time.mt +26 -0
- data/std/c/tls.mt +24 -0
- data/std/c/tls_support.h +626 -0
- data/std/c/tracy.mt +53 -0
- data/std/c/zlib.mt +20 -0
- data/std/c/zlib_support.h +239 -0
- data/std/c/zstd.mt +231 -0
- data/std/cell.mt +60 -0
- data/std/cgltf.mt +115 -0
- data/std/cjson.mt +90 -0
- data/std/cli.mt +768 -0
- data/std/cookie.mt +198 -0
- data/std/counter.mt +160 -0
- data/std/crypto.mt +74 -0
- data/std/cstring.mt +13 -0
- data/std/ctype.mt +52 -0
- data/std/curl/runtime.mt +261 -0
- data/std/curl.mt +38 -0
- data/std/deque.mt +348 -0
- data/std/encoding.mt +93 -0
- data/std/enet.mt +133 -0
- data/std/env.mt +41 -0
- data/std/errno.mt +47 -0
- data/std/flecs.mt +978 -0
- data/std/fmt.mt +271 -0
- data/std/fs.linux.mt +696 -0
- data/std/fs.windows.mt +711 -0
- data/std/fsm.mt +267 -0
- data/std/gl.mt +2062 -0
- data/std/glfw.mt +471 -0
- data/std/goap.mt +342 -0
- data/std/graph.mt +521 -0
- data/std/gzip.mt +77 -0
- data/std/hash.mt +429 -0
- data/std/http/server.mt +810 -0
- data/std/http.mt +1227 -0
- data/std/intern.mt +53 -0
- data/std/jobs.mt +288 -0
- data/std/json.mt +627 -0
- data/std/libc.mt +34 -0
- data/std/libuv.mt +554 -0
- data/std/linear_algebra.mt +243 -0
- data/std/linked_map.mt +372 -0
- data/std/linked_map_view.mt +49 -0
- data/std/linked_set.mt +117 -0
- data/std/log.mt +69 -0
- data/std/map.mt +418 -0
- data/std/math.mt +24 -0
- data/std/mem/arena.mt +137 -0
- data/std/mem/endian.mt +51 -0
- data/std/mem/heap.mt +298 -0
- data/std/mem/pool.mt +164 -0
- data/std/mem/stack.mt +47 -0
- data/std/mem/tracking.mt +119 -0
- data/std/miniaudio.mt +1299 -0
- data/std/multiset.mt +191 -0
- data/std/net/channel.mt +727 -0
- data/std/net/clock.mt +237 -0
- data/std/net/discovery.mt +277 -0
- data/std/net/lobby.mt +813 -0
- data/std/net/manager.mt +539 -0
- data/std/net/mux.mt +839 -0
- data/std/net/nat.mt +122 -0
- data/std/net/packet.mt +219 -0
- data/std/net/punch.mt +162 -0
- data/std/net/rpc.mt +119 -0
- data/std/net/session.mt +1157 -0
- data/std/net/stun.mt +252 -0
- data/std/net/sync.mt +183 -0
- data/std/net/turn.mt +459 -0
- data/std/net.mt +2944 -0
- data/std/oauth2.mt +408 -0
- data/std/option.mt +51 -0
- data/std/ordered_map.mt +497 -0
- data/std/ordered_set.mt +348 -0
- data/std/path.mt +368 -0
- data/std/pcre2/runtime.mt +35 -0
- data/std/pcre2.mt +78 -0
- data/std/priority_queue.mt +55 -0
- data/std/process.mt +837 -0
- data/std/queue.mt +55 -0
- data/std/random.mt +146 -0
- data/std/raygui.mt +99 -0
- data/std/raylib/debug_console.mt +71 -0
- data/std/raylib/easing.mt +388 -0
- data/std/raylib/packed_assets.mt +255 -0
- data/std/raylib/runtime.mt +30 -0
- data/std/raylib/tracy_gpu.mt +37 -0
- data/std/raylib.mt +1510 -0
- data/std/raymath.mt +153 -0
- data/std/result.mt +89 -0
- data/std/rlgl.mt +268 -0
- data/std/rpng.mt +46 -0
- data/std/rres.mt +36 -0
- data/std/sdl3/runtime.mt +54 -0
- data/std/sdl3.mt +1731 -0
- data/std/serialize.mt +68 -0
- data/std/set.mt +124 -0
- data/std/spatial.mt +176 -0
- data/std/sqlite3.mt +151 -0
- data/std/stack.mt +55 -0
- data/std/stb_image.mt +47 -0
- data/std/stb_image_resize2.mt +41 -0
- data/std/stb_image_write.mt +17 -0
- data/std/stb_rect_pack.mt +15 -0
- data/std/stb_truetype.mt +77 -0
- data/std/stb_vorbis.mt +16 -0
- data/std/stdio.mt +88 -0
- data/std/steamworks.mt +1542 -0
- data/std/str.mt +293 -0
- data/std/string.mt +234 -0
- data/std/sync.mt +194 -0
- data/std/tar.mt +704 -0
- data/std/terminal.mt +1002 -0
- data/std/testing.mt +266 -0
- data/std/thread.mt +120 -0
- data/std/time.mt +105 -0
- data/std/tls.mt +616 -0
- data/std/toml.mt +1310 -0
- data/std/tracy.mt +42 -0
- data/std/uri.mt +118 -0
- data/std/url.mt +372 -0
- data/std/vec.mt +433 -0
- data/std/zstd.mt +94 -0
- metadata +187 -2
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import std.math as math
|
|
2
|
+
|
|
3
|
+
public const PI: float = 3.14159265358979323846
|
|
4
|
+
|
|
5
|
+
public const EASE_LINEAR_NONE: int = 0
|
|
6
|
+
public const EASE_LINEAR_IN: int = 1
|
|
7
|
+
public const EASE_LINEAR_OUT: int = 2
|
|
8
|
+
public const EASE_LINEAR_IN_OUT: int = 3
|
|
9
|
+
public const EASE_SINE_IN: int = 4
|
|
10
|
+
public const EASE_SINE_OUT: int = 5
|
|
11
|
+
public const EASE_SINE_IN_OUT: int = 6
|
|
12
|
+
public const EASE_CIRC_IN: int = 7
|
|
13
|
+
public const EASE_CIRC_OUT: int = 8
|
|
14
|
+
public const EASE_CIRC_IN_OUT: int = 9
|
|
15
|
+
public const EASE_CUBIC_IN: int = 10
|
|
16
|
+
public const EASE_CUBIC_OUT: int = 11
|
|
17
|
+
public const EASE_CUBIC_IN_OUT: int = 12
|
|
18
|
+
public const EASE_QUAD_IN: int = 13
|
|
19
|
+
public const EASE_QUAD_OUT: int = 14
|
|
20
|
+
public const EASE_QUAD_IN_OUT: int = 15
|
|
21
|
+
public const EASE_EXPO_IN: int = 16
|
|
22
|
+
public const EASE_EXPO_OUT: int = 17
|
|
23
|
+
public const EASE_EXPO_IN_OUT: int = 18
|
|
24
|
+
public const EASE_BACK_IN: int = 19
|
|
25
|
+
public const EASE_BACK_OUT: int = 20
|
|
26
|
+
public const EASE_BACK_IN_OUT: int = 21
|
|
27
|
+
public const EASE_BOUNCE_OUT: int = 22
|
|
28
|
+
public const EASE_BOUNCE_IN: int = 23
|
|
29
|
+
public const EASE_BOUNCE_IN_OUT: int = 24
|
|
30
|
+
public const EASE_ELASTIC_IN: int = 25
|
|
31
|
+
public const EASE_ELASTIC_OUT: int = 26
|
|
32
|
+
public const EASE_ELASTIC_IN_OUT: int = 27
|
|
33
|
+
public const EASING_NONE: int = 28
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function sinf(value: float) -> float:
|
|
37
|
+
return float<-math.sin(double<-value)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function cosf(value: float) -> float:
|
|
41
|
+
return float<-math.cos(double<-value)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function sqrtf(value: float) -> float:
|
|
45
|
+
return float<-math.sqrt(double<-value)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
function powf(base: float, exponent: float) -> float:
|
|
49
|
+
return float<-math.pow(double<-base, double<-exponent)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
public function linear_none(t: float, b: float, c: float, d: float) -> float:
|
|
53
|
+
return (c * t / d) + b
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public function linear_in(t: float, b: float, c: float, d: float) -> float:
|
|
57
|
+
return linear_none(t, b, c, d)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
public function linear_out(t: float, b: float, c: float, d: float) -> float:
|
|
61
|
+
return linear_none(t, b, c, d)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
public function linear_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
65
|
+
return linear_none(t, b, c, d)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
public function sine_in(t: float, b: float, c: float, d: float) -> float:
|
|
69
|
+
return (-c * cosf((t / d) * (PI / 2.0)) + c + b)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
public function sine_out(t: float, b: float, c: float, d: float) -> float:
|
|
73
|
+
return (c * sinf((t / d) * (PI / 2.0)) + b)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
public function sine_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
77
|
+
return (-c / 2.0 * (cosf(PI * t / d) - 1.0) + b)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
public function circ_in(t: float, b: float, c: float, d: float) -> float:
|
|
81
|
+
let current = t / d
|
|
82
|
+
return (-c * (sqrtf(1.0 - current * current) - 1.0) + b)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
public function circ_out(t: float, b: float, c: float, d: float) -> float:
|
|
86
|
+
let current = (t / d) - 1.0
|
|
87
|
+
return (c * sqrtf(1.0 - current * current) + b)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
public function circ_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
91
|
+
var current = t / (d / 2.0)
|
|
92
|
+
if current < 1.0:
|
|
93
|
+
return (-c / 2.0 * (sqrtf(1.0 - current * current) - 1.0) + b)
|
|
94
|
+
|
|
95
|
+
current -= 2.0
|
|
96
|
+
return (c / 2.0 * (sqrtf(1.0 - current * current) + 1.0) + b)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
public function cubic_in(t: float, b: float, c: float, d: float) -> float:
|
|
100
|
+
let current = t / d
|
|
101
|
+
return (c * current * current * current + b)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
public function cubic_out(t: float, b: float, c: float, d: float) -> float:
|
|
105
|
+
let current = (t / d) - 1.0
|
|
106
|
+
return (c * (current * current * current + 1.0) + b)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
public function cubic_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
110
|
+
var current = t / (d / 2.0)
|
|
111
|
+
if current < 1.0:
|
|
112
|
+
return (c / 2.0 * current * current * current + b)
|
|
113
|
+
|
|
114
|
+
current -= 2.0
|
|
115
|
+
return (c / 2.0 * (current * current * current + 2.0) + b)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
public function quad_in(t: float, b: float, c: float, d: float) -> float:
|
|
119
|
+
let current = t / d
|
|
120
|
+
return (c * current * current + b)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
public function quad_out(t: float, b: float, c: float, d: float) -> float:
|
|
124
|
+
let current = t / d
|
|
125
|
+
return (-c * current * (current - 2.0) + b)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
public function quad_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
129
|
+
let current = t / (d / 2.0)
|
|
130
|
+
if current < 1.0:
|
|
131
|
+
return (c / 2.0 * current * current + b)
|
|
132
|
+
|
|
133
|
+
return (-c / 2.0 * (((current - 1.0) * (current - 3.0)) - 1.0) + b)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
public function expo_in(t: float, b: float, c: float, d: float) -> float:
|
|
137
|
+
if t == 0.0:
|
|
138
|
+
return b
|
|
139
|
+
|
|
140
|
+
return (c * powf(2.0, 10.0 * ((t / d) - 1.0)) + b)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
public function expo_out(t: float, b: float, c: float, d: float) -> float:
|
|
144
|
+
if t == d:
|
|
145
|
+
return b + c
|
|
146
|
+
|
|
147
|
+
return (c * (-powf(2.0, (-10.0 * t) / d) + 1.0) + b)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
public function expo_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
151
|
+
if t == 0.0:
|
|
152
|
+
return b
|
|
153
|
+
if t == d:
|
|
154
|
+
return b + c
|
|
155
|
+
|
|
156
|
+
let current = t / (d / 2.0)
|
|
157
|
+
if current < 1.0:
|
|
158
|
+
return (c / 2.0 * powf(2.0, 10.0 * (current - 1.0)) + b)
|
|
159
|
+
|
|
160
|
+
return (c / 2.0 * (-powf(2.0, -10.0 * (current - 1.0)) + 2.0) + b)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
public function back_in(t: float, b: float, c: float, d: float) -> float:
|
|
164
|
+
let s = 1.70158
|
|
165
|
+
let current = t / d
|
|
166
|
+
return (c * current * current * (((s + 1.0) * current) - s) + b)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
public function back_out(t: float, b: float, c: float, d: float) -> float:
|
|
170
|
+
let s = 1.70158
|
|
171
|
+
let current = (t / d) - 1.0
|
|
172
|
+
return (c * (current * current * (((s + 1.0) * current) + s) + 1.0) + b)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
public function back_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
176
|
+
var s: float = 1.70158
|
|
177
|
+
var current = t / (d / 2.0)
|
|
178
|
+
if current < 1.0:
|
|
179
|
+
s *= 1.525
|
|
180
|
+
return (c / 2.0 * (current * current * (((s + 1.0) * current) - s)) + b)
|
|
181
|
+
|
|
182
|
+
current -= 2.0
|
|
183
|
+
s *= 1.525
|
|
184
|
+
return (c / 2.0 * (current * current * (((s + 1.0) * current) + s) + 2.0) + b)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
public function bounce_out(t: float, b: float, c: float, d: float) -> float:
|
|
188
|
+
let current = t / d
|
|
189
|
+
if current < (1.0 / 2.75):
|
|
190
|
+
return (c * (7.5625 * current * current) + b)
|
|
191
|
+
else if current < (2.0 / 2.75):
|
|
192
|
+
let post_fix = current - (1.5 / 2.75)
|
|
193
|
+
return (c * (7.5625 * post_fix * post_fix + 0.75) + b)
|
|
194
|
+
else if current < (2.5 / 2.75):
|
|
195
|
+
let post_fix = current - (2.25 / 2.75)
|
|
196
|
+
return (c * (7.5625 * post_fix * post_fix + 0.9375) + b)
|
|
197
|
+
|
|
198
|
+
let post_fix = current - (2.625 / 2.75)
|
|
199
|
+
return (c * (7.5625 * post_fix * post_fix + 0.984375) + b)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
public function bounce_in(t: float, b: float, c: float, d: float) -> float:
|
|
203
|
+
return (c - bounce_out(d - t, 0.0, c, d) + b)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
public function bounce_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
207
|
+
if t < d / 2.0:
|
|
208
|
+
return (bounce_in(t * 2.0, 0.0, c, d) * 0.5 + b)
|
|
209
|
+
|
|
210
|
+
return (bounce_out(t * 2.0 - d, 0.0, c, d) * 0.5 + c * 0.5 + b)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
public function elastic_in(t: float, b: float, c: float, d: float) -> float:
|
|
214
|
+
if t == 0.0:
|
|
215
|
+
return b
|
|
216
|
+
|
|
217
|
+
var current = t / d
|
|
218
|
+
if current == 1.0:
|
|
219
|
+
return b + c
|
|
220
|
+
|
|
221
|
+
let p = d * 0.3
|
|
222
|
+
let a = c
|
|
223
|
+
let s = p / 4.0
|
|
224
|
+
current -= 1.0
|
|
225
|
+
let post_fix = a * powf(2.0, 10.0 * current)
|
|
226
|
+
return (-(post_fix * sinf(((current * d) - s) * ((2.0 * PI) / p))) + b)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
public function elastic_out(t: float, b: float, c: float, d: float) -> float:
|
|
230
|
+
if t == 0.0:
|
|
231
|
+
return b
|
|
232
|
+
|
|
233
|
+
let current = t / d
|
|
234
|
+
if current == 1.0:
|
|
235
|
+
return b + c
|
|
236
|
+
|
|
237
|
+
let p = d * 0.3
|
|
238
|
+
let a = c
|
|
239
|
+
let s = p / 4.0
|
|
240
|
+
return (a * powf(2.0, -10.0 * current) * sinf(((current * d) - s) * ((2.0 * PI) / p)) + c + b)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
public function elastic_in_out(t: float, b: float, c: float, d: float) -> float:
|
|
244
|
+
if t == 0.0:
|
|
245
|
+
return b
|
|
246
|
+
|
|
247
|
+
var current = t / (d / 2.0)
|
|
248
|
+
if current == 2.0:
|
|
249
|
+
return b + c
|
|
250
|
+
|
|
251
|
+
let p = d * (0.3 * 1.5)
|
|
252
|
+
let a = c
|
|
253
|
+
let s = p / 4.0
|
|
254
|
+
|
|
255
|
+
if current < 1.0:
|
|
256
|
+
current -= 1.0
|
|
257
|
+
let post_fix = a * powf(2.0, 10.0 * current)
|
|
258
|
+
return (-0.5 * (post_fix * sinf(((current * d) - s) * ((2.0 * PI) / p))) + b)
|
|
259
|
+
|
|
260
|
+
current -= 1.0
|
|
261
|
+
let post_fix = a * powf(2.0, -10.0 * current)
|
|
262
|
+
return (post_fix * sinf(((current * d) - s) * ((2.0 * PI) / p)) * 0.5 + c + b)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
public function no_ease(_t: float, b: float, _c: float, _d: float) -> float:
|
|
266
|
+
return b
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
public function by_kind(kind: int, t: float, b: float, c: float, d: float) -> float:
|
|
270
|
+
if kind == EASE_LINEAR_NONE:
|
|
271
|
+
return linear_none(t, b, c, d)
|
|
272
|
+
else if kind == EASE_LINEAR_IN:
|
|
273
|
+
return linear_in(t, b, c, d)
|
|
274
|
+
else if kind == EASE_LINEAR_OUT:
|
|
275
|
+
return linear_out(t, b, c, d)
|
|
276
|
+
else if kind == EASE_LINEAR_IN_OUT:
|
|
277
|
+
return linear_in_out(t, b, c, d)
|
|
278
|
+
else if kind == EASE_SINE_IN:
|
|
279
|
+
return sine_in(t, b, c, d)
|
|
280
|
+
else if kind == EASE_SINE_OUT:
|
|
281
|
+
return sine_out(t, b, c, d)
|
|
282
|
+
else if kind == EASE_SINE_IN_OUT:
|
|
283
|
+
return sine_in_out(t, b, c, d)
|
|
284
|
+
else if kind == EASE_CIRC_IN:
|
|
285
|
+
return circ_in(t, b, c, d)
|
|
286
|
+
else if kind == EASE_CIRC_OUT:
|
|
287
|
+
return circ_out(t, b, c, d)
|
|
288
|
+
else if kind == EASE_CIRC_IN_OUT:
|
|
289
|
+
return circ_in_out(t, b, c, d)
|
|
290
|
+
else if kind == EASE_CUBIC_IN:
|
|
291
|
+
return cubic_in(t, b, c, d)
|
|
292
|
+
else if kind == EASE_CUBIC_OUT:
|
|
293
|
+
return cubic_out(t, b, c, d)
|
|
294
|
+
else if kind == EASE_CUBIC_IN_OUT:
|
|
295
|
+
return cubic_in_out(t, b, c, d)
|
|
296
|
+
else if kind == EASE_QUAD_IN:
|
|
297
|
+
return quad_in(t, b, c, d)
|
|
298
|
+
else if kind == EASE_QUAD_OUT:
|
|
299
|
+
return quad_out(t, b, c, d)
|
|
300
|
+
else if kind == EASE_QUAD_IN_OUT:
|
|
301
|
+
return quad_in_out(t, b, c, d)
|
|
302
|
+
else if kind == EASE_EXPO_IN:
|
|
303
|
+
return expo_in(t, b, c, d)
|
|
304
|
+
else if kind == EASE_EXPO_OUT:
|
|
305
|
+
return expo_out(t, b, c, d)
|
|
306
|
+
else if kind == EASE_EXPO_IN_OUT:
|
|
307
|
+
return expo_in_out(t, b, c, d)
|
|
308
|
+
else if kind == EASE_BACK_IN:
|
|
309
|
+
return back_in(t, b, c, d)
|
|
310
|
+
else if kind == EASE_BACK_OUT:
|
|
311
|
+
return back_out(t, b, c, d)
|
|
312
|
+
else if kind == EASE_BACK_IN_OUT:
|
|
313
|
+
return back_in_out(t, b, c, d)
|
|
314
|
+
else if kind == EASE_BOUNCE_OUT:
|
|
315
|
+
return bounce_out(t, b, c, d)
|
|
316
|
+
else if kind == EASE_BOUNCE_IN:
|
|
317
|
+
return bounce_in(t, b, c, d)
|
|
318
|
+
else if kind == EASE_BOUNCE_IN_OUT:
|
|
319
|
+
return bounce_in_out(t, b, c, d)
|
|
320
|
+
else if kind == EASE_ELASTIC_IN:
|
|
321
|
+
return elastic_in(t, b, c, d)
|
|
322
|
+
else if kind == EASE_ELASTIC_OUT:
|
|
323
|
+
return elastic_out(t, b, c, d)
|
|
324
|
+
else if kind == EASE_ELASTIC_IN_OUT:
|
|
325
|
+
return elastic_in_out(t, b, c, d)
|
|
326
|
+
|
|
327
|
+
return no_ease(t, b, c, d)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
public function kind_name(kind: int) -> str:
|
|
331
|
+
if kind == EASE_LINEAR_NONE:
|
|
332
|
+
return "EaseLinearNone"
|
|
333
|
+
else if kind == EASE_LINEAR_IN:
|
|
334
|
+
return "EaseLinearIn"
|
|
335
|
+
else if kind == EASE_LINEAR_OUT:
|
|
336
|
+
return "EaseLinearOut"
|
|
337
|
+
else if kind == EASE_LINEAR_IN_OUT:
|
|
338
|
+
return "EaseLinearInOut"
|
|
339
|
+
else if kind == EASE_SINE_IN:
|
|
340
|
+
return "EaseSineIn"
|
|
341
|
+
else if kind == EASE_SINE_OUT:
|
|
342
|
+
return "EaseSineOut"
|
|
343
|
+
else if kind == EASE_SINE_IN_OUT:
|
|
344
|
+
return "EaseSineInOut"
|
|
345
|
+
else if kind == EASE_CIRC_IN:
|
|
346
|
+
return "EaseCircIn"
|
|
347
|
+
else if kind == EASE_CIRC_OUT:
|
|
348
|
+
return "EaseCircOut"
|
|
349
|
+
else if kind == EASE_CIRC_IN_OUT:
|
|
350
|
+
return "EaseCircInOut"
|
|
351
|
+
else if kind == EASE_CUBIC_IN:
|
|
352
|
+
return "EaseCubicIn"
|
|
353
|
+
else if kind == EASE_CUBIC_OUT:
|
|
354
|
+
return "EaseCubicOut"
|
|
355
|
+
else if kind == EASE_CUBIC_IN_OUT:
|
|
356
|
+
return "EaseCubicInOut"
|
|
357
|
+
else if kind == EASE_QUAD_IN:
|
|
358
|
+
return "EaseQuadIn"
|
|
359
|
+
else if kind == EASE_QUAD_OUT:
|
|
360
|
+
return "EaseQuadOut"
|
|
361
|
+
else if kind == EASE_QUAD_IN_OUT:
|
|
362
|
+
return "EaseQuadInOut"
|
|
363
|
+
else if kind == EASE_EXPO_IN:
|
|
364
|
+
return "EaseExpoIn"
|
|
365
|
+
else if kind == EASE_EXPO_OUT:
|
|
366
|
+
return "EaseExpoOut"
|
|
367
|
+
else if kind == EASE_EXPO_IN_OUT:
|
|
368
|
+
return "EaseExpoInOut"
|
|
369
|
+
else if kind == EASE_BACK_IN:
|
|
370
|
+
return "EaseBackIn"
|
|
371
|
+
else if kind == EASE_BACK_OUT:
|
|
372
|
+
return "EaseBackOut"
|
|
373
|
+
else if kind == EASE_BACK_IN_OUT:
|
|
374
|
+
return "EaseBackInOut"
|
|
375
|
+
else if kind == EASE_BOUNCE_OUT:
|
|
376
|
+
return "EaseBounceOut"
|
|
377
|
+
else if kind == EASE_BOUNCE_IN:
|
|
378
|
+
return "EaseBounceIn"
|
|
379
|
+
else if kind == EASE_BOUNCE_IN_OUT:
|
|
380
|
+
return "EaseBounceInOut"
|
|
381
|
+
else if kind == EASE_ELASTIC_IN:
|
|
382
|
+
return "EaseElasticIn"
|
|
383
|
+
else if kind == EASE_ELASTIC_OUT:
|
|
384
|
+
return "EaseElasticOut"
|
|
385
|
+
else if kind == EASE_ELASTIC_IN_OUT:
|
|
386
|
+
return "EaseElasticInOut"
|
|
387
|
+
|
|
388
|
+
return "None"
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import std.asset_pack as pack
|
|
2
|
+
import std.bytes as bytes
|
|
3
|
+
import std.raylib as rl
|
|
4
|
+
import std.string as string
|
|
5
|
+
import std.str as text
|
|
6
|
+
|
|
7
|
+
public enum Error: int
|
|
8
|
+
open_failed = 1
|
|
9
|
+
closed = 2
|
|
10
|
+
invalid_magic = 3
|
|
11
|
+
unsupported_version = 4
|
|
12
|
+
unsupported_flags = 5
|
|
13
|
+
range = 6
|
|
14
|
+
malformed_header = 7
|
|
15
|
+
malformed_index = 8
|
|
16
|
+
entry_not_found = 9
|
|
17
|
+
io = 10
|
|
18
|
+
missing_file_type = 101
|
|
19
|
+
invalid_image = 102
|
|
20
|
+
invalid_texture = 103
|
|
21
|
+
invalid_wave = 104
|
|
22
|
+
invalid_sound = 105
|
|
23
|
+
invalid_music = 106
|
|
24
|
+
|
|
25
|
+
public type Reader = pack.Reader
|
|
26
|
+
|
|
27
|
+
public struct PackedMusic:
|
|
28
|
+
music: rl.Music
|
|
29
|
+
backing_data: bytes.Bytes
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
extending PackedMusic:
|
|
33
|
+
public function is_valid() -> bool:
|
|
34
|
+
return rl.is_music_valid(this.music)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
public function play() -> void:
|
|
38
|
+
rl.play_music_stream(this.music)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public function is_playing() -> bool:
|
|
42
|
+
return rl.is_music_stream_playing(this.music)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
public function update() -> void:
|
|
46
|
+
rl.update_music_stream(this.music)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
public function stop() -> void:
|
|
50
|
+
rl.stop_music_stream(this.music)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
public function pause() -> void:
|
|
54
|
+
rl.pause_music_stream(this.music)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
public function resume() -> void:
|
|
58
|
+
rl.resume_music_stream(this.music)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
public function seek(position: float) -> void:
|
|
62
|
+
rl.seek_music_stream(this.music, position)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
public function set_volume(volume: float) -> void:
|
|
66
|
+
rl.set_music_volume(this.music, volume)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public function set_pitch(pitch: float) -> void:
|
|
70
|
+
rl.set_music_pitch(this.music, pitch)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
public function set_pan(pan: float) -> void:
|
|
74
|
+
rl.set_music_pan(this.music, pan)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
public function time_length() -> float:
|
|
78
|
+
return rl.get_music_time_length(this.music)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
public function time_played() -> float:
|
|
82
|
+
return rl.get_music_time_played(this.music)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
public editable function release() -> void:
|
|
86
|
+
if rl.is_music_valid(this.music):
|
|
87
|
+
rl.unload_music_stream(this.music)
|
|
88
|
+
|
|
89
|
+
this.music = zero[rl.Music]
|
|
90
|
+
this.backing_data.release()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
public function open_assets_pack_if_present() -> Result[Option[Reader], Error]:
|
|
94
|
+
let open_result = open_pack_relative_to_application("assets.mtpack")
|
|
95
|
+
match open_result:
|
|
96
|
+
Result.failure as payload:
|
|
97
|
+
if payload.error == Error.open_failed:
|
|
98
|
+
return Result[Option[Reader], Error].success(value= Option[Reader].none)
|
|
99
|
+
|
|
100
|
+
return Result[Option[Reader], Error].failure(error= payload.error)
|
|
101
|
+
Result.success as payload:
|
|
102
|
+
return Result[Option[Reader], Error].success(value= Option[Reader].some(value= payload.value))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
public function open_assets_pack() -> Result[Reader, Error]:
|
|
106
|
+
return open_pack_relative_to_application("assets.mtpack")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
public function close_reader(reader: ref[Reader]) -> void:
|
|
110
|
+
reader.close()
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
public function load_image(reader: pack.Reader, logical_path: str) -> Result[rl.Image, Error]:
|
|
114
|
+
let file_type = detect_file_type(logical_path)?
|
|
115
|
+
var data = map_pack_result(reader.read_bytes(logical_path))?
|
|
116
|
+
defer data.release()
|
|
117
|
+
|
|
118
|
+
let image = rl.load_image_from_memory(file_type, data.as_span())
|
|
119
|
+
if not rl.is_image_valid(image):
|
|
120
|
+
return Result[rl.Image, Error].failure(error= Error.invalid_image)
|
|
121
|
+
|
|
122
|
+
return Result[rl.Image, Error].success(value= image)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
public function load_texture(reader: pack.Reader, logical_path: str) -> Result[rl.Texture2D, Error]:
|
|
126
|
+
let image = load_image(reader, logical_path)?
|
|
127
|
+
defer rl.unload_image(image)
|
|
128
|
+
|
|
129
|
+
let texture = rl.load_texture_from_image(image)
|
|
130
|
+
if not rl.is_texture_valid(texture):
|
|
131
|
+
return Result[rl.Texture2D, Error].failure(error= Error.invalid_texture)
|
|
132
|
+
|
|
133
|
+
return Result[rl.Texture2D, Error].success(value= texture)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
public function load_wave(reader: pack.Reader, logical_path: str) -> Result[rl.Wave, Error]:
|
|
137
|
+
let file_type = detect_file_type(logical_path)?
|
|
138
|
+
var data = map_pack_result(reader.read_bytes(logical_path))?
|
|
139
|
+
defer data.release()
|
|
140
|
+
|
|
141
|
+
let wave = rl.load_wave_from_memory(file_type, data.as_span())
|
|
142
|
+
if not rl.is_wave_valid(wave):
|
|
143
|
+
return Result[rl.Wave, Error].failure(error= Error.invalid_wave)
|
|
144
|
+
|
|
145
|
+
return Result[rl.Wave, Error].success(value= wave)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
public function load_sound(reader: pack.Reader, logical_path: str) -> Result[rl.Sound, Error]:
|
|
149
|
+
let wave = load_wave(reader, logical_path)?
|
|
150
|
+
defer rl.unload_wave(wave)
|
|
151
|
+
|
|
152
|
+
let sound = rl.load_sound_from_wave(wave)
|
|
153
|
+
if not rl.is_sound_valid(sound):
|
|
154
|
+
return Result[rl.Sound, Error].failure(error= Error.invalid_sound)
|
|
155
|
+
|
|
156
|
+
return Result[rl.Sound, Error].success(value= sound)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
public function load_music(reader: pack.Reader, logical_path: str) -> Result[PackedMusic, Error]:
|
|
160
|
+
let file_type = detect_file_type(logical_path)?
|
|
161
|
+
var data = map_pack_result(reader.read_bytes(logical_path))?
|
|
162
|
+
let span = data.as_span()
|
|
163
|
+
let music = rl.load_music_stream_from_memory(file_type, span.data, int<-span.len)
|
|
164
|
+
if rl.is_music_valid(music):
|
|
165
|
+
return Result[PackedMusic, Error].success(value= PackedMusic(
|
|
166
|
+
music = music,
|
|
167
|
+
backing_data = data
|
|
168
|
+
))
|
|
169
|
+
|
|
170
|
+
data.release()
|
|
171
|
+
return Result[PackedMusic, Error].failure(error= Error.invalid_music)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
function open_pack_relative_to_application(pack_name: str) -> Result[pack.Reader, Error]:
|
|
175
|
+
var application_path = application_relative_path(pack_name)
|
|
176
|
+
defer application_path.release()
|
|
177
|
+
|
|
178
|
+
let application_result = pack.open(application_path.as_str())
|
|
179
|
+
match application_result:
|
|
180
|
+
Result.success as payload:
|
|
181
|
+
return Result[pack.Reader, Error].success(value= payload.value)
|
|
182
|
+
Result.failure as payload:
|
|
183
|
+
if payload.error != pack.Error.open_failed:
|
|
184
|
+
return Result[pack.Reader, Error].failure(error= from_pack_error(payload.error))
|
|
185
|
+
|
|
186
|
+
return map_pack_result(pack.open(pack_name))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
function application_relative_path(relative_path: str) -> string.String:
|
|
190
|
+
let application_dir = text.cstr_as_str(rl.get_application_directory())
|
|
191
|
+
var result = string.String.from_str(application_dir)
|
|
192
|
+
|
|
193
|
+
if application_dir.len > 0:
|
|
194
|
+
let last = application_dir.byte_at(application_dir.len - 1)
|
|
195
|
+
if last != 47 and last != 92:
|
|
196
|
+
result.append("/")
|
|
197
|
+
|
|
198
|
+
result.append(relative_path)
|
|
199
|
+
return result
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
function detect_file_type(logical_path: str) -> Result[str, Error]:
|
|
203
|
+
match file_type(logical_path):
|
|
204
|
+
Option.some as payload:
|
|
205
|
+
return Result[str, Error].success(value= payload.value)
|
|
206
|
+
Option.none:
|
|
207
|
+
return Result[str, Error].failure(error= Error.missing_file_type)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
function from_pack_error(error: pack.Error) -> Error:
|
|
211
|
+
match error:
|
|
212
|
+
pack.Error.open_failed:
|
|
213
|
+
return Error.open_failed
|
|
214
|
+
pack.Error.closed:
|
|
215
|
+
return Error.closed
|
|
216
|
+
pack.Error.invalid_magic:
|
|
217
|
+
return Error.invalid_magic
|
|
218
|
+
pack.Error.unsupported_version:
|
|
219
|
+
return Error.unsupported_version
|
|
220
|
+
pack.Error.unsupported_flags:
|
|
221
|
+
return Error.unsupported_flags
|
|
222
|
+
pack.Error.range:
|
|
223
|
+
return Error.range
|
|
224
|
+
pack.Error.malformed_header:
|
|
225
|
+
return Error.malformed_header
|
|
226
|
+
pack.Error.malformed_index:
|
|
227
|
+
return Error.malformed_index
|
|
228
|
+
pack.Error.entry_not_found:
|
|
229
|
+
return Error.entry_not_found
|
|
230
|
+
pack.Error.io:
|
|
231
|
+
return Error.io
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
function map_pack_result[T](result: Result[T, pack.Error]) -> Result[T, Error]:
|
|
235
|
+
return result.map_error(proc(e: pack.Error) -> Error:
|
|
236
|
+
from_pack_error(e)
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
function file_type(logical_path: str) -> Option[str]:
|
|
241
|
+
var index = logical_path.len
|
|
242
|
+
while index > 0:
|
|
243
|
+
index -= 1
|
|
244
|
+
|
|
245
|
+
let value = logical_path.byte_at(index)
|
|
246
|
+
if value == 47:
|
|
247
|
+
return Option[str].none
|
|
248
|
+
|
|
249
|
+
if value == 46:
|
|
250
|
+
if index + 1 == logical_path.len:
|
|
251
|
+
return Option[str].none
|
|
252
|
+
|
|
253
|
+
return Option[str].some(value= logical_path.slice(index, logical_path.len - index))
|
|
254
|
+
|
|
255
|
+
return Option[str].none
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import std.raylib as rl
|
|
2
|
+
import std.libc as libc
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
public function env_flag(name: str) -> bool:
|
|
6
|
+
return libc.get_environment_variable(name) != null
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
public function require_ptr[T](value: ptr[T]?, message: str) -> ptr[T]:
|
|
10
|
+
if value == null:
|
|
11
|
+
fatal(message)
|
|
12
|
+
|
|
13
|
+
return ptr[T]<-value
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
public function enter_asset_directory(directory_name: str) -> bool:
|
|
17
|
+
let working_dir = rl.get_working_directory()
|
|
18
|
+
let application_dir = rl.get_application_directory()
|
|
19
|
+
|
|
20
|
+
if rl.change_directory(application_dir):
|
|
21
|
+
if rl.change_directory(directory_name):
|
|
22
|
+
return true
|
|
23
|
+
|
|
24
|
+
rl.change_directory(working_dir)
|
|
25
|
+
|
|
26
|
+
return rl.change_directory(directory_name)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
public function enter_assets_directory() -> bool:
|
|
30
|
+
return enter_asset_directory("assets")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import std.tracy as tracy
|
|
2
|
+
|
|
3
|
+
public const GPU_CALIBRATION_QUERY_COUNT: int = 32
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
public function begin_gpu_zone(srcloc: const_ptr[tracy.SourceLocation], active: int) -> tracy.Zone:
|
|
7
|
+
return tracy.emit_gpu_zone_begin(srcloc, active)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
public function end_gpu_zone(zone: tracy.Zone) -> void:
|
|
11
|
+
tracy.emit_gpu_zone_end(zone)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
public function gpu_zone_value(zone: tracy.Zone, value: long) -> void:
|
|
15
|
+
tracy.emit_gpu_zone_value(zone, value)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
public function gpu_calibrate(zone: tracy.Zone) -> void:
|
|
19
|
+
tracy.emit_gpu_calibration(zone)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
public function submit_gpu_time(gpu_time: long, query_id: ushort, context: ubyte) -> void:
|
|
23
|
+
let data = tracy.GpuTime(
|
|
24
|
+
gpu_time = gpu_time,
|
|
25
|
+
query_id = query_id,
|
|
26
|
+
context = context
|
|
27
|
+
)
|
|
28
|
+
tracy.emit_gpu_time(const_ptr_of(data))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public function submit_gpu_time_sync(gpu_time: long, query_id: ushort, context: ubyte) -> void:
|
|
32
|
+
let data = tracy.GpuTime(
|
|
33
|
+
gpu_time = gpu_time,
|
|
34
|
+
query_id = query_id,
|
|
35
|
+
context = context
|
|
36
|
+
)
|
|
37
|
+
tracy.emit_gpu_time_sync(const_ptr_of(data))
|