@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.
- package/README.md +60 -11
- package/package.json +11 -3
- package/src/Raylib.ts +58 -3678
- package/src/c/common.h +0 -2
- package/src/constants.ts +2 -2
- package/src/index.ts +6 -6
- package/src/main.c +0 -1
- package/src/main.d.ts +1 -1
- package/src/modules/audio/AudioModule.ts +197 -0
- package/src/modules/audio/symbols.ts +70 -0
- package/src/{c/audio.c → modules/audio/wrapper.c} +40 -80
- package/src/modules/camera/CameraModule.ts +239 -0
- package/src/modules/camera/symbols.ts +49 -0
- package/src/modules/camera/wrapper.c +141 -0
- package/src/modules/collision/CollisionModule.ts +363 -0
- package/src/modules/collision/symbols.ts +149 -0
- package/src/modules/collision/wrapper.c +176 -0
- package/src/modules/color/ColorModule.ts +65 -0
- package/src/modules/color/symbols.ts +26 -0
- package/src/modules/color/wrapper.c +16 -0
- package/src/modules/draw3d/Draw3DModule.ts +441 -0
- package/src/modules/draw3d/symbols.ts +199 -0
- package/src/modules/draw3d/wrapper.c +202 -0
- package/src/modules/font/FontModule.ts +250 -0
- package/src/modules/font/symbols.ts +46 -0
- package/src/{c/font.c → modules/font/wrapper.c} +50 -70
- package/src/modules/image/ImageModule.ts +451 -0
- package/src/{symbols/image.ts → modules/image/symbols.ts} +15 -12
- package/src/{c/image.c → modules/image/wrapper.c} +23 -45
- package/src/modules/input/InputModule.ts +160 -0
- package/src/modules/input/symbols.ts +54 -0
- package/src/modules/input/wrapper.c +31 -0
- package/src/modules/model/ModelModule.ts +228 -0
- package/src/{symbols/model.ts → modules/model/symbols.ts} +17 -14
- package/src/{c/model.c → modules/model/wrapper.c} +30 -30
- package/src/modules/shader/ShaderModule.ts +78 -0
- package/src/{symbols/shader.ts → modules/shader/symbols.ts} +3 -1
- package/src/{c/shader.c → modules/shader/wrapper.c} +11 -1
- package/src/modules/shapes/ShapesModule.ts +687 -0
- package/src/modules/shapes/symbols.ts +161 -0
- package/src/modules/shapes/wrapper.c +183 -0
- package/src/modules/texture/TextureModule.ts +190 -0
- package/src/{symbols/texture.ts → modules/texture/symbols.ts} +15 -9
- package/src/{c/texture.c → modules/texture/wrapper.c} +7 -22
- package/src/modules/window/WindowModule.ts +248 -0
- package/src/modules/window/symbols.ts +85 -0
- package/src/modules/window/wrapper.c +39 -0
- package/src/symbols.ts +87 -47
- package/src/utils.ts +63 -15
- package/src/c/camera.c +0 -161
- package/src/c/collision.c +0 -176
- package/src/c/color.c +0 -100
- package/src/c/draw3d.c +0 -222
- package/src/c/filesystem.c +0 -36
- package/src/c/input.c +0 -85
- package/src/c/shapes.c +0 -283
- package/src/c/window.c +0 -150
- package/src/symbols/audio.ts +0 -64
- package/src/symbols/camera.ts +0 -46
- package/src/symbols/collision.ts +0 -116
- package/src/symbols/color.ts +0 -22
- package/src/symbols/draw3d.ts +0 -137
- package/src/symbols/filesystem.ts +0 -30
- package/src/symbols/font.ts +0 -40
- package/src/symbols/input.ts +0 -51
- package/src/symbols/shapes.ts +0 -92
- package/src/symbols/window.ts +0 -83
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#include "common.h"
|
|
1
|
+
#include "../../c/common.h"
|
|
2
|
+
#include <stdlib.h>
|
|
2
3
|
|
|
3
4
|
int LoadFontW(const char* fileName) {
|
|
4
5
|
int slot = fontAlloc();
|
|
@@ -32,32 +33,19 @@ bool IsFontValidW(int id) {
|
|
|
32
33
|
return IsFontValid(fontRegistry[id]);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
int
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
void MeasureTextExW(float* out, int fontId, const char* text, int fontSize, int spacing) {
|
|
40
|
-
float sp;
|
|
41
|
-
memcpy(&sp, &spacing, sizeof(float));
|
|
42
|
-
Vector2 v = MeasureTextEx(fontRegistry[fontId], text, fontSize, sp);
|
|
36
|
+
void MeasureTextExW(float* out, int fontId, const char* text, float fontSize, float spacing) {
|
|
37
|
+
Vector2 v = MeasureTextEx(fontRegistry[fontId], text, fontSize, spacing);
|
|
43
38
|
out[0] = v.x; out[1] = v.y;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
void DrawTextExW(int fontId, const char* text,
|
|
47
|
-
|
|
48
|
-
memcpy(&sp, &spacing, sizeof(float));
|
|
49
|
-
DrawTextEx(fontRegistry[fontId], text, (Vector2){posX, posY}, fontSize, sp, tint);
|
|
41
|
+
void DrawTextExW(int fontId, const char* text, float posX, float posY, float fontSize, float spacing, Color tint) {
|
|
42
|
+
DrawTextEx(fontRegistry[fontId], text, (Vector2){posX, posY}, fontSize, spacing, tint);
|
|
50
43
|
}
|
|
51
44
|
|
|
52
|
-
void DrawTextProW(int fontId, const char* text,
|
|
53
|
-
|
|
54
|
-
memcpy(&rot, &rotation, sizeof(float));
|
|
55
|
-
memcpy(&sp, &spacing, sizeof(float));
|
|
56
|
-
DrawTextPro(fontRegistry[fontId], text, (Vector2){posX, posY}, (Vector2){originX, originY}, rot, fontSize, sp, tint);
|
|
45
|
+
void DrawTextProW(int fontId, const char* text, float posX, float posY, float originX, float originY, float rotation, float fontSize, float spacing, Color tint) {
|
|
46
|
+
DrawTextPro(fontRegistry[fontId], text, (Vector2){posX, posY}, (Vector2){originX, originY}, rotation, fontSize, spacing, tint);
|
|
57
47
|
}
|
|
58
48
|
|
|
59
|
-
void SetTextLineSpacingW(int spacing) { SetTextLineSpacing(spacing); }
|
|
60
|
-
|
|
61
49
|
int LoadFontFromImageW(int imageId, Color key, int firstChar) {
|
|
62
50
|
if (imageId < 0 || imageId >= MAX_IMAGES || !imageUsed[imageId]) return -1;
|
|
63
51
|
int slot = fontAlloc();
|
|
@@ -78,17 +66,12 @@ bool ExportFontAsCodeW(int fontId, const char* fileName) {
|
|
|
78
66
|
return ExportFontAsCode(fontRegistry[fontId], fileName);
|
|
79
67
|
}
|
|
80
68
|
|
|
81
|
-
void DrawTextCodepointW(int fontId, int codepoint,
|
|
82
|
-
|
|
83
|
-
memcpy(&fs, &fontSize, sizeof(float));
|
|
84
|
-
DrawTextCodepoint(fontRegistry[fontId], codepoint, (Vector2){posX, posY}, fs, tint);
|
|
69
|
+
void DrawTextCodepointW(int fontId, int codepoint, float posX, float posY, float fontSize, Color tint) {
|
|
70
|
+
DrawTextCodepoint(fontRegistry[fontId], codepoint, (Vector2){posX, posY}, fontSize, tint);
|
|
85
71
|
}
|
|
86
72
|
|
|
87
|
-
void DrawTextCodepointsW(int fontId, const int* codepoints, int count,
|
|
88
|
-
|
|
89
|
-
memcpy(&fs, &fontSize, sizeof(float));
|
|
90
|
-
memcpy(&sp, &spacing, sizeof(float));
|
|
91
|
-
DrawTextCodepoints(fontRegistry[fontId], codepoints, count, (Vector2){posX, posY}, fs, sp, tint);
|
|
73
|
+
void DrawTextCodepointsW(int fontId, const int* codepoints, int count, float posX, float posY, float fontSize, float spacing, Color tint) {
|
|
74
|
+
DrawTextCodepoints(fontRegistry[fontId], codepoints, count, (Vector2){posX, posY}, fontSize, spacing, tint);
|
|
92
75
|
}
|
|
93
76
|
|
|
94
77
|
int GetGlyphIndexW(int fontId, int codepoint) {
|
|
@@ -113,51 +96,48 @@ void GetGlyphAtlasRecW(float* out, int fontId, int codepoint) {
|
|
|
113
96
|
out[0] = rec.x; out[1] = rec.y; out[2] = rec.width; out[3] = rec.height;
|
|
114
97
|
}
|
|
115
98
|
|
|
116
|
-
int
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
bool TextIsEqualW(const char* text1, const char* text2) {
|
|
133
|
-
return TextIsEqual(text1, text2);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
unsigned int TextLengthW(const char* text) {
|
|
137
|
-
return TextLength(text);
|
|
138
|
-
}
|
|
99
|
+
int GenImageFontAtlasW(float* outRecs, int* glyphData, int glyphCount, int fontSize, int padding, int packMethod) {
|
|
100
|
+
GlyphInfo* glyphs = (GlyphInfo*)RL_MALLOC(glyphCount * sizeof(GlyphInfo));
|
|
101
|
+
for (int i = 0; i < glyphCount; i++) {
|
|
102
|
+
glyphs[i].value = glyphData[i * 5];
|
|
103
|
+
glyphs[i].offsetX = glyphData[i * 5 + 1];
|
|
104
|
+
glyphs[i].offsetY = glyphData[i * 5 + 2];
|
|
105
|
+
glyphs[i].advanceX = glyphData[i * 5 + 3];
|
|
106
|
+
int imgSlot = glyphData[i * 5 + 4];
|
|
107
|
+
if (imgSlot >= 0 && imgSlot < MAX_IMAGES && imageUsed[imgSlot]) {
|
|
108
|
+
glyphs[i].image = imageRegistry[imgSlot];
|
|
109
|
+
} else {
|
|
110
|
+
glyphs[i].image = (Image){NULL, 0, 0, 1, 0};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
139
113
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
114
|
+
Rectangle* recs = NULL;
|
|
115
|
+
Image atlas = GenImageFontAtlas(glyphs, &recs, glyphCount, fontSize, padding, packMethod);
|
|
143
116
|
|
|
144
|
-
|
|
145
|
-
return TextToFloat(text);
|
|
146
|
-
}
|
|
117
|
+
RL_FREE(glyphs);
|
|
147
118
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
119
|
+
if (recs && outRecs) {
|
|
120
|
+
for (int i = 0; i < glyphCount; i++) {
|
|
121
|
+
outRecs[i * 4] = recs[i].x;
|
|
122
|
+
outRecs[i * 4 + 1] = recs[i].y;
|
|
123
|
+
outRecs[i * 4 + 2] = recs[i].width;
|
|
124
|
+
outRecs[i * 4 + 3] = recs[i].height;
|
|
125
|
+
}
|
|
126
|
+
RL_FREE(recs);
|
|
127
|
+
}
|
|
151
128
|
|
|
152
|
-
|
|
153
|
-
|
|
129
|
+
int imgSlot = imageAlloc();
|
|
130
|
+
if (imgSlot >= 0) {
|
|
131
|
+
imageRegistry[imgSlot] = atlas;
|
|
132
|
+
}
|
|
133
|
+
return imgSlot;
|
|
154
134
|
}
|
|
155
135
|
|
|
156
|
-
void
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
136
|
+
void MeasureTextCodepointsW(float* out, int fontId, const int* codepoints, int length, float fontSize, float spacing) {
|
|
137
|
+
if (fontId < 0 || fontId >= MAX_FONTS || !fontUsed[fontId]) {
|
|
138
|
+
out[0] = 0; out[1] = 0;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
Vector2 v = MeasureTextCodepoints(fontRegistry[fontId], codepoints, length, fontSize, spacing);
|
|
142
|
+
out[0] = v.x; out[1] = v.y;
|
|
163
143
|
}
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { getSymbols } from '../../symbols';
|
|
2
|
+
import { bufs as b, cstr, f, i } from '../../utils';
|
|
3
|
+
import type { Vec2, Rectangle, Texture2D, Font, Image, Color } from '../../types';
|
|
4
|
+
|
|
5
|
+
const r = () => getSymbols();
|
|
6
|
+
|
|
7
|
+
export class ImageModule {
|
|
8
|
+
static loadImage(fileName: string): Image {
|
|
9
|
+
return r().symbols.LoadImageW(cstr(fileName));
|
|
10
|
+
}
|
|
11
|
+
static loadImageRaw(
|
|
12
|
+
fileName: string,
|
|
13
|
+
width: number,
|
|
14
|
+
height: number,
|
|
15
|
+
format: number,
|
|
16
|
+
headerSize: number,
|
|
17
|
+
): Image {
|
|
18
|
+
return r().symbols.LoadImageRawW(cstr(fileName), i(width), i(height), i(format), i(headerSize));
|
|
19
|
+
}
|
|
20
|
+
static loadImageAnim(fileName: string): { image: Image; frames: number } {
|
|
21
|
+
r().symbols.LoadImageAnimW(b._imgAnimSlot, b._imgAnimFrames, cstr(fileName));
|
|
22
|
+
return { image: b._imgAnimSlot[0]!, frames: b._imgAnimFrames[0]! };
|
|
23
|
+
}
|
|
24
|
+
static loadImageFromMemory(fileType: string, fileData: Uint8Array, dataSize: number): Image {
|
|
25
|
+
return r().symbols.LoadImageFromMemoryW(cstr(fileType), fileData, i(dataSize));
|
|
26
|
+
}
|
|
27
|
+
static loadImageFromTexture(texture: Texture2D): Image {
|
|
28
|
+
return r().symbols.LoadImageFromTextureW(i(texture.id), i(texture.width), i(texture.height));
|
|
29
|
+
}
|
|
30
|
+
static loadImageFromScreen(): Image {
|
|
31
|
+
return r().symbols.LoadImageFromScreenW();
|
|
32
|
+
}
|
|
33
|
+
static isImageValid(image: Image): boolean {
|
|
34
|
+
return r().symbols.IsImageValidW(i(image));
|
|
35
|
+
}
|
|
36
|
+
static unloadImage(image: Image): void {
|
|
37
|
+
r().symbols.UnloadImageW(i(image));
|
|
38
|
+
}
|
|
39
|
+
static exportImage(image: Image, fileName: string): boolean {
|
|
40
|
+
return r().symbols.ExportImageW(i(image), cstr(fileName));
|
|
41
|
+
}
|
|
42
|
+
static exportImageAsCode(image: Image, fileName: string): boolean {
|
|
43
|
+
return r().symbols.ExportImageAsCodeW(i(image), cstr(fileName));
|
|
44
|
+
}
|
|
45
|
+
static genImageColor(width: number, height: number, color: Color): Image {
|
|
46
|
+
return r().symbols.GenImageColorW(i(width), i(height), i(color));
|
|
47
|
+
}
|
|
48
|
+
static genImageGradientLinear(
|
|
49
|
+
width: number,
|
|
50
|
+
height: number,
|
|
51
|
+
direction: number,
|
|
52
|
+
start: Color,
|
|
53
|
+
end: Color,
|
|
54
|
+
): Image {
|
|
55
|
+
return r().symbols.GenImageGradientLinearW(i(width), i(height), i(direction), i(start), i(end));
|
|
56
|
+
}
|
|
57
|
+
static genImageGradientRadial(
|
|
58
|
+
width: number,
|
|
59
|
+
height: number,
|
|
60
|
+
density: number,
|
|
61
|
+
inner: Color,
|
|
62
|
+
outer: Color,
|
|
63
|
+
): Image {
|
|
64
|
+
return r().symbols.GenImageGradientRadialW(i(width), i(height), f(density), i(inner), i(outer));
|
|
65
|
+
}
|
|
66
|
+
static genImageGradientSquare(
|
|
67
|
+
width: number,
|
|
68
|
+
height: number,
|
|
69
|
+
density: number,
|
|
70
|
+
inner: Color,
|
|
71
|
+
outer: Color,
|
|
72
|
+
): Image {
|
|
73
|
+
return r().symbols.GenImageGradientSquareW(i(width), i(height), f(density), i(inner), i(outer));
|
|
74
|
+
}
|
|
75
|
+
static genImageChecked(
|
|
76
|
+
width: number,
|
|
77
|
+
height: number,
|
|
78
|
+
checksX: number,
|
|
79
|
+
checksY: number,
|
|
80
|
+
col1: Color,
|
|
81
|
+
col2: Color,
|
|
82
|
+
): Image {
|
|
83
|
+
return r().symbols.GenImageCheckedW(
|
|
84
|
+
i(width),
|
|
85
|
+
i(height),
|
|
86
|
+
i(checksX),
|
|
87
|
+
i(checksY),
|
|
88
|
+
i(col1),
|
|
89
|
+
i(col2),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
static genImageWhiteNoise(width: number, height: number, factor: number): Image {
|
|
93
|
+
return r().symbols.GenImageWhiteNoiseW(i(width), i(height), f(factor));
|
|
94
|
+
}
|
|
95
|
+
static genImagePerlinNoise(
|
|
96
|
+
width: number,
|
|
97
|
+
height: number,
|
|
98
|
+
offsetX: number,
|
|
99
|
+
offsetY: number,
|
|
100
|
+
scale: number,
|
|
101
|
+
): Image {
|
|
102
|
+
return r().symbols.GenImagePerlinNoiseW(i(width), i(height), i(offsetX), i(offsetY), f(scale));
|
|
103
|
+
}
|
|
104
|
+
static genImageCellular(width: number, height: number, tileSize: number): Image {
|
|
105
|
+
return r().symbols.GenImageCellularW(i(width), i(height), i(tileSize));
|
|
106
|
+
}
|
|
107
|
+
static genImageText(width: number, height: number, text: string): Image {
|
|
108
|
+
return r().symbols.GenImageTextW(i(width), i(height), cstr(text));
|
|
109
|
+
}
|
|
110
|
+
static imageCopy(image: Image): Image {
|
|
111
|
+
return r().symbols.ImageCopyW(i(image));
|
|
112
|
+
}
|
|
113
|
+
static imageFromImage(image: Image, rec: Rectangle): Image {
|
|
114
|
+
return r().symbols.ImageFromImageW(i(image), i(rec.x), i(rec.y), i(rec.width), i(rec.height));
|
|
115
|
+
}
|
|
116
|
+
static imageFromChannel(image: Image, selectedChannel: number): Image {
|
|
117
|
+
return r().symbols.ImageFromChannelW(i(image), i(selectedChannel));
|
|
118
|
+
}
|
|
119
|
+
static imageText(text: string, fontSize: number, color: Color): Image {
|
|
120
|
+
return r().symbols.ImageTextW(cstr(text), i(fontSize), i(color));
|
|
121
|
+
}
|
|
122
|
+
static imageTextEx(
|
|
123
|
+
font: Font,
|
|
124
|
+
text: string,
|
|
125
|
+
fontSize: number,
|
|
126
|
+
spacing: number,
|
|
127
|
+
tint: Color,
|
|
128
|
+
): Image {
|
|
129
|
+
return r().symbols.ImageTextExW(i(font), cstr(text), i(fontSize), f(spacing), i(tint));
|
|
130
|
+
}
|
|
131
|
+
static imageFormat(image: Image, newFormat: number): void {
|
|
132
|
+
r().symbols.ImageFormatW(i(image), i(newFormat));
|
|
133
|
+
}
|
|
134
|
+
static imageCrop(image: Image, rec: Rectangle): void {
|
|
135
|
+
r().symbols.ImageCropW(i(image), i(rec.x), i(rec.y), i(rec.width), i(rec.height));
|
|
136
|
+
}
|
|
137
|
+
static imageAlphaCrop(image: Image, threshold: number): void {
|
|
138
|
+
r().symbols.ImageAlphaCropW(i(image), f(threshold));
|
|
139
|
+
}
|
|
140
|
+
static imageAlphaClear(image: Image, color: Color, threshold: number): void {
|
|
141
|
+
r().symbols.ImageAlphaClearW(i(image), i(color), f(threshold));
|
|
142
|
+
}
|
|
143
|
+
static imageAlphaMask(image: Image, alphaMask: Image): void {
|
|
144
|
+
r().symbols.ImageAlphaMaskW(i(image), i(alphaMask));
|
|
145
|
+
}
|
|
146
|
+
static imageAlphaPremultiply(image: Image): void {
|
|
147
|
+
r().symbols.ImageAlphaPremultiplyW(i(image));
|
|
148
|
+
}
|
|
149
|
+
static imageBlurGaussian(image: Image, blurSize: number): void {
|
|
150
|
+
r().symbols.ImageBlurGaussianW(i(image), i(blurSize));
|
|
151
|
+
}
|
|
152
|
+
static imageResize(image: Image, newWidth: number, newHeight: number): void {
|
|
153
|
+
r().symbols.ImageResizeW(i(image), i(newWidth), i(newHeight));
|
|
154
|
+
}
|
|
155
|
+
static imageResizeNN(image: Image, newWidth: number, newHeight: number): void {
|
|
156
|
+
r().symbols.ImageResizeNNW(i(image), i(newWidth), i(newHeight));
|
|
157
|
+
}
|
|
158
|
+
static imageResizeCanvas(
|
|
159
|
+
image: Image,
|
|
160
|
+
newWidth: number,
|
|
161
|
+
newHeight: number,
|
|
162
|
+
offsetX: number,
|
|
163
|
+
offsetY: number,
|
|
164
|
+
fill: Color,
|
|
165
|
+
): void {
|
|
166
|
+
r().symbols.ImageResizeCanvasW(
|
|
167
|
+
i(image),
|
|
168
|
+
i(newWidth),
|
|
169
|
+
i(newHeight),
|
|
170
|
+
i(offsetX),
|
|
171
|
+
i(offsetY),
|
|
172
|
+
i(fill),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
static imageMipmaps(image: Image): void {
|
|
176
|
+
r().symbols.ImageMipmapsW(i(image));
|
|
177
|
+
}
|
|
178
|
+
static imageDither(image: Image, rBpp: number, gBpp: number, bBpp: number, aBpp: number): void {
|
|
179
|
+
r().symbols.ImageDitherW(i(image), i(rBpp), i(gBpp), i(bBpp), i(aBpp));
|
|
180
|
+
}
|
|
181
|
+
static imageFlipVertical(image: Image): void {
|
|
182
|
+
r().symbols.ImageFlipVerticalW(i(image));
|
|
183
|
+
}
|
|
184
|
+
static imageFlipHorizontal(image: Image): void {
|
|
185
|
+
r().symbols.ImageFlipHorizontalW(i(image));
|
|
186
|
+
}
|
|
187
|
+
static imageRotate(image: Image, degrees: number): void {
|
|
188
|
+
r().symbols.ImageRotateW(i(image), f(degrees));
|
|
189
|
+
}
|
|
190
|
+
static imageRotateCW(image: Image): void {
|
|
191
|
+
r().symbols.ImageRotateCWW(i(image));
|
|
192
|
+
}
|
|
193
|
+
static imageRotateCCW(image: Image): void {
|
|
194
|
+
r().symbols.ImageRotateCCWW(i(image));
|
|
195
|
+
}
|
|
196
|
+
static imageColorTint(image: Image, color: Color): void {
|
|
197
|
+
r().symbols.ImageColorTintW(i(image), i(color));
|
|
198
|
+
}
|
|
199
|
+
static imageColorInvert(image: Image): void {
|
|
200
|
+
r().symbols.ImageColorInvertW(i(image));
|
|
201
|
+
}
|
|
202
|
+
static imageColorGrayscale(image: Image): void {
|
|
203
|
+
r().symbols.ImageColorGrayscaleW(i(image));
|
|
204
|
+
}
|
|
205
|
+
static imageColorContrast(image: Image, contrast: number): void {
|
|
206
|
+
r().symbols.ImageColorContrastW(i(image), f(contrast));
|
|
207
|
+
}
|
|
208
|
+
static imageColorBrightness(image: Image, brightness: number): void {
|
|
209
|
+
r().symbols.ImageColorBrightnessW(i(image), i(brightness));
|
|
210
|
+
}
|
|
211
|
+
static imageColorReplace(image: Image, color: Color, replace: Color): void {
|
|
212
|
+
r().symbols.ImageColorReplaceW(i(image), i(color), i(replace));
|
|
213
|
+
}
|
|
214
|
+
static getImageAlphaBorder(image: Image, threshold: number): Rectangle {
|
|
215
|
+
r().symbols.GetImageAlphaBorderW(b._recBuf, i(image), f(threshold));
|
|
216
|
+
return {
|
|
217
|
+
x: b._recBuf[0]!,
|
|
218
|
+
y: b._recBuf[1]!,
|
|
219
|
+
width: b._recBuf[2]!,
|
|
220
|
+
height: b._recBuf[3]!,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
static getImageColor(image: Image, x: number, y: number): Color {
|
|
224
|
+
return r().symbols.GetImageColorW(i(image), i(x), i(y));
|
|
225
|
+
}
|
|
226
|
+
static imageClearBackground(dst: Image, color: Color): void {
|
|
227
|
+
r().symbols.ImageClearBackgroundW(i(dst), i(color));
|
|
228
|
+
}
|
|
229
|
+
static imageDrawPixel(dst: Image, posX: number, posY: number, color: Color): void {
|
|
230
|
+
r().symbols.ImageDrawPixelW(i(dst), i(posX), i(posY), i(color));
|
|
231
|
+
}
|
|
232
|
+
static imageDrawPixelV(dst: Image, position: Vec2, color: Color): void {
|
|
233
|
+
r().symbols.ImageDrawPixelVW(i(dst), i(position.x), i(position.y), i(color));
|
|
234
|
+
}
|
|
235
|
+
static imageDrawLine(
|
|
236
|
+
dst: Image,
|
|
237
|
+
startX: number,
|
|
238
|
+
startY: number,
|
|
239
|
+
endX: number,
|
|
240
|
+
endY: number,
|
|
241
|
+
color: Color,
|
|
242
|
+
): void {
|
|
243
|
+
r().symbols.ImageDrawLineW(i(dst), i(startX), i(startY), i(endX), i(endY), i(color));
|
|
244
|
+
}
|
|
245
|
+
static imageDrawLineV(dst: Image, start: Vec2, end: Vec2, color: Color): void {
|
|
246
|
+
r().symbols.ImageDrawLineVW(i(dst), i(start.x), i(start.y), i(end.x), i(end.y), i(color));
|
|
247
|
+
}
|
|
248
|
+
static imageDrawLineEx(dst: Image, start: Vec2, end: Vec2, thick: number, color: Color): void {
|
|
249
|
+
r().symbols.ImageDrawLineExW(
|
|
250
|
+
i(dst),
|
|
251
|
+
i(start.x),
|
|
252
|
+
i(start.y),
|
|
253
|
+
i(end.x),
|
|
254
|
+
i(end.y),
|
|
255
|
+
i(thick),
|
|
256
|
+
i(color),
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
static imageDrawCircle(
|
|
260
|
+
dst: Image,
|
|
261
|
+
centerX: number,
|
|
262
|
+
centerY: number,
|
|
263
|
+
radius: number,
|
|
264
|
+
color: Color,
|
|
265
|
+
): void {
|
|
266
|
+
r().symbols.ImageDrawCircleW(i(dst), i(centerX), i(centerY), i(radius), i(color));
|
|
267
|
+
}
|
|
268
|
+
static imageDrawCircleV(dst: Image, center: Vec2, radius: number, color: Color): void {
|
|
269
|
+
r().symbols.ImageDrawCircleVW(i(dst), i(center.x), i(center.y), i(radius), i(color));
|
|
270
|
+
}
|
|
271
|
+
static imageDrawCircleLines(
|
|
272
|
+
dst: Image,
|
|
273
|
+
centerX: number,
|
|
274
|
+
centerY: number,
|
|
275
|
+
radius: number,
|
|
276
|
+
color: Color,
|
|
277
|
+
): void {
|
|
278
|
+
r().symbols.ImageDrawCircleLinesW(i(dst), i(centerX), i(centerY), i(radius), i(color));
|
|
279
|
+
}
|
|
280
|
+
static imageDrawCircleLinesV(dst: Image, center: Vec2, radius: number, color: Color): void {
|
|
281
|
+
r().symbols.ImageDrawCircleLinesVW(i(dst), i(center.x), i(center.y), i(radius), i(color));
|
|
282
|
+
}
|
|
283
|
+
static imageDrawRectangle(
|
|
284
|
+
dst: Image,
|
|
285
|
+
posX: number,
|
|
286
|
+
posY: number,
|
|
287
|
+
w: number,
|
|
288
|
+
h: number,
|
|
289
|
+
color: Color,
|
|
290
|
+
): void {
|
|
291
|
+
r().symbols.ImageDrawRectangleW(i(dst), i(posX), i(posY), i(w), i(h), i(color));
|
|
292
|
+
}
|
|
293
|
+
static imageDrawRectangleV(dst: Image, position: Vec2, size: Vec2, color: Color): void {
|
|
294
|
+
r().symbols.ImageDrawRectangleVW(
|
|
295
|
+
i(dst),
|
|
296
|
+
i(position.x),
|
|
297
|
+
i(position.y),
|
|
298
|
+
i(size.x),
|
|
299
|
+
i(size.y),
|
|
300
|
+
i(color),
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
static imageDrawRectangleRec(dst: Image, rec: Rectangle, color: Color): void {
|
|
304
|
+
r().symbols.ImageDrawRectangleRecW(
|
|
305
|
+
i(dst),
|
|
306
|
+
i(rec.x),
|
|
307
|
+
i(rec.y),
|
|
308
|
+
i(rec.width),
|
|
309
|
+
i(rec.height),
|
|
310
|
+
i(color),
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
static imageDrawRectangleLines(dst: Image, rec: Rectangle, thick: number, color: Color): void {
|
|
314
|
+
r().symbols.ImageDrawRectangleLinesW(
|
|
315
|
+
i(dst),
|
|
316
|
+
i(rec.x),
|
|
317
|
+
i(rec.y),
|
|
318
|
+
i(rec.width),
|
|
319
|
+
i(rec.height),
|
|
320
|
+
i(thick),
|
|
321
|
+
i(color),
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
static imageDrawTriangle(dst: Image, v1: Vec2, v2: Vec2, v3: Vec2, color: Color): void {
|
|
325
|
+
r().symbols.ImageDrawTriangleW(
|
|
326
|
+
i(dst),
|
|
327
|
+
i(v1.x),
|
|
328
|
+
i(v1.y),
|
|
329
|
+
i(v2.x),
|
|
330
|
+
i(v2.y),
|
|
331
|
+
i(v3.x),
|
|
332
|
+
i(v3.y),
|
|
333
|
+
i(color),
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
static imageDrawTriangleEx(
|
|
337
|
+
dst: Image,
|
|
338
|
+
v1: Vec2,
|
|
339
|
+
v2: Vec2,
|
|
340
|
+
v3: Vec2,
|
|
341
|
+
c1: Color,
|
|
342
|
+
c2: Color,
|
|
343
|
+
c3: Color,
|
|
344
|
+
): void {
|
|
345
|
+
r().symbols.ImageDrawTriangleExW(
|
|
346
|
+
i(dst),
|
|
347
|
+
i(v1.x),
|
|
348
|
+
i(v1.y),
|
|
349
|
+
i(v2.x),
|
|
350
|
+
i(v2.y),
|
|
351
|
+
i(v3.x),
|
|
352
|
+
i(v3.y),
|
|
353
|
+
i(c1),
|
|
354
|
+
i(c2),
|
|
355
|
+
i(c3),
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
static imageDrawTriangleLines(dst: Image, v1: Vec2, v2: Vec2, v3: Vec2, color: Color): void {
|
|
359
|
+
r().symbols.ImageDrawTriangleLinesW(
|
|
360
|
+
i(dst),
|
|
361
|
+
i(v1.x),
|
|
362
|
+
i(v1.y),
|
|
363
|
+
i(v2.x),
|
|
364
|
+
i(v2.y),
|
|
365
|
+
i(v3.x),
|
|
366
|
+
i(v3.y),
|
|
367
|
+
i(color),
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
static imageDrawTriangleFan(dst: Image, points: Float32Array, color: Color): void {
|
|
371
|
+
r().symbols.ImageDrawTriangleFanW(i(dst), points, i(points.length / 2), i(color));
|
|
372
|
+
}
|
|
373
|
+
static imageDrawTriangleStrip(dst: Image, points: Float32Array, color: Color): void {
|
|
374
|
+
r().symbols.ImageDrawTriangleStripW(i(dst), points, i(points.length / 2), i(color));
|
|
375
|
+
}
|
|
376
|
+
static imageDraw(
|
|
377
|
+
dst: Image,
|
|
378
|
+
src: Image,
|
|
379
|
+
srcRec: Rectangle,
|
|
380
|
+
dstRec: Rectangle,
|
|
381
|
+
tint: Color,
|
|
382
|
+
): void {
|
|
383
|
+
r().symbols.ImageDrawW(
|
|
384
|
+
i(dst),
|
|
385
|
+
i(src),
|
|
386
|
+
i(srcRec.x),
|
|
387
|
+
i(srcRec.y),
|
|
388
|
+
i(srcRec.width),
|
|
389
|
+
i(srcRec.height),
|
|
390
|
+
i(dstRec.x),
|
|
391
|
+
i(dstRec.y),
|
|
392
|
+
i(dstRec.width),
|
|
393
|
+
i(dstRec.height),
|
|
394
|
+
i(tint),
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
static imageDrawText(
|
|
398
|
+
dst: Image,
|
|
399
|
+
text: string,
|
|
400
|
+
posX: number,
|
|
401
|
+
posY: number,
|
|
402
|
+
fontSize: number,
|
|
403
|
+
color: Color,
|
|
404
|
+
): void {
|
|
405
|
+
r().symbols.ImageDrawTextW(i(dst), cstr(text), i(posX), i(posY), i(fontSize), i(color));
|
|
406
|
+
}
|
|
407
|
+
static imageDrawTextEx(
|
|
408
|
+
dst: Image,
|
|
409
|
+
font: Font,
|
|
410
|
+
text: string,
|
|
411
|
+
position: Vec2,
|
|
412
|
+
fontSize: number,
|
|
413
|
+
spacing: number,
|
|
414
|
+
tint: Color,
|
|
415
|
+
): void {
|
|
416
|
+
r().symbols.ImageDrawTextExW(
|
|
417
|
+
i(dst),
|
|
418
|
+
i(font),
|
|
419
|
+
cstr(text),
|
|
420
|
+
i(position.x),
|
|
421
|
+
i(position.y),
|
|
422
|
+
i(fontSize),
|
|
423
|
+
f(spacing),
|
|
424
|
+
i(tint),
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
static imageToPOT(image: Image, fill: number): void {
|
|
428
|
+
r().symbols.ImageToPOTW(i(image), i(fill));
|
|
429
|
+
}
|
|
430
|
+
static imageKernelConvolution(image: Image, kernel: Float32Array): void {
|
|
431
|
+
r().symbols.ImageKernelConvolutionW(i(image), kernel, i(kernel.length));
|
|
432
|
+
}
|
|
433
|
+
static unloadImageColors(ptr: number): void {
|
|
434
|
+
r().symbols.UnloadImageColorsW(ptr as unknown as Buffer);
|
|
435
|
+
}
|
|
436
|
+
static unloadImagePalette(ptr: number): void {
|
|
437
|
+
r().symbols.UnloadImagePaletteW(ptr as unknown as Buffer);
|
|
438
|
+
}
|
|
439
|
+
static loadImageAnimFromMemory(
|
|
440
|
+
fileType: string,
|
|
441
|
+
data: Buffer | Uint8Array,
|
|
442
|
+
frames?: Int32Array,
|
|
443
|
+
): Image {
|
|
444
|
+
return r().symbols.LoadImageAnimFromMemoryW(
|
|
445
|
+
cstr(fileType),
|
|
446
|
+
data,
|
|
447
|
+
i(data.length),
|
|
448
|
+
frames ?? new Int32Array(1),
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FFIType } from
|
|
1
|
+
import { FFIType } from 'bun:ffi';
|
|
2
2
|
const { i32, cstring, bool, ptr } = FFIType;
|
|
3
3
|
|
|
4
4
|
export const imageSymbols = {
|
|
@@ -14,22 +14,22 @@ export const imageSymbols = {
|
|
|
14
14
|
ExportImageAsCodeW: { args: [i32, cstring], returns: bool },
|
|
15
15
|
GenImageColorW: { args: [i32, i32, i32], returns: i32 },
|
|
16
16
|
GenImageGradientLinearW: { args: [i32, i32, i32, i32, i32], returns: i32 },
|
|
17
|
-
GenImageGradientRadialW: { args: [i32, i32,
|
|
18
|
-
GenImageGradientSquareW: { args: [i32, i32,
|
|
17
|
+
GenImageGradientRadialW: { args: [i32, i32, FFIType.f32, i32, i32], returns: i32 },
|
|
18
|
+
GenImageGradientSquareW: { args: [i32, i32, FFIType.f32, i32, i32], returns: i32 },
|
|
19
19
|
GenImageCheckedW: { args: [i32, i32, i32, i32, i32, i32], returns: i32 },
|
|
20
|
-
GenImageWhiteNoiseW: { args: [i32, i32,
|
|
21
|
-
GenImagePerlinNoiseW: { args: [i32, i32, i32, i32,
|
|
20
|
+
GenImageWhiteNoiseW: { args: [i32, i32, FFIType.f32], returns: i32 },
|
|
21
|
+
GenImagePerlinNoiseW: { args: [i32, i32, i32, i32, FFIType.f32], returns: i32 },
|
|
22
22
|
GenImageCellularW: { args: [i32, i32, i32], returns: i32 },
|
|
23
23
|
GenImageTextW: { args: [i32, i32, cstring], returns: i32 },
|
|
24
24
|
ImageCopyW: { args: [i32], returns: i32 },
|
|
25
25
|
ImageFromImageW: { args: [i32, i32, i32, i32, i32], returns: i32 },
|
|
26
26
|
ImageFromChannelW: { args: [i32, i32], returns: i32 },
|
|
27
27
|
ImageTextW: { args: [cstring, i32, i32], returns: i32 },
|
|
28
|
-
ImageTextExW: { args: [i32, cstring, i32,
|
|
28
|
+
ImageTextExW: { args: [i32, cstring, i32, FFIType.f32, i32], returns: i32 },
|
|
29
29
|
ImageFormatW: { args: [i32, i32], returns: FFIType.void },
|
|
30
30
|
ImageCropW: { args: [i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
31
|
-
ImageAlphaCropW: { args: [i32,
|
|
32
|
-
ImageAlphaClearW: { args: [i32, i32,
|
|
31
|
+
ImageAlphaCropW: { args: [i32, FFIType.f32], returns: FFIType.void },
|
|
32
|
+
ImageAlphaClearW: { args: [i32, i32, FFIType.f32], returns: FFIType.void },
|
|
33
33
|
ImageAlphaMaskW: { args: [i32, i32], returns: FFIType.void },
|
|
34
34
|
ImageAlphaPremultiplyW: { args: [i32], returns: FFIType.void },
|
|
35
35
|
ImageBlurGaussianW: { args: [i32, i32], returns: FFIType.void },
|
|
@@ -40,16 +40,16 @@ export const imageSymbols = {
|
|
|
40
40
|
ImageDitherW: { args: [i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
41
41
|
ImageFlipVerticalW: { args: [i32], returns: FFIType.void },
|
|
42
42
|
ImageFlipHorizontalW: { args: [i32], returns: FFIType.void },
|
|
43
|
-
ImageRotateW: { args: [i32,
|
|
43
|
+
ImageRotateW: { args: [i32, FFIType.f32], returns: FFIType.void },
|
|
44
44
|
ImageRotateCWW: { args: [i32], returns: FFIType.void },
|
|
45
45
|
ImageRotateCCWW: { args: [i32], returns: FFIType.void },
|
|
46
46
|
ImageColorTintW: { args: [i32, i32], returns: FFIType.void },
|
|
47
47
|
ImageColorInvertW: { args: [i32], returns: FFIType.void },
|
|
48
48
|
ImageColorGrayscaleW: { args: [i32], returns: FFIType.void },
|
|
49
|
-
ImageColorContrastW: { args: [i32,
|
|
49
|
+
ImageColorContrastW: { args: [i32, FFIType.f32], returns: FFIType.void },
|
|
50
50
|
ImageColorBrightnessW: { args: [i32, i32], returns: FFIType.void },
|
|
51
51
|
ImageColorReplaceW: { args: [i32, i32, i32], returns: FFIType.void },
|
|
52
|
-
GetImageAlphaBorderW: { args: [ptr, i32,
|
|
52
|
+
GetImageAlphaBorderW: { args: [ptr, i32, FFIType.f32], returns: FFIType.void },
|
|
53
53
|
GetImageColorW: { args: [i32, i32, i32], returns: i32 },
|
|
54
54
|
ImageClearBackgroundW: { args: [i32, i32], returns: FFIType.void },
|
|
55
55
|
ImageDrawPixelW: { args: [i32, i32, i32, i32], returns: FFIType.void },
|
|
@@ -81,7 +81,10 @@ export const imageSymbols = {
|
|
|
81
81
|
returns: FFIType.void,
|
|
82
82
|
},
|
|
83
83
|
ImageDrawTextW: { args: [i32, cstring, i32, i32, i32, i32], returns: FFIType.void },
|
|
84
|
-
ImageDrawTextExW: {
|
|
84
|
+
ImageDrawTextExW: {
|
|
85
|
+
args: [i32, i32, cstring, i32, i32, i32, FFIType.f32, i32],
|
|
86
|
+
returns: FFIType.void,
|
|
87
|
+
},
|
|
85
88
|
ImageToPOTW: { args: [i32, i32], returns: FFIType.void },
|
|
86
89
|
ImageKernelConvolutionW: { args: [i32, ptr, i32], returns: FFIType.void },
|
|
87
90
|
UnloadImageColorsW: { args: [ptr], returns: FFIType.void },
|