-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimage.mbt
More file actions
257 lines (230 loc) · 5.93 KB
/
image.mbt
File metadata and controls
257 lines (230 loc) · 5.93 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
///|
struct Image(@ffi.Image)
///|
/// Unload image from CPU memory (RAM).
#as_free_fn(unload_image)
pub fn Image::unload(self : Image) -> Unit {
@ffi.unload_image(self.0)
}
///|
/// Check if an image is valid (data and parameters).
#as_free_fn(is_image_valid)
pub fn Image::is_valid(self : Image) -> Bool {
@ffi.is_image_valid(self.0)
}
///|
/// Create an image duplicate (useful for transformations).
#as_free_fn(image_copy)
pub fn Image::copy(self : Image) -> Image {
@ffi.image_copy(self.0)
}
///|
/// Create an image from a selected channel of another image (GRAYSCALE).
#as_free_fn(image_from_channel)
pub fn Image::from_channel(self : Image, selected_channel : Int) -> Image {
@ffi.image_from_channel(self.0, selected_channel)
}
///|
/// Get image width.
#as_free_fn(get_image_width)
#as_free_fn(image_width, deprecated="Use @raylib.Image::width() instead")
pub fn Image::width(self : Image) -> Int {
@ffi.image_width(self.0)
}
///|
/// Get image height.
#as_free_fn(get_image_height)
#as_free_fn(image_height, deprecated="Use @raylib.Image::height() instead")
pub fn Image::height(self : Image) -> Int {
@ffi.image_height(self.0)
}
///|
/// Get image mipmap levels.
#as_free_fn(get_image_mipmaps)
pub fn Image::mipmaps(self : Image) -> Int {
@ffi.image_get_mipmaps(self.0)
}
///|
/// Get image data format.
#as_free_fn(get_image_format)
pub fn Image::format(self : Image) -> Int {
@ffi.image_get_format(self.0)
}
///|
/// Load image from GPU texture data.
#as_free_fn(load_image_from_texture)
pub fn Image::load_from_texture(texture : Texture) -> Image {
@ffi.load_image_from_texture(texture.0)
}
///|
/// Load image from screen buffer (screenshot).
#as_free_fn(load_image_from_screen)
pub fn Image::load_from_screen() -> Image {
@ffi.load_image_from_screen()
}
///|
/// Load color data from image as a Color array (RGBA - 32bit).
#as_free_fn(load_image_colors)
pub fn Image::load_colors(self : Image) -> Bytes {
@ffi.load_image_colors(self.0)
}
///|
/// Load colors palette from image as a Color array (RGBA - 32bit).
#as_free_fn(load_image_palette)
pub fn Image::load_palette(self : Image, max_palette_size : Int) -> Bytes {
@ffi.load_image_palette(self.0, max_palette_size)
}
///|
/// Generate image: white noise.
#as_free_fn(gen_image_white_noise)
pub fn Image::gen_white_noise(
width : Int,
height : Int,
factor : Float,
) -> Image {
@ffi.gen_image_white_noise(width, height, factor)
}
///|
/// Generate image: perlin noise.
#as_free_fn(gen_image_perlin_noise)
pub fn Image::gen_perlin_noise(
width : Int,
height : Int,
offset_x : Int,
offset_y : Int,
scale : Float,
) -> Image {
@ffi.gen_image_perlin_noise(width, height, offset_x, offset_y, scale)
}
///|
/// Generate image: cellular algorithm, bigger tileSize means bigger cells.
#as_free_fn(gen_image_cellular)
pub fn Image::gen_cellular(width : Int, height : Int, tile_size : Int) -> Image {
@ffi.gen_image_cellular(width, height, tile_size)
}
///|
/// Load texture from image data.
#as_free_fn(load_texture_from_image)
pub fn Image::to_texture(self : Image) -> Texture {
@ffi.load_texture_from_image(self.0)
}
///|
/// Load cubemap from image, multiple image cubemap layouts supported.
#as_free_fn(load_texture_cubemap)
pub fn Image::to_texture_cubemap(self : Image, layout : Int) -> Texture {
@ffi.load_texture_cubemap(self.0, layout)
}
///|
/// Load image from file into CPU memory (RAM).
#as_free_fn(load_image)
pub fn Image::load(file_name : String) -> Image {
@ffi.load_image(@utf8.encode(file_name))
}
///|
/// Generate image: plain color.
#as_free_fn(gen_image_color)
pub fn Image::gen_color(width : Int, height : Int, color : Color) -> Image {
@ffi.gen_image_color(width, height, color.to_bytes())
}
///|
/// Generate image: checked.
#as_free_fn(gen_image_checked)
pub fn Image::gen_checked(
width : Int,
height : Int,
checks_x : Int,
checks_y : Int,
col1 : Color,
col2 : Color,
) -> Image {
@ffi.gen_image_checked(
width,
height,
checks_x,
checks_y,
col1.to_bytes(),
col2.to_bytes(),
)
}
///|
/// Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient.
#as_free_fn(gen_image_gradient_linear)
pub fn Image::gen_gradient_linear(
width : Int,
height : Int,
direction : Int,
start : Color,
end_ : Color,
) -> Image {
@ffi.gen_image_gradient_linear(
width,
height,
direction,
start.to_bytes(),
end_.to_bytes(),
)
}
///|
/// Generate image: radial gradient.
#as_free_fn(gen_image_gradient_radial)
pub fn Image::gen_gradient_radial(
width : Int,
height : Int,
density : Float,
inner : Color,
outer : Color,
) -> Image {
@ffi.gen_image_gradient_radial(
width,
height,
density,
inner.to_bytes(),
outer.to_bytes(),
)
}
///|
/// Generate image: square gradient.
#as_free_fn(gen_image_gradient_square)
pub fn Image::gen_gradient_square(
width : Int,
height : Int,
density : Float,
inner : Color,
outer : Color,
) -> Image {
@ffi.gen_image_gradient_square(
width,
height,
density,
inner.to_bytes(),
outer.to_bytes(),
)
}
///|
/// Generate image: grayscale image from text data.
#as_free_fn(gen_image_text)
pub fn Image::gen_text(width : Int, height : Int, text : String) -> Image {
@ffi.gen_image_text(width, height, @utf8.encode(text))
}
///|
/// Load image from memory buffer, fileType refers to extension: i.e. '.png'.
#as_free_fn(load_image_from_memory)
pub fn Image::load_from_memory(
file_type : String,
file_data : Bytes,
data_size : Int,
) -> Image {
@ffi.load_image_from_memory(@utf8.encode(file_type), file_data, data_size)
}
///|
/// Export image data to file, returns true on success.
#as_free_fn(export_image)
pub fn Image::export_(self : Image, file_name : String) -> Bool {
@ffi.export_image(self.0, @utf8.encode(file_name))
}
///|
/// Create an image from another image piece.
#as_free_fn(image_from_image)
pub fn Image::from_image(self : Image, rec : Rectangle) -> Image {
@ffi.image_from_image(self.0, rec.to_bytes())
}