@dayme/bunraylib 0.1.0 → 1.0.0

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.
Files changed (67) hide show
  1. package/README.md +60 -11
  2. package/package.json +11 -3
  3. package/src/Raylib.ts +58 -3678
  4. package/src/c/common.h +0 -2
  5. package/src/constants.ts +2 -2
  6. package/src/index.ts +6 -6
  7. package/src/main.c +0 -1
  8. package/src/main.d.ts +1 -1
  9. package/src/modules/audio/AudioModule.ts +197 -0
  10. package/src/modules/audio/symbols.ts +70 -0
  11. package/src/{c/audio.c → modules/audio/wrapper.c} +40 -80
  12. package/src/modules/camera/CameraModule.ts +239 -0
  13. package/src/modules/camera/symbols.ts +49 -0
  14. package/src/modules/camera/wrapper.c +141 -0
  15. package/src/modules/collision/CollisionModule.ts +363 -0
  16. package/src/modules/collision/symbols.ts +149 -0
  17. package/src/modules/collision/wrapper.c +176 -0
  18. package/src/modules/color/ColorModule.ts +65 -0
  19. package/src/modules/color/symbols.ts +26 -0
  20. package/src/modules/color/wrapper.c +16 -0
  21. package/src/modules/draw3d/Draw3DModule.ts +441 -0
  22. package/src/modules/draw3d/symbols.ts +199 -0
  23. package/src/modules/draw3d/wrapper.c +202 -0
  24. package/src/modules/font/FontModule.ts +250 -0
  25. package/src/modules/font/symbols.ts +46 -0
  26. package/src/{c/font.c → modules/font/wrapper.c} +50 -70
  27. package/src/modules/image/ImageModule.ts +451 -0
  28. package/src/{symbols/image.ts → modules/image/symbols.ts} +15 -12
  29. package/src/{c/image.c → modules/image/wrapper.c} +23 -45
  30. package/src/modules/input/InputModule.ts +160 -0
  31. package/src/modules/input/symbols.ts +54 -0
  32. package/src/modules/input/wrapper.c +31 -0
  33. package/src/modules/model/ModelModule.ts +228 -0
  34. package/src/{symbols/model.ts → modules/model/symbols.ts} +17 -14
  35. package/src/{c/model.c → modules/model/wrapper.c} +30 -30
  36. package/src/modules/shader/ShaderModule.ts +78 -0
  37. package/src/{symbols/shader.ts → modules/shader/symbols.ts} +3 -1
  38. package/src/{c/shader.c → modules/shader/wrapper.c} +11 -1
  39. package/src/modules/shapes/ShapesModule.ts +687 -0
  40. package/src/modules/shapes/symbols.ts +161 -0
  41. package/src/modules/shapes/wrapper.c +183 -0
  42. package/src/modules/texture/TextureModule.ts +190 -0
  43. package/src/{symbols/texture.ts → modules/texture/symbols.ts} +15 -9
  44. package/src/{c/texture.c → modules/texture/wrapper.c} +7 -22
  45. package/src/modules/window/WindowModule.ts +248 -0
  46. package/src/modules/window/symbols.ts +85 -0
  47. package/src/modules/window/wrapper.c +39 -0
  48. package/src/symbols.ts +87 -47
  49. package/src/utils.ts +63 -15
  50. package/src/c/camera.c +0 -161
  51. package/src/c/collision.c +0 -176
  52. package/src/c/color.c +0 -100
  53. package/src/c/draw3d.c +0 -222
  54. package/src/c/filesystem.c +0 -36
  55. package/src/c/input.c +0 -85
  56. package/src/c/shapes.c +0 -283
  57. package/src/c/window.c +0 -150
  58. package/src/symbols/audio.ts +0 -64
  59. package/src/symbols/camera.ts +0 -46
  60. package/src/symbols/collision.ts +0 -116
  61. package/src/symbols/color.ts +0 -22
  62. package/src/symbols/draw3d.ts +0 -137
  63. package/src/symbols/filesystem.ts +0 -30
  64. package/src/symbols/font.ts +0 -40
  65. package/src/symbols/input.ts +0 -51
  66. package/src/symbols/shapes.ts +0 -92
  67. package/src/symbols/window.ts +0 -83
@@ -0,0 +1,687 @@
1
+ import { getSymbols } from '../../symbols';
2
+ import { bufs as b, f, i, validatePoints } from '../../utils';
3
+ import type { Vec2, Rectangle, Texture2D, Color } from '../../types';
4
+
5
+ const r = () => getSymbols();
6
+
7
+ export class ShapesModule {
8
+ /** Draw a color-filled rectangle */
9
+ static drawRectangle(x: number, y: number, width: number, height: number, col: Color): void {
10
+ r().symbols.DrawRectangle(i(x), i(y), i(width), i(height), i(col));
11
+ }
12
+ static drawFPS(x: number, y: number): void {
13
+ r().symbols.DrawFPS(i(x), i(y));
14
+ }
15
+ /** Draw a pixel */
16
+ static drawPixel(x: number, y: number, col: Color): void {
17
+ r().symbols.DrawPixel(i(x), i(y), i(col));
18
+ }
19
+ /** Draw a pixel (using vector position) */
20
+ static drawPixelV(position: Vec2, col: Color): void {
21
+ r().symbols.DrawPixelVW(f(position.x), f(position.y), i(col));
22
+ }
23
+ /** Draw a line */
24
+ static drawLine(startX: number, startY: number, endX: number, endY: number, col: Color): void {
25
+ r().symbols.DrawLine(i(startX), i(startY), i(endX), i(endY), i(col));
26
+ }
27
+ /** Draw a line (using vector positions) */
28
+ static drawLineV(startPos: Vec2, endPos: Vec2, col: Color): void {
29
+ r().symbols.DrawLineVW(f(startPos.x), f(startPos.y), f(endPos.x), f(endPos.y), i(col));
30
+ }
31
+ /** Draw a line with defined thickness */
32
+ static drawLineEx(startPos: Vec2, endPos: Vec2, thick: number, col: Color): void {
33
+ r().symbols.DrawLineExW(
34
+ f(startPos.x),
35
+ f(startPos.y),
36
+ f(endPos.x),
37
+ f(endPos.y),
38
+ f(thick),
39
+ i(col),
40
+ );
41
+ }
42
+ /** Draw lines sequence as a strip. Points are packed as [x0,y0, x1,y1, ...] in Float32Array */
43
+ static drawLineStrip(points: Float32Array, col: Color): void {
44
+ validatePoints('drawLineStrip', points, 2, 2);
45
+ r().symbols.DrawLineStrip(points, i(points.length / 2), i(col));
46
+ }
47
+ /** Draw line segment with Bezier easing */
48
+ static drawLineBezier(startPos: Vec2, endPos: Vec2, thick: number, col: Color): void {
49
+ r().symbols.DrawLineBezierW(
50
+ f(startPos.x),
51
+ f(startPos.y),
52
+ f(endPos.x),
53
+ f(endPos.y),
54
+ f(thick),
55
+ i(col),
56
+ );
57
+ }
58
+ static drawLineDashed(
59
+ startPos: Vec2,
60
+ endPos: Vec2,
61
+ dashSize: number,
62
+ spaceSize: number,
63
+ col: Color,
64
+ ): void {
65
+ r().symbols.DrawLineDashedW(
66
+ f(startPos.x),
67
+ f(startPos.y),
68
+ f(endPos.x),
69
+ f(endPos.y),
70
+ i(dashSize),
71
+ i(spaceSize),
72
+ i(col),
73
+ );
74
+ }
75
+ /** Draw a color-filled circle */
76
+ static drawCircle(centerX: number, centerY: number, radius: number, col: Color): void {
77
+ r().symbols.DrawCircle(i(centerX), i(centerY), f(radius), i(col));
78
+ }
79
+ /** Draw a color-filled circle (using vector center) */
80
+ static drawCircleV(center: Vec2, radius: number, col: Color): void {
81
+ r().symbols.DrawCircleVW(i(center.x), i(center.y), f(radius), i(col));
82
+ }
83
+ /**
84
+ * Draw a circle sector (pie slice).
85
+ * @param center - Center position
86
+ * @param radius - Circle radius
87
+ * @param startAngle - Start angle in degrees
88
+ * @param endAngle - End angle in degrees
89
+ * @param segments - Number of segments (higher = smoother)
90
+ * @param col - Fill color
91
+ */
92
+ static drawCircleSector(
93
+ center: Vec2,
94
+ radius: number,
95
+ startAngle: number,
96
+ endAngle: number,
97
+ segments: number,
98
+ col: Color,
99
+ ): void {
100
+ r().symbols.DrawCircleSectorW(
101
+ f(center.x),
102
+ f(center.y),
103
+ f(radius),
104
+ f(startAngle),
105
+ f(endAngle),
106
+ i(segments),
107
+ i(col),
108
+ );
109
+ }
110
+ /**
111
+ * Draw a circle sector outline.
112
+ * @param center - Center position
113
+ * @param radius - Circle radius
114
+ * @param startAngle - Start angle in degrees
115
+ * @param endAngle - End angle in degrees
116
+ * @param segments - Number of segments (higher = smoother)
117
+ * @param col - Outline color
118
+ */
119
+ static drawCircleSectorLines(
120
+ center: Vec2,
121
+ radius: number,
122
+ startAngle: number,
123
+ endAngle: number,
124
+ segments: number,
125
+ col: Color,
126
+ ): void {
127
+ r().symbols.DrawCircleSectorLinesW(
128
+ f(center.x),
129
+ f(center.y),
130
+ f(radius),
131
+ f(startAngle),
132
+ f(endAngle),
133
+ i(segments),
134
+ i(col),
135
+ );
136
+ }
137
+ /** Draw a gradient-filled circle */
138
+ static drawCircleGradient(
139
+ centerX: number,
140
+ centerY: number,
141
+ radius: number,
142
+ inner: Color,
143
+ outer: Color,
144
+ ): void {
145
+ r().symbols.DrawCircleGradientW(f(centerX), f(centerY), f(radius), i(inner), i(outer));
146
+ }
147
+ /** Draw circle outline */
148
+ static drawCircleLines(centerX: number, centerY: number, radius: number, col: Color): void {
149
+ r().symbols.DrawCircleLines(i(centerX), i(centerY), f(radius), i(col));
150
+ }
151
+ /** Draw circle outline (using vector center) */
152
+ static drawCircleLinesV(center: Vec2, radius: number, col: Color): void {
153
+ r().symbols.DrawCircleLinesVW(f(center.x), f(center.y), f(radius), i(col));
154
+ }
155
+ /** Draw a color-filled ellipse */
156
+ static drawEllipse(
157
+ centerX: number,
158
+ centerY: number,
159
+ radiusH: number,
160
+ radiusV: number,
161
+ col: Color,
162
+ ): void {
163
+ r().symbols.DrawEllipse(i(centerX), i(centerY), f(radiusH), f(radiusV), i(col));
164
+ }
165
+ /** Draw a color-filled ellipse */
166
+ static drawEllipseV(center: Vec2, radiusH: number, radiusV: number, col: Color): void {
167
+ r().symbols.DrawEllipseVW(f(center.x), f(center.y), f(radiusH), f(radiusV), i(col));
168
+ }
169
+ /** Draw a color-filled ellipse lines */
170
+ static drawEllipseLinesV(center: Vec2, radiusH: number, radiusV: number, col: Color): void {
171
+ r().symbols.DrawEllipseLinesVW(f(center.x), f(center.y), f(radiusH), f(radiusV), i(col));
172
+ }
173
+ /** Draw ellipse outline */
174
+ static drawEllipseLines(
175
+ centerX: number,
176
+ centerY: number,
177
+ radiusH: number,
178
+ radiusV: number,
179
+ col: Color,
180
+ ): void {
181
+ r().symbols.DrawEllipseLines(i(centerX), i(centerY), f(radiusH), f(radiusV), i(col));
182
+ }
183
+ /**
184
+ * Draw a ring (donut shape).
185
+ * @param center - Center position
186
+ * @param innerRadius - Inner circle radius
187
+ * @param outerRadius - Outer circle radius
188
+ * @param startAngle - Start angle in degrees
189
+ * @param endAngle - End angle in degrees
190
+ * @param segments - Number of segments (higher = smoother)
191
+ * @param col - Fill color
192
+ */
193
+ static drawRing(
194
+ center: Vec2,
195
+ innerRadius: number,
196
+ outerRadius: number,
197
+ startAngle: number,
198
+ endAngle: number,
199
+ segments: number,
200
+ col: Color,
201
+ ): void {
202
+ r().symbols.DrawRingW(
203
+ f(center.x),
204
+ f(center.y),
205
+ f(innerRadius),
206
+ f(outerRadius),
207
+ f(startAngle),
208
+ f(endAngle),
209
+ i(segments),
210
+ i(col),
211
+ );
212
+ }
213
+ /**
214
+ * Draw a ring outline.
215
+ * @param center - Center position
216
+ * @param innerRadius - Inner circle radius
217
+ * @param outerRadius - Outer circle radius
218
+ * @param startAngle - Start angle in degrees
219
+ * @param endAngle - End angle in degrees
220
+ * @param segments - Number of segments (higher = smoother)
221
+ * @param col - Outline color
222
+ */
223
+ static drawRingLines(
224
+ center: Vec2,
225
+ innerRadius: number,
226
+ outerRadius: number,
227
+ startAngle: number,
228
+ endAngle: number,
229
+ segments: number,
230
+ col: Color,
231
+ ): void {
232
+ r().symbols.DrawRingLinesW(
233
+ f(center.x),
234
+ f(center.y),
235
+ f(innerRadius),
236
+ f(outerRadius),
237
+ f(startAngle),
238
+ f(endAngle),
239
+ i(segments),
240
+ i(col),
241
+ );
242
+ }
243
+ /** Draw a color-filled rectangle (using vector position and size) */
244
+ static drawRectangleV(pos: Vec2, size: Vec2, col: Color): void {
245
+ r().symbols.DrawRectangleVW(f(pos.x), f(pos.y), f(size.x), f(size.y), i(col));
246
+ }
247
+ static drawRectangleRec(rec: Rectangle, col: Color): void {
248
+ r().symbols.DrawRectangleRecW(f(rec.x), f(rec.y), f(rec.width), f(rec.height), i(col));
249
+ }
250
+ /** Draw a color-filled rectangle with pro parameters (rotation and origin) */
251
+ static drawRectanglePro(rec: Rectangle, origin: Vec2, rotation: number, col: Color): void {
252
+ r().symbols.DrawRectangleProW(
253
+ f(rec.x),
254
+ f(rec.y),
255
+ f(rec.width),
256
+ f(rec.height),
257
+ f(origin.x),
258
+ f(origin.y),
259
+ f(rotation),
260
+ i(col),
261
+ );
262
+ }
263
+ /** Draw a vertical-gradient-filled rectangle */
264
+ static drawRectangleGradientV(
265
+ x: number,
266
+ y: number,
267
+ width: number,
268
+ height: number,
269
+ top: Color,
270
+ bottom: Color,
271
+ ): void {
272
+ r().symbols.DrawRectangleGradientV(i(x), i(y), i(width), i(height), i(top), i(bottom));
273
+ }
274
+ /** Draw a horizontal-gradient-filled rectangle */
275
+ static drawRectangleGradientH(
276
+ x: number,
277
+ y: number,
278
+ width: number,
279
+ height: number,
280
+ left: Color,
281
+ right: Color,
282
+ ): void {
283
+ r().symbols.DrawRectangleGradientH(i(x), i(y), i(width), i(height), i(left), i(right));
284
+ }
285
+ /** Draw a gradient-filled rectangle with custom gradient colors for each corner */
286
+ static drawRectangleGradientEx(
287
+ rec: Rectangle,
288
+ topLeft: Color,
289
+ bottomLeft: Color,
290
+ topRight: Color,
291
+ bottomRight: Color,
292
+ ): void {
293
+ r().symbols.DrawRectangleGradientExW(
294
+ f(rec.x),
295
+ f(rec.y),
296
+ f(rec.width),
297
+ f(rec.height),
298
+ i(topLeft),
299
+ i(bottomLeft),
300
+ i(topRight),
301
+ i(bottomRight),
302
+ );
303
+ }
304
+ /** Draw rectangle outline */
305
+ static drawRectangleLines(x: number, y: number, width: number, height: number, col: Color): void {
306
+ r().symbols.DrawRectangleLines(i(x), i(y), i(width), i(height), i(col));
307
+ }
308
+ /** Draw rectangle outline with extended parameters (custom line thickness) */
309
+ static drawRectangleLinesEx(rec: Rectangle, lineThick: number, col: Color): void {
310
+ r().symbols.DrawRectangleLinesExW(
311
+ f(rec.x),
312
+ f(rec.y),
313
+ f(rec.width),
314
+ f(rec.height),
315
+ f(lineThick),
316
+ i(col),
317
+ );
318
+ }
319
+ /** Draw rectangle with rounded edges */
320
+ static drawRectangleRounded(
321
+ rec: Rectangle,
322
+ roundness: number,
323
+ segments: number,
324
+ col: Color,
325
+ ): void {
326
+ r().symbols.DrawRectangleRoundedW(
327
+ f(rec.x),
328
+ f(rec.y),
329
+ f(rec.width),
330
+ f(rec.height),
331
+ f(roundness),
332
+ i(segments),
333
+ i(col),
334
+ );
335
+ }
336
+ /** Draw rectangle with rounded edges outline */
337
+ static drawRectangleRoundedLines(
338
+ rec: Rectangle,
339
+ roundness: number,
340
+ segments: number,
341
+ col: Color,
342
+ ): void {
343
+ r().symbols.DrawRectangleRoundedLinesW(
344
+ f(rec.x),
345
+ f(rec.y),
346
+ f(rec.width),
347
+ f(rec.height),
348
+ f(roundness),
349
+ i(segments),
350
+ i(col),
351
+ );
352
+ }
353
+ /** Draw rectangle with rounded edges outline (custom line thickness) */
354
+ static drawRectangleRoundedLinesEx(
355
+ rec: Rectangle,
356
+ roundness: number,
357
+ segments: number,
358
+ lineThick: number,
359
+ col: Color,
360
+ ): void {
361
+ r().symbols.DrawRectangleRoundedLinesExW(
362
+ f(rec.x),
363
+ f(rec.y),
364
+ f(rec.width),
365
+ f(rec.height),
366
+ f(roundness),
367
+ i(segments),
368
+ f(lineThick),
369
+ i(col),
370
+ );
371
+ }
372
+ /** Draw a color-filled triangle */
373
+ static drawTriangle(v1: Vec2, v2: Vec2, v3: Vec2, col: Color): void {
374
+ r().symbols.DrawTriangleW(f(v1.x), f(v1.y), f(v2.x), f(v2.y), f(v3.x), f(v3.y), i(col));
375
+ }
376
+ /** Draw triangle outline */
377
+ static drawTriangleLines(v1: Vec2, v2: Vec2, v3: Vec2, col: Color): void {
378
+ r().symbols.DrawTriangleLinesW(f(v1.x), f(v1.y), f(v2.x), f(v2.y), f(v3.x), f(v3.y), i(col));
379
+ }
380
+ /** Draw a triangle fan. Points are packed as [x0,y0, x1,y1, ...] in Float32Array */
381
+ static drawTriangleFan(points: Float32Array, col: Color): void {
382
+ validatePoints('drawTriangleFan', points, 2, 3);
383
+ r().symbols.DrawTriangleFan(points, i(points.length / 2), i(col));
384
+ }
385
+ /** Draw a triangle strip. Points are packed as [x0,y0, x1,y1, ...] in Float32Array */
386
+ static drawTriangleStrip(points: Float32Array, col: Color): void {
387
+ validatePoints('drawTriangleStrip', points, 2, 2);
388
+ r().symbols.DrawTriangleStrip(points, i(points.length / 2), i(col));
389
+ }
390
+ /** Draw a regular polygon (color-filled) */
391
+ static drawPoly(center: Vec2, sides: number, radius: number, rotation: number, col: Color): void {
392
+ r().symbols.DrawPolyW(f(center.x), f(center.y), i(sides), f(radius), f(rotation), i(col));
393
+ }
394
+ /** Draw a regular polygon outline */
395
+ static drawPolyLines(
396
+ center: Vec2,
397
+ sides: number,
398
+ radius: number,
399
+ rotation: number,
400
+ col: Color,
401
+ ): void {
402
+ r().symbols.DrawPolyLinesW(f(center.x), f(center.y), i(sides), f(radius), f(rotation), i(col));
403
+ }
404
+ /** Draw a regular polygon outline with custom line thickness */
405
+ static drawPolyLinesEx(
406
+ center: Vec2,
407
+ sides: number,
408
+ radius: number,
409
+ rotation: number,
410
+ lineThick: number,
411
+ col: Color,
412
+ ): void {
413
+ r().symbols.DrawPolyLinesExW(
414
+ f(center.x),
415
+ f(center.y),
416
+ i(sides),
417
+ f(radius),
418
+ f(rotation),
419
+ f(lineThick),
420
+ i(col),
421
+ );
422
+ }
423
+ /**
424
+ * Draw spline: Linear. Minimum 2 points.
425
+ * Points are packed as [x0,y0, x1,y1, ...] in Float32Array.
426
+ */
427
+ static drawSplineLinear(points: Float32Array, thick: number, col: Color): void {
428
+ validatePoints('drawSplineLinear', points, 2, 2);
429
+ r().symbols.DrawSplineLinear(points, i(points.length / 2), f(thick), i(col));
430
+ }
431
+ /**
432
+ * Draw spline: B-Spline. Minimum 4 points.
433
+ * Points are packed as [x0,y0, x1,y1, ...] in Float32Array.
434
+ */
435
+ static drawSplineBasis(points: Float32Array, thick: number, col: Color): void {
436
+ validatePoints('drawSplineBasis', points, 2, 4);
437
+ r().symbols.DrawSplineBasis(points, i(points.length / 2), f(thick), i(col));
438
+ }
439
+ /**
440
+ * Draw spline: Catmull-Rom. Minimum 4 points.
441
+ * Points are packed as [x0,y0, x1,y1, ...] in Float32Array.
442
+ */
443
+ static drawSplineCatmullRom(points: Float32Array, thick: number, col: Color): void {
444
+ validatePoints('drawSplineCatmullRom', points, 2, 4);
445
+ r().symbols.DrawSplineCatmullRom(points, i(points.length / 2), f(thick), i(col));
446
+ }
447
+ /**
448
+ * Draw spline: Quadratic Bezier. Minimum 3 points (1 control point).
449
+ * Points layout: [p1, c2, p3, c4, ...] packed as [x0,y0, x1,y1, ...] in Float32Array.
450
+ */
451
+ static drawSplineBezierQuadratic(points: Float32Array, thick: number, col: Color): void {
452
+ validatePoints('drawSplineBezierQuadratic', points, 2, 3);
453
+ r().symbols.DrawSplineBezierQuadratic(points, i(points.length / 2), f(thick), i(col));
454
+ }
455
+ /**
456
+ * Draw spline: Cubic Bezier. Minimum 4 points (2 control points).
457
+ * Points layout: [p1, c2, c3, p4, c5, c6, ...] packed as [x0,y0, x1,y1, ...] in Float32Array.
458
+ */
459
+ static drawSplineBezierCubic(points: Float32Array, thick: number, col: Color): void {
460
+ validatePoints('drawSplineBezierCubic', points, 2, 4);
461
+ r().symbols.DrawSplineBezierCubic(points, i(points.length / 2), f(thick), i(col));
462
+ }
463
+ /** Draw spline segment: Linear, 2 points */
464
+ static drawSplineSegmentLinear(p1: Vec2, p2: Vec2, thick: number, col: Color): void {
465
+ r().symbols.DrawSplineSegmentLinearW(f(p1.x), f(p1.y), f(p2.x), f(p2.y), f(thick), i(col));
466
+ }
467
+ /** Draw spline segment: B-Spline, 4 points */
468
+ static drawSplineSegmentBasis(
469
+ p1: Vec2,
470
+ p2: Vec2,
471
+ p3: Vec2,
472
+ p4: Vec2,
473
+ thick: number,
474
+ col: Color,
475
+ ): void {
476
+ r().symbols.DrawSplineSegmentBasisW(
477
+ f(p1.x),
478
+ f(p1.y),
479
+ f(p2.x),
480
+ f(p2.y),
481
+ f(p3.x),
482
+ f(p3.y),
483
+ f(p4.x),
484
+ f(p4.y),
485
+ f(thick),
486
+ i(col),
487
+ );
488
+ }
489
+ /** Draw spline segment: Catmull-Rom, 4 points */
490
+ static drawSplineSegmentCatmullRom(
491
+ p1: Vec2,
492
+ p2: Vec2,
493
+ p3: Vec2,
494
+ p4: Vec2,
495
+ thick: number,
496
+ col: Color,
497
+ ): void {
498
+ r().symbols.DrawSplineSegmentCatmullRomW(
499
+ f(p1.x),
500
+ f(p1.y),
501
+ f(p2.x),
502
+ f(p2.y),
503
+ f(p3.x),
504
+ f(p3.y),
505
+ f(p4.x),
506
+ f(p4.y),
507
+ f(thick),
508
+ i(col),
509
+ );
510
+ }
511
+ /** Draw spline segment: Quadratic Bezier, 2 points + 1 control point */
512
+ static drawSplineSegmentBezierQuadratic(
513
+ p1: Vec2,
514
+ c2: Vec2,
515
+ p3: Vec2,
516
+ thick: number,
517
+ col: Color,
518
+ ): void {
519
+ r().symbols.DrawSplineSegmentBezierQuadraticW(
520
+ f(p1.x),
521
+ f(p1.y),
522
+ f(c2.x),
523
+ f(c2.y),
524
+ f(p3.x),
525
+ f(p3.y),
526
+ f(thick),
527
+ i(col),
528
+ );
529
+ }
530
+ /** Draw spline segment: Cubic Bezier, 2 points + 2 control points */
531
+ static drawSplineSegmentBezierCubic(
532
+ p1: Vec2,
533
+ c2: Vec2,
534
+ c3: Vec2,
535
+ p4: Vec2,
536
+ thick: number,
537
+ col: Color,
538
+ ): void {
539
+ r().symbols.DrawSplineSegmentBezierCubicW(
540
+ f(p1.x),
541
+ f(p1.y),
542
+ f(c2.x),
543
+ f(c2.y),
544
+ f(c3.x),
545
+ f(c3.y),
546
+ f(p4.x),
547
+ f(p4.y),
548
+ f(thick),
549
+ i(col),
550
+ );
551
+ }
552
+ /**
553
+ * Get (evaluate) spline point: Linear.
554
+ * @param startPos - Start position
555
+ * @param endPos - End position
556
+ * @param t - Interpolation factor [0.0 .. 1.0]
557
+ * @returns Evaluated point as Vec2
558
+ */
559
+ static getSplinePointLinear(startPos: Vec2, endPos: Vec2, t: number): Vec2 {
560
+ r().symbols.GetSplinePointLinearW(
561
+ b._vec2Buf,
562
+ f(startPos.x),
563
+ f(startPos.y),
564
+ f(endPos.x),
565
+ f(endPos.y),
566
+ f(t),
567
+ );
568
+ return { x: b._vec2Buf[0]!, y: b._vec2Buf[1]! };
569
+ }
570
+ /**
571
+ * Get (evaluate) spline point: B-Spline.
572
+ * @param p1 - Point 1
573
+ * @param p2 - Point 2
574
+ * @param p3 - Point 3
575
+ * @param p4 - Point 4
576
+ * @param t - Interpolation factor [0.0 .. 1.0]
577
+ * @returns Evaluated point as Vec2
578
+ */
579
+ static getSplinePointBasis(p1: Vec2, p2: Vec2, p3: Vec2, p4: Vec2, t: number): Vec2 {
580
+ r().symbols.GetSplinePointBasisW(
581
+ b._vec2Buf,
582
+ f(p1.x),
583
+ f(p1.y),
584
+ f(p2.x),
585
+ f(p2.y),
586
+ f(p3.x),
587
+ f(p3.y),
588
+ f(p4.x),
589
+ f(p4.y),
590
+ f(t),
591
+ );
592
+ return { x: b._vec2Buf[0]!, y: b._vec2Buf[1]! };
593
+ }
594
+ /**
595
+ * Get (evaluate) spline point: Catmull-Rom.
596
+ * @param p1 - Point 1
597
+ * @param p2 - Point 2
598
+ * @param p3 - Point 3
599
+ * @param p4 - Point 4
600
+ * @param t - Interpolation factor [0.0 .. 1.0]
601
+ * @returns Evaluated point as Vec2
602
+ */
603
+ static getSplinePointCatmullRom(p1: Vec2, p2: Vec2, p3: Vec2, p4: Vec2, t: number): Vec2 {
604
+ r().symbols.GetSplinePointCatmullRomW(
605
+ b._vec2Buf,
606
+ f(p1.x),
607
+ f(p1.y),
608
+ f(p2.x),
609
+ f(p2.y),
610
+ f(p3.x),
611
+ f(p3.y),
612
+ f(p4.x),
613
+ f(p4.y),
614
+ f(t),
615
+ );
616
+ return { x: b._vec2Buf[0]!, y: b._vec2Buf[1]! };
617
+ }
618
+ /**
619
+ * Get (evaluate) spline point: Quadratic Bezier.
620
+ * @param p1 - Start point
621
+ * @param c2 - Control point
622
+ * @param p3 - End point
623
+ * @param t - Interpolation factor [0.0 .. 1.0]
624
+ * @returns Evaluated point as Vec2
625
+ */
626
+ static getSplinePointBezierQuad(p1: Vec2, c2: Vec2, p3: Vec2, t: number): Vec2 {
627
+ r().symbols.GetSplinePointBezierQuadW(
628
+ b._vec2Buf,
629
+ f(p1.x),
630
+ f(p1.y),
631
+ f(c2.x),
632
+ f(c2.y),
633
+ f(p3.x),
634
+ f(p3.y),
635
+ f(t),
636
+ );
637
+ return { x: b._vec2Buf[0]!, y: b._vec2Buf[1]! };
638
+ }
639
+ /**
640
+ * Get (evaluate) spline point: Cubic Bezier.
641
+ * @param p1 - Start point
642
+ * @param c2 - Control point 1
643
+ * @param c3 - Control point 2
644
+ * @param p4 - End point
645
+ * @param t - Interpolation factor [0.0 .. 1.0]
646
+ * @returns Evaluated point as Vec2
647
+ */
648
+ static getSplinePointBezierCubic(p1: Vec2, c2: Vec2, c3: Vec2, p4: Vec2, t: number): Vec2 {
649
+ r().symbols.GetSplinePointBezierCubicW(
650
+ b._vec2Buf,
651
+ f(p1.x),
652
+ f(p1.y),
653
+ f(c2.x),
654
+ f(c2.y),
655
+ f(c3.x),
656
+ f(c3.y),
657
+ f(p4.x),
658
+ f(p4.y),
659
+ f(t),
660
+ );
661
+ return { x: b._vec2Buf[0]!, y: b._vec2Buf[1]! };
662
+ }
663
+ static setShapesTexture(texture: Texture2D, source: Rectangle): void {
664
+ r().symbols.SetShapesTextureW(
665
+ i(texture.id),
666
+ i(texture.width),
667
+ i(texture.height),
668
+ i(source.x),
669
+ i(source.y),
670
+ i(source.width),
671
+ i(source.height),
672
+ );
673
+ }
674
+ static getShapesTexture(): Texture2D {
675
+ r().symbols.GetShapesTextureW(b._shapesTexId, b._shapesTexW, b._shapesTexH);
676
+ return { id: b._shapesTexId[0]!, width: b._shapesTexW[0]!, height: b._shapesTexH[0]! };
677
+ }
678
+ static getShapesTextureRectangle(): Rectangle {
679
+ r().symbols.GetShapesTextureRectangleW(b._recBuf);
680
+ return {
681
+ x: b._recBuf[0]!,
682
+ y: b._recBuf[1]!,
683
+ width: b._recBuf[2]!,
684
+ height: b._recBuf[3]!,
685
+ };
686
+ }
687
+ }