1use crate::{ext::image::ImageType, utils::array_from_c};
2use raylib_ffi::{enums::*, *};
3use std::{
4 f32::consts::PI,
5 ffi::c_void,
6 fmt::{Debug, Display},
7 path::Path,
8};
9
10#[derive(Clone, Copy, Debug, Default)]
11pub(crate) struct RtexturesImpl;
12
13impl RtexturesImpl {
15 pub fn __load_image(filename: impl Display) -> Result<Image, String> {
18 unsafe {
19 let image = LoadImage(rl_str!(filename));
20 if image.data.is_null() {
21 if Path::new(&format!("{}", filename)).exists() {
22 Err(format!("couldn't load image from {}", filename))
23 } else {
24 Err(format!(
25 "couldn't load image from {}, file not found",
26 filename
27 ))
28 }
29 } else {
30 Ok(image)
31 }
32 }
33 }
34
35 pub fn __load_image_raw(
36 filename: impl Display,
37 width: i32,
38 height: i32,
39 format: impl Into<usize>,
40 header_size: i32,
41 ) -> Result<Image, String> {
42 unsafe {
43 let image = LoadImageRaw(
44 rl_str!(filename),
45 width,
46 height,
47 format.into() as i32,
48 header_size,
49 );
50 if image.data.is_null() {
51 if Path::new(&format!("{}", filename)).exists() {
52 Err(format!("couldn't load image from {}", filename))
53 } else {
54 Err(format!(
55 "couldn't load image from {}, file not found",
56 filename
57 ))
58 }
59 } else {
60 Ok(image)
61 }
62 }
63 }
64
65 pub fn __load_image_svg(
66 filename_or_string: impl Display,
67 width: i32,
68 height: i32,
69 ) -> Result<Image, String> {
70 unsafe {
71 let image = LoadImageSvg(rl_str!(filename_or_string), width, height);
72 if image.data.is_null() {
73 Err(format!("couldn't load image from {}", filename_or_string))
74 } else {
75 Ok(image)
76 }
77 }
78 }
79
80 pub fn __load_image_anim(filename: impl Display) -> Result<(Image, i32), String> {
81 unsafe {
82 let mut frames: i32 = 0;
83 let image = LoadImageAnim(rl_str!(filename), &mut frames);
84 if image.data.is_null() {
85 if Path::new(&format!("{}", filename)).exists() {
86 Err(format!("couldn't load image from {}", filename))
87 } else {
88 Err(format!(
89 "couldn't load image from {}, file not found",
90 filename
91 ))
92 }
93 } else {
94 Ok((image, frames))
95 }
96 }
97 }
98
99 pub fn __load_image_from_memory(tpe: impl Display, data: &[u8]) -> Result<Image, String> {
101 unsafe {
102 let size = data.len() as i32;
103 let mut data = data.to_vec();
104 let data = data.as_mut_ptr();
105 let image = LoadImageFromMemory(rl_str!(tpe), data, size);
106 if image.data.is_null() {
107 Err("failed to load image from memory".to_owned())
108 } else {
109 Ok(image)
110 }
111 }
112 }
113
114 pub fn __load_image_from_texture(texture: Texture2D) -> Image {
115 unsafe { LoadImageFromTexture(texture) }
116 }
117
118 pub fn __load_image_from_screen() -> Image {
119 unsafe { LoadImageFromScreen() }
120 }
121
122 pub fn __is_image_ready(image: Image) -> bool {
123 unsafe { IsImageReady(image) }
124 }
125
126 pub fn __unload_image(image: Image) {
127 unsafe { UnloadImage(image) }
128 }
129
130 pub fn __export_image(image: Image, filename: impl Display) -> bool {
131 unsafe { ExportImage(image, rl_str!(filename)) }
132 }
133
134 pub fn __export_image_to_memory(image: Image, tpe: impl Display) -> Result<Vec<u8>, String> {
135 unsafe {
136 let mut size: i32 = 0;
137 let raw = ExportImageToMemory(image, rl_str!(tpe), &mut size);
138 array_from_c(raw, size as usize, || "failed to export image".to_owned())
139 }
140 }
141
142 pub fn __export_image_as_code(image: Image, filename: impl Display) -> bool {
143 unsafe { ExportImageAsCode(image, rl_str!(filename)) }
144 }
145
146 pub fn __gen_image_color(width: i32, height: i32, color: Color) -> Image {
149 unsafe { GenImageColor(width, height, color) }
150 }
151
152 pub fn __gen_image_gradient_linear(
153 width: i32,
154 height: i32,
155 angle: f32,
156 start: Color,
157 end: Color,
158 ) -> Image {
159 unsafe {
160 let direction = (angle * 180.0 / PI) as i32;
161 GenImageGradientLinear(width, height, direction, start, end)
162 }
163 }
164
165 pub fn __gen_image_gradient_radial(
166 width: i32,
167 height: i32,
168 density: f32,
169 inner: Color,
170 outer: Color,
171 ) -> Image {
172 unsafe { GenImageGradientRadial(width, height, density, inner, outer) }
173 }
174
175 pub fn __gen_image_gradient_square(
176 width: i32,
177 height: i32,
178 density: f32,
179 inner: Color,
180 outer: Color,
181 ) -> Image {
182 unsafe { GenImageGradientSquare(width, height, density, inner, outer) }
183 }
184
185 pub fn __gen_image_checked(
186 width: i32,
187 height: i32,
188 checks_x: i32,
189 checks_y: i32,
190 col1: Color,
191 col2: Color,
192 ) -> Image {
193 unsafe { GenImageChecked(width, height, checks_x, checks_y, col1, col2) }
194 }
195
196 pub fn __gen_image_white_noise(width: i32, height: i32, factor: f32) -> Image {
197 unsafe { GenImageWhiteNoise(width, height, factor) }
198 }
199
200 pub fn __gen_image_perlin_noise(
201 width: i32,
202 height: i32,
203 offset_x: i32,
204 offset_y: i32,
205 scale: f32,
206 ) -> Image {
207 unsafe { GenImagePerlinNoise(width, height, offset_x, offset_y, scale) }
208 }
209
210 pub fn __gen_image_cellular(width: i32, height: i32, tile_size: i32) -> Image {
211 unsafe { GenImageCellular(width, height, tile_size) }
212 }
213
214 pub fn __gen_image_text(width: i32, height: i32, text: impl Display) -> Image {
215 unsafe { GenImageText(width, height, rl_str!(text)) }
216 }
217
218 pub fn __image_copy(image: Image) -> Image {
221 unsafe { ImageCopy(image) }
222 }
223
224 pub fn __image_from_image(image: Image, rec: Rectangle) -> Image {
225 unsafe { ImageFromImage(image, rec) }
226 }
227
228 pub fn __image_text(text: impl Display, font_size: i32, color: Color) -> Image {
229 unsafe { ImageText(rl_str!(text), font_size, color) }
230 }
231
232 pub fn __image_text_ex(
233 font: Font,
234 text: impl Display,
235 font_size: f32,
236 spacing: f32,
237 tint: Color,
238 ) -> Image {
239 unsafe { ImageTextEx(font, rl_str!(text), font_size, spacing, tint) }
240 }
241
242 pub fn __image_format(image: &mut Image, format: impl Into<usize>) {
243 unsafe { ImageFormat(image, format.into() as i32) }
244 }
245
246 pub fn __image_to_pot(image: &mut Image, fill: Color) {
247 unsafe { ImageToPOT(image, fill) }
248 }
249
250 pub fn __image_crop(image: &mut Image, crop: Rectangle) {
251 unsafe { ImageCrop(image, crop) }
252 }
253
254 pub fn __image_alpha_crop(image: &mut Image, threshold: f32) {
255 unsafe { ImageAlphaCrop(image, threshold) }
256 }
257
258 pub fn __image_alpha_clear(image: &mut Image, color: Color, threshold: f32) {
259 unsafe { ImageAlphaClear(image, color, threshold) }
260 }
261
262 pub fn __image_alpha_mask(image: &mut Image, alpha_mask: Image) {
263 unsafe { ImageAlphaMask(image, alpha_mask) }
264 }
265
266 pub fn __image_alpha_premultiply(image: &mut Image) {
267 unsafe { ImageAlphaPremultiply(image) }
268 }
269
270 pub fn __image_blur_gaussian(image: &mut Image, blur_size: i32) {
271 unsafe { ImageBlurGaussian(image, blur_size) }
272 }
273
274 pub fn __image_resize(image: &mut Image, width: i32, height: i32) {
275 unsafe { ImageResize(image, width, height) }
276 }
277
278 pub fn __image_resize_nn(image: &mut Image, width: i32, height: i32) {
279 unsafe { ImageResizeNN(image, width, height) }
280 }
281
282 pub fn __image_resize_canvas(
283 image: &mut Image,
284 width: i32,
285 height: i32,
286 offset_x: i32,
287 offset_y: i32,
288 fill: Color,
289 ) {
290 unsafe { ImageResizeCanvas(image, width, height, offset_x, offset_y, fill) }
291 }
292
293 pub fn __image_mipmaps(image: &mut Image) {
294 unsafe { ImageMipmaps(image) }
295 }
296
297 pub fn __image_dither(image: &mut Image, r: i32, g: i32, b: i32, a: i32) {
298 unsafe { ImageDither(image, r, g, b, a) }
299 }
300
301 pub fn __image_flip_vertical(image: &mut Image) {
302 unsafe { ImageFlipVertical(image) }
303 }
304
305 pub fn __image_flip_horizontal(image: &mut Image) {
306 unsafe { ImageFlipHorizontal(image) }
307 }
308
309 pub fn __image_rotate(image: &mut Image, angle: f32) {
310 unsafe {
311 let degrees = (angle * 180.0 / PI) as i32;
312 ImageRotate(image, degrees)
313 }
314 }
315
316 pub fn __image_rotate_cw(image: &mut Image) {
317 unsafe { ImageRotateCW(image) }
318 }
319
320 pub fn __image_rotate_ccw(image: &mut Image) {
321 unsafe { ImageRotateCCW(image) }
322 }
323
324 pub fn __image_color_tint(image: &mut Image, tint: Color) {
325 unsafe { ImageColorTint(image, tint) }
326 }
327
328 pub fn __image_color_invert(image: &mut Image) {
329 unsafe { ImageColorInvert(image) }
330 }
331
332 pub fn __image_color_grayscale(image: &mut Image) {
333 unsafe { ImageColorGrayscale(image) }
334 }
335
336 pub fn __image_color_contrast(image: &mut Image, contrast: f32) {
337 unsafe { ImageColorContrast(image, contrast) }
338 }
339
340 pub fn __image_color_brightness(image: &mut Image, brightness: i32) {
341 unsafe { ImageColorBrightness(image, brightness) }
342 }
343
344 pub fn __image_color_replace(image: &mut Image, color: Color, replace: Color) {
345 unsafe { ImageColorReplace(image, color, replace) }
346 }
347
348 pub fn __load_image_colors(image: Image) -> *mut Color {
349 unsafe { LoadImageColors(image) }
350 }
351
352 pub fn __load_image_pallete(image: Image, max_size: i32) -> Result<Vec<Color>, String> {
353 unsafe {
354 let mut size: i32 = 0;
355 let raw = LoadImagePalette(image, max_size, &mut size);
356 let res = array_from_c(raw, size as usize, || {
357 "failed to load pallet from image".to_owned()
358 })?
359 .iter()
361 .map(|e| Color {
362 r: e.r,
363 g: e.g,
364 b: e.b,
365 a: e.a,
366 })
367 .collect::<Vec<_>>();
368 UnloadImagePalette(raw);
369 Ok(res)
370 }
371 }
372
373 pub fn __unload_image_colors(colors: *mut Color) {
374 unsafe { UnloadImageColors(colors) }
375 }
376
377 pub fn __get_image_alpha_border(image: Image, threshold: f32) -> Rectangle {
378 unsafe { GetImageAlphaBorder(image, threshold) }
379 }
380
381 pub fn __get_image_color(image: Image, x: i32, y: i32) -> Color {
382 unsafe { GetImageColor(image, x, y) }
383 }
384
385 pub fn __image_clear_background(image: &mut Image, color: Color) {
388 unsafe { ImageClearBackground(image, color) }
389 }
390
391 pub fn __image_draw_pixel(image: &mut Image, x: i32, y: i32, color: Color) {
392 unsafe { ImageDrawPixel(image, x, y, color) }
393 }
394
395 pub fn __image_draw_pixel_v(image: &mut Image, position: Vector2, color: Color) {
396 unsafe { ImageDrawPixelV(image, position, color) }
397 }
398
399 pub fn __image_draw_line(
400 image: &mut Image,
401 start_x: i32,
402 start_y: i32,
403 end_x: i32,
404 end_y: i32,
405 color: Color,
406 ) {
407 unsafe { ImageDrawLine(image, start_x, start_y, end_x, end_y, color) }
408 }
409
410 pub fn __image_draw_line_v(image: &mut Image, start: Vector2, end: Vector2, color: Color) {
411 unsafe { ImageDrawLineV(image, start, end, color) }
412 }
413
414 pub fn __image_draw_circle(
415 image: &mut Image,
416 center_x: i32,
417 center_y: i32,
418 radius: i32,
419 color: Color,
420 ) {
421 unsafe { ImageDrawCircle(image, center_x, center_y, radius, color) }
422 }
423
424 pub fn __image_draw_circle_v(image: &mut Image, center: Vector2, radius: i32, color: Color) {
425 unsafe { ImageDrawCircleV(image, center, radius, color) }
426 }
427
428 pub fn __image_draw_circle_lines(
429 image: &mut Image,
430 center_x: i32,
431 center_y: i32,
432 radius: i32,
433 color: Color,
434 ) {
435 unsafe { ImageDrawCircleLines(image, center_x, center_y, radius, color) }
436 }
437
438 pub fn __image_draw_circle_lines_v(
439 image: &mut Image,
440 center: Vector2,
441 radius: i32,
442 color: Color,
443 ) {
444 unsafe { ImageDrawCircleLinesV(image, center, radius, color) }
445 }
446
447 pub fn __image_draw_rectangle(
448 image: &mut Image,
449 x: i32,
450 y: i32,
451 width: i32,
452 height: i32,
453 color: Color,
454 ) {
455 unsafe { ImageDrawRectangle(image, x, y, width, height, color) }
456 }
457
458 pub fn __image_draw_rectangle_v(
459 image: &mut Image,
460 position: Vector2,
461 size: Vector2,
462 color: Color,
463 ) {
464 unsafe { ImageDrawRectangleV(image, position, size, color) }
465 }
466
467 pub fn __image_draw_rectangle_rec(image: &mut Image, rec: Rectangle, color: Color) {
468 unsafe { ImageDrawRectangleRec(image, rec, color) }
469 }
470
471 pub fn __image_draw_rectangle_lines(
472 image: &mut Image,
473 rec: Rectangle,
474 thick: i32,
475 color: Color,
476 ) {
477 unsafe { ImageDrawRectangleLines(image, rec, thick, color) }
478 }
479
480 pub fn __image_draw(
481 image: &mut Image,
482 src: Image,
483 src_rec: Rectangle,
484 dst_rec: Rectangle,
485 tint: Color,
486 ) {
487 unsafe { ImageDraw(image, src, src_rec, dst_rec, tint) }
488 }
489
490 pub fn __image_draw_text(
491 image: &mut Image,
492 text: impl Display,
493 x: i32,
494 y: i32,
495 font_size: i32,
496 color: Color,
497 ) {
498 unsafe { ImageDrawText(image, rl_str!(text), x, y, font_size, color) }
499 }
500
501 pub fn __image_draw_text_ex(
502 image: &mut Image,
503 font: Font,
504 text: impl Display,
505 position: Vector2,
506 font_size: f32,
507 spacing: f32,
508 tint: Color,
509 ) {
510 unsafe {
511 ImageDrawTextEx(
512 image,
513 font,
514 rl_str!(text),
515 position,
516 font_size,
517 spacing,
518 tint,
519 )
520 }
521 }
522
523 pub fn __load_texture(filename: impl Display) -> Result<Texture2D, String> {
526 unsafe {
527 let texture = LoadTexture(rl_str!(filename));
528 if texture.id == 0 {
529 if Path::new(&format!("{}", filename)).exists() {
530 Err(format!("couldn't load texture from {}", filename))
531 } else {
532 Err(format!(
533 "couldn't load texture from {}, file not found",
534 filename
535 ))
536 }
537 } else {
538 Ok(texture)
539 }
540 }
541 }
542
543 pub fn __load_texture_from_image(image: Image) -> Result<Texture2D, String> {
544 unsafe {
545 let texture = LoadTextureFromImage(image);
546 if texture.id == 0 {
547 Err("failed to load texture from image".to_owned())
548 } else {
549 Ok(texture)
550 }
551 }
552 }
553
554 pub fn __load_texture_cubemap(
555 image: Image,
556 layout: impl Into<usize>,
557 ) -> Result<TextureCubemap, String> {
558 unsafe {
559 let texture = LoadTextureCubemap(image, layout.into() as i32);
560 if texture.id == 0 {
561 Err("failed to load cubemap from image".to_owned())
562 } else {
563 Ok(texture)
564 }
565 }
566 }
567
568 pub fn __load_render_texture(width: i32, height: i32) -> RenderTexture2D {
569 unsafe { LoadRenderTexture(width, height) }
570 }
571
572 pub fn __is_texture_ready(texture: Texture2D) -> bool {
573 unsafe { IsTextureReady(texture) }
574 }
575
576 pub fn __unload_texture(texture: Texture2D) {
577 unsafe { UnloadTexture(texture) }
578 }
579
580 pub fn __is_render_texture_ready(target: RenderTexture2D) -> bool {
581 unsafe { IsRenderTextureReady(target) }
582 }
583
584 pub fn __unload_render_texture(target: RenderTexture2D) {
585 unsafe { UnloadRenderTexture(target) }
586 }
587
588 pub fn __update_texture(texture: Texture2D, pixels: &[u8]) {
589 unsafe { UpdateTexture(texture, pixels.as_ptr() as *const c_void) }
590 }
591
592 pub fn __update_texture_rec(texture: Texture2D, rec: Rectangle, pixels: &[u8]) {
593 unsafe { UpdateTextureRec(texture, rec, pixels.as_ptr() as *const c_void) }
594 }
595
596 pub fn __gen_texture_mipmaps(texture: &mut Texture2D) {
599 unsafe { GenTextureMipmaps(texture) }
600 }
601
602 pub fn __set_texture_filter(texture: Texture2D, filter: impl Into<usize>) {
603 unsafe { SetTextureFilter(texture, filter.into() as i32) }
604 }
605
606 pub fn __set_texture_wrap(texture: Texture2D, wrap: impl Into<usize>) {
607 unsafe { SetTextureWrap(texture, wrap.into() as i32) }
608 }
609
610 pub fn __draw_texture(texture: Texture2D, x: i32, y: i32, tint: Color) {
613 unsafe { DrawTexture(texture, x, y, tint) }
614 }
615
616 pub fn __draw_texture_v(texture: Texture2D, position: Vector2, tint: Color) {
617 unsafe { DrawTextureV(texture, position, tint) }
618 }
619
620 pub fn __draw_texture_ex(
621 texture: Texture2D,
622 position: Vector2,
623 rotation: f32,
624 scale: f32,
625 tint: Color,
626 ) {
627 unsafe { DrawTextureEx(texture, position, rotation, scale, tint) }
628 }
629
630 pub fn __draw_texture_rec(
631 texture: Texture2D,
632 source: Rectangle,
633 position: Vector2,
634 tint: Color,
635 ) {
636 unsafe { DrawTextureRec(texture, source, position, tint) }
637 }
638
639 pub fn __draw_texture_pro(
640 texture: Texture2D,
641 source: Rectangle,
642 dest: Rectangle,
643 origin: Vector2,
644 rotation: f32,
645 tint: Color,
646 ) {
647 unsafe { DrawTexturePro(texture, source, dest, origin, rotation, tint) }
648 }
649
650 pub fn __draw_texture_n_patch(
651 texture: Texture2D,
652 info: NPatchInfo,
653 dest: Rectangle,
654 origin: Vector2,
655 rotation: f32,
656 tint: Color,
657 ) {
658 unsafe { DrawTextureNPatch(texture, info, dest, origin, rotation, tint) }
659 }
660
661 pub fn __fade(color: Color, alpha: f32) -> Color {
664 unsafe { Fade(color, alpha) }
665 }
666
667 pub fn __color_to_int(color: Color) -> i32 {
668 unsafe { ColorToInt(color) }
669 }
670
671 pub fn __color_normalize(color: Color) -> Vector4 {
672 unsafe { ColorNormalize(color) }
673 }
674
675 pub fn __color_from_normalized(normalized: Vector4) -> Color {
676 unsafe { ColorFromNormalized(normalized) }
677 }
678
679 pub fn __color_to_hsv(color: Color) -> Vector3 {
680 unsafe { ColorToHSV(color) }
681 }
682
683 pub fn __color_from_hsv(hue: f32, saturation: f32, value: f32) -> Color {
684 unsafe { ColorFromHSV(hue, saturation, value) }
685 }
686
687 pub fn __color_tint(color: Color, tint: Color) -> Color {
688 unsafe { ColorTint(color, tint) }
689 }
690
691 pub fn __color_brightness(color: Color, factor: f32) -> Color {
692 unsafe { ColorBrightness(color, factor) }
693 }
694
695 pub fn __color_contrast(color: Color, contrast: f32) -> Color {
696 unsafe { ColorContrast(color, contrast) }
697 }
698
699 pub fn __color_alpha(color: Color, alpha: f32) -> Color {
700 unsafe { ColorAlpha(color, alpha) }
701 }
702
703 pub fn __color_alpha_blend(dst: Color, src: Color, tint: Color) -> Color {
704 unsafe { ColorAlphaBlend(dst, src, tint) }
705 }
706
707 pub fn __get_color(hex_value: u32) -> Color {
708 unsafe { GetColor(hex_value) }
709 }
710
711 pub fn __get_pixel_color(ptr: &mut Vec<u8>, format: impl Into<usize>) -> Color {
712 unsafe { GetPixelColor(ptr.as_mut_ptr() as *mut c_void, format.into() as i32) }
713 }
714
715 pub fn __set_pixel_color(ptr: &mut Vec<u8>, color: Color, format: impl Into<usize>) {
716 unsafe { SetPixelColor(ptr.as_mut_ptr() as *mut c_void, color, format.into() as i32) }
717 }
718
719 pub fn __get_pixel_data_size(width: i32, height: i32, format: impl Into<usize>) -> i32 {
720 unsafe { GetPixelDataSize(width, height, format.into() as i32) }
721 }
722}
723
724pub trait Rtextures: Debug {
726 fn load_image(&self, filename: impl Display) -> Result<Image, String> {
730 RtexturesImpl::__load_image(filename)
731 }
732
733 fn load_image_raw(
735 &self,
736 filename: impl Display,
737 width: i32,
738 height: i32,
739 format: PixelFormat,
740 header_size: i32,
741 ) -> Result<Image, String> {
742 RtexturesImpl::__load_image_raw(filename, width, height, format as usize, header_size)
743 }
744
745 fn load_image_svg(
747 &self,
748 filename_or_string: impl Display,
749 width: i32,
750 height: i32,
751 ) -> Result<Image, String> {
752 RtexturesImpl::__load_image_svg(filename_or_string, width, height)
753 }
754
755 fn load_image_anim(&self, filename: impl Display) -> Result<(Image, i32), String> {
757 RtexturesImpl::__load_image_anim(filename)
758 }
759
760 fn load_image_from_memory(&self, tpe: ImageType, data: &[u8]) -> Result<Image, String> {
762 RtexturesImpl::__load_image_from_memory(tpe, data)
763 }
764
765 fn load_image_from_texture(&self, texture: Texture2D) -> Image {
767 RtexturesImpl::__load_image_from_texture(texture)
768 }
769
770 fn load_image_from_screen(&self) -> Image {
772 RtexturesImpl::__load_image_from_screen()
773 }
774
775 fn is_image_ready(&self, image: Image) -> bool {
777 RtexturesImpl::__is_image_ready(image)
778 }
779
780 fn unload_image(&self, image: Image) {
782 RtexturesImpl::__unload_image(image)
783 }
784
785 fn export_image(&self, image: Image, filename: impl Display) -> bool {
787 RtexturesImpl::__export_image(image, filename)
788 }
789
790 fn export_image_to_memory(&self, image: Image, tpe: ImageType) -> Result<Vec<u8>, String> {
792 RtexturesImpl::__export_image_to_memory(image, tpe)
793 }
794
795 fn export_image_as_code(&self, image: Image, filename: impl Display) -> bool {
797 RtexturesImpl::__export_image_as_code(image, filename)
798 }
799
800 fn gen_image_color(&self, width: i32, height: i32, color: Color) -> Image {
804 RtexturesImpl::__gen_image_color(width, height, color)
805 }
806
807 fn gen_image_gradient_linear(
809 &self,
810 width: i32,
811 height: i32,
812 angle: f32,
813 start: Color,
814 end: Color,
815 ) -> Image {
816 RtexturesImpl::__gen_image_gradient_linear(width, height, angle, start, end)
817 }
818
819 fn gen_image_gradient_radial(
821 &self,
822 width: i32,
823 height: i32,
824 density: f32,
825 inner: Color,
826 outer: Color,
827 ) -> Image {
828 RtexturesImpl::__gen_image_gradient_radial(width, height, density, inner, outer)
829 }
830
831 fn gen_image_gradient_square(
833 &self,
834 width: i32,
835 height: i32,
836 density: f32,
837 inner: Color,
838 outer: Color,
839 ) -> Image {
840 RtexturesImpl::__gen_image_gradient_square(width, height, density, inner, outer)
841 }
842
843 fn gen_image_checked(
845 &self,
846 width: i32,
847 height: i32,
848 checks_x: i32,
849 checks_y: i32,
850 col1: Color,
851 col2: Color,
852 ) -> Image {
853 RtexturesImpl::__gen_image_checked(width, height, checks_x, checks_y, col1, col2)
854 }
855
856 fn gen_image_white_noise(&self, width: i32, height: i32, factor: f32) -> Image {
858 RtexturesImpl::__gen_image_white_noise(width, height, factor)
859 }
860
861 fn gen_image_perlin_noise(
863 &self,
864 width: i32,
865 height: i32,
866 offset_x: i32,
867 offset_y: i32,
868 scale: f32,
869 ) -> Image {
870 RtexturesImpl::__gen_image_perlin_noise(width, height, offset_x, offset_y, scale)
871 }
872
873 fn gen_image_cellular(&self, width: i32, height: i32, tile_size: i32) -> Image {
875 RtexturesImpl::__gen_image_cellular(width, height, tile_size)
876 }
877
878 fn gen_image_text(&self, width: i32, height: i32, text: impl Display) -> Image {
880 RtexturesImpl::__gen_image_text(width, height, text)
881 }
882
883 fn image_copy(&self, image: Image) -> Image {
887 RtexturesImpl::__image_copy(image)
888 }
889
890 fn image_from_image(&self, image: Image, rec: Rectangle) -> Image {
892 RtexturesImpl::__image_from_image(image, rec)
893 }
894
895 fn image_text(&self, text: impl Display, font_size: i32, color: Color) -> Image {
897 RtexturesImpl::__image_text(text, font_size, color)
898 }
899
900 fn image_text_ex(
902 &self,
903 font: Font,
904 text: impl Display,
905 font_size: f32,
906 spacing: f32,
907 tint: Color,
908 ) -> Image {
909 RtexturesImpl::__image_text_ex(font, text, font_size, spacing, tint)
910 }
911
912 fn image_format(&self, image: &mut Image, format: PixelFormat) {
914 RtexturesImpl::__image_format(image, format as usize)
915 }
916
917 fn image_to_pot(&self, image: &mut Image, fill: Color) {
919 RtexturesImpl::__image_to_pot(image, fill)
920 }
921
922 fn image_crop(&self, image: &mut Image, crop: Rectangle) {
924 RtexturesImpl::__image_crop(image, crop)
925 }
926
927 fn image_alpha_crop(&self, image: &mut Image, threshold: f32) {
929 RtexturesImpl::__image_alpha_crop(image, threshold)
930 }
931
932 fn image_alpha_clear(&self, image: &mut Image, color: Color, threshold: f32) {
934 RtexturesImpl::__image_alpha_clear(image, color, threshold)
935 }
936
937 fn image_alpha_mask(&self, image: &mut Image, alpha_mask: Image) {
939 RtexturesImpl::__image_alpha_mask(image, alpha_mask)
940 }
941
942 fn image_alpha_premultiply(&self, image: &mut Image) {
944 RtexturesImpl::__image_alpha_premultiply(image)
945 }
946
947 fn image_blur_gaussian(&self, image: &mut Image, blur_size: i32) {
949 RtexturesImpl::__image_blur_gaussian(image, blur_size)
950 }
951
952 fn image_resize(&self, image: &mut Image, width: i32, height: i32) {
954 RtexturesImpl::__image_resize(image, width, height)
955 }
956
957 fn image_resize_nn(&self, image: &mut Image, width: i32, height: i32) {
959 RtexturesImpl::__image_resize_nn(image, width, height)
960 }
961
962 fn image_resize_canvas(
964 &self,
965 image: &mut Image,
966 width: i32,
967 height: i32,
968 offset_x: i32,
969 offset_y: i32,
970 fill: Color,
971 ) {
972 RtexturesImpl::__image_resize_canvas(image, width, height, offset_x, offset_y, fill)
973 }
974
975 fn image_mipmaps(&self, image: &mut Image) {
977 RtexturesImpl::__image_mipmaps(image)
978 }
979
980 fn image_dither(&self, image: &mut Image, r: i32, g: i32, b: i32, a: i32) {
982 RtexturesImpl::__image_dither(image, r, g, b, a)
983 }
984
985 fn image_flip_vertical(&self, image: &mut Image) {
987 RtexturesImpl::__image_flip_vertical(image)
988 }
989
990 fn image_flip_horizontal(&self, image: &mut Image) {
992 RtexturesImpl::__image_flip_horizontal(image)
993 }
994
995 fn image_rotate(&self, image: &mut Image, angle: f32) {
997 RtexturesImpl::__image_rotate(image, angle)
998 }
999
1000 fn image_rotate_cw(&self, image: &mut Image) {
1002 RtexturesImpl::__image_rotate_cw(image)
1003 }
1004
1005 fn image_rotate_ccw(&self, image: &mut Image) {
1007 RtexturesImpl::__image_rotate_ccw(image)
1008 }
1009
1010 fn image_color_tint(&self, image: &mut Image, tint: Color) {
1012 RtexturesImpl::__image_color_tint(image, tint)
1013 }
1014
1015 fn image_color_invert(&self, image: &mut Image) {
1017 RtexturesImpl::__image_color_invert(image)
1018 }
1019
1020 fn image_color_grayscale(&self, image: &mut Image) {
1022 RtexturesImpl::__image_color_grayscale(image)
1023 }
1024
1025 fn image_color_contrast(&self, image: &mut Image, contrast: f32) {
1027 RtexturesImpl::__image_color_contrast(image, contrast)
1028 }
1029
1030 fn image_color_brightness(&self, image: &mut Image, brightness: i32) {
1032 RtexturesImpl::__image_color_brightness(image, brightness)
1033 }
1034
1035 fn image_color_replace(&self, image: &mut Image, color: Color, replace: Color) {
1037 RtexturesImpl::__image_color_replace(image, color, replace)
1038 }
1039
1040 fn load_image_colors(&self, image: Image) -> *mut Color {
1042 RtexturesImpl::__load_image_colors(image)
1043 }
1044
1045 fn load_image_pallete(&self, image: Image, max_size: i32) -> Result<Vec<Color>, String> {
1047 RtexturesImpl::__load_image_pallete(image, max_size)
1048 }
1049
1050 fn unload_image_colors(&self, colors: *mut Color) {
1052 RtexturesImpl::__unload_image_colors(colors)
1053 }
1054
1055 fn get_image_alpha_border(&self, image: Image, threshold: f32) -> Rectangle {
1057 RtexturesImpl::__get_image_alpha_border(image, threshold)
1058 }
1059
1060 fn get_image_color(&self, image: Image, x: i32, y: i32) -> Color {
1062 RtexturesImpl::__get_image_color(image, x, y)
1063 }
1064
1065 fn image_clear_background(&self, image: &mut Image, color: Color) {
1069 RtexturesImpl::__image_clear_background(image, color)
1070 }
1071
1072 fn image_draw_pixel(&self, image: &mut Image, x: i32, y: i32, color: Color) {
1074 RtexturesImpl::__image_draw_pixel(image, x, y, color)
1075 }
1076
1077 fn image_draw_pixel_v(&self, image: &mut Image, position: Vector2, color: Color) {
1079 RtexturesImpl::__image_draw_pixel_v(image, position, color)
1080 }
1081
1082 fn image_draw_line(
1084 &self,
1085 image: &mut Image,
1086 start_x: i32,
1087 start_y: i32,
1088 end_x: i32,
1089 end_y: i32,
1090 color: Color,
1091 ) {
1092 RtexturesImpl::__image_draw_line(image, start_x, start_y, end_x, end_y, color)
1093 }
1094
1095 fn image_draw_line_v(&self, image: &mut Image, start: Vector2, end: Vector2, color: Color) {
1097 RtexturesImpl::__image_draw_line_v(image, start, end, color)
1098 }
1099
1100 fn image_draw_circle(
1102 &self,
1103 image: &mut Image,
1104 center_x: i32,
1105 center_y: i32,
1106 radius: i32,
1107 color: Color,
1108 ) {
1109 RtexturesImpl::__image_draw_circle(image, center_x, center_y, radius, color)
1110 }
1111
1112 fn image_draw_circle_v(&self, image: &mut Image, center: Vector2, radius: i32, color: Color) {
1114 RtexturesImpl::__image_draw_circle_v(image, center, radius, color)
1115 }
1116
1117 fn image_draw_circle_lines(
1119 &self,
1120 image: &mut Image,
1121 center_x: i32,
1122 center_y: i32,
1123 radius: i32,
1124 color: Color,
1125 ) {
1126 RtexturesImpl::__image_draw_circle_lines(image, center_x, center_y, radius, color)
1127 }
1128
1129 fn image_draw_circle_lines_v(
1131 &self,
1132 image: &mut Image,
1133 center: Vector2,
1134 radius: i32,
1135 color: Color,
1136 ) {
1137 RtexturesImpl::__image_draw_circle_lines_v(image, center, radius, color)
1138 }
1139
1140 fn image_draw_rectangle(
1142 &self,
1143 image: &mut Image,
1144 x: i32,
1145 y: i32,
1146 width: i32,
1147 height: i32,
1148 color: Color,
1149 ) {
1150 RtexturesImpl::__image_draw_rectangle(image, x, y, width, height, color)
1151 }
1152
1153 fn image_draw_rectangle_v(
1155 &self,
1156 image: &mut Image,
1157 position: Vector2,
1158 size: Vector2,
1159 color: Color,
1160 ) {
1161 RtexturesImpl::__image_draw_rectangle_v(image, position, size, color)
1162 }
1163
1164 fn image_draw_rectangle_rec(&self, image: &mut Image, rec: Rectangle, color: Color) {
1166 RtexturesImpl::__image_draw_rectangle_rec(image, rec, color)
1167 }
1168
1169 fn image_draw_rectangle_lines(
1171 &self,
1172 image: &mut Image,
1173 rec: Rectangle,
1174 thick: i32,
1175 color: Color,
1176 ) {
1177 RtexturesImpl::__image_draw_rectangle_lines(image, rec, thick, color)
1178 }
1179
1180 fn image_draw(
1182 &self,
1183 image: &mut Image,
1184 src: Image,
1185 src_rec: Rectangle,
1186 dst_rec: Rectangle,
1187 tint: Color,
1188 ) {
1189 RtexturesImpl::__image_draw(image, src, src_rec, dst_rec, tint)
1190 }
1191
1192 fn image_draw_text(
1194 &self,
1195 image: &mut Image,
1196 text: impl Display,
1197 x: i32,
1198 y: i32,
1199 font_size: i32,
1200 color: Color,
1201 ) {
1202 RtexturesImpl::__image_draw_text(image, text, x, y, font_size, color)
1203 }
1204
1205 fn image_draw_text_ex(
1207 &self,
1208 image: &mut Image,
1209 font: Font,
1210 text: impl Display,
1211 position: Vector2,
1212 font_size: f32,
1213 spacing: f32,
1214 tint: Color,
1215 ) {
1216 RtexturesImpl::__image_draw_text_ex(image, font, text, position, font_size, spacing, tint)
1217 }
1218
1219 fn load_texture(&self, filename: impl Display) -> Result<Texture2D, String> {
1223 RtexturesImpl::__load_texture(filename)
1224 }
1225
1226 fn load_texture_from_image(&self, image: Image) -> Result<Texture2D, String> {
1228 RtexturesImpl::__load_texture_from_image(image)
1229 }
1230
1231 fn load_texture_cubemap(
1233 &self,
1234 image: Image,
1235 layout: CubemapLayout,
1236 ) -> Result<TextureCubemap, String> {
1237 RtexturesImpl::__load_texture_cubemap(image, layout as usize)
1238 }
1239
1240 fn load_render_texture(&self, width: i32, height: i32) -> RenderTexture2D {
1242 RtexturesImpl::__load_render_texture(width, height)
1243 }
1244
1245 fn is_texture_ready(&self, texture: Texture2D) -> bool {
1247 RtexturesImpl::__is_texture_ready(texture)
1248 }
1249
1250 fn unload_texture(&self, texture: Texture2D) {
1252 RtexturesImpl::__unload_texture(texture)
1253 }
1254
1255 fn is_render_texture_ready(&self, target: RenderTexture2D) -> bool {
1257 RtexturesImpl::__is_render_texture_ready(target)
1258 }
1259
1260 fn unload_render_texture(&self, target: RenderTexture2D) {
1262 RtexturesImpl::__unload_render_texture(target)
1263 }
1264
1265 fn update_texture(&self, texture: Texture2D, pixels: &[u8]) {
1267 RtexturesImpl::__update_texture(texture, pixels)
1268 }
1269
1270 fn update_texture_rec(&self, texture: Texture2D, rec: Rectangle, pixels: &[u8]) {
1272 RtexturesImpl::__update_texture_rec(texture, rec, pixels)
1273 }
1274
1275 fn gen_texture_mipmaps(&self, texture: &mut Texture2D) {
1279 RtexturesImpl::__gen_texture_mipmaps(texture)
1280 }
1281
1282 fn set_texture_filter(&self, texture: Texture2D, filter: TextureFilter) {
1284 RtexturesImpl::__set_texture_filter(texture, filter as usize)
1285 }
1286
1287 fn set_texture_wrap(&self, texture: Texture2D, wrap: TextureWrap) {
1289 RtexturesImpl::__set_texture_wrap(texture, wrap as usize)
1290 }
1291
1292 fn draw_texture(&self, texture: Texture2D, x: i32, y: i32, tint: Color) {
1296 RtexturesImpl::__draw_texture(texture, x, y, tint)
1297 }
1298
1299 fn draw_texture_v(&self, texture: Texture2D, position: Vector2, tint: Color) {
1301 RtexturesImpl::__draw_texture_v(texture, position, tint)
1302 }
1303
1304 fn draw_texture_ex(
1306 &self,
1307 texture: Texture2D,
1308 position: Vector2,
1309 rotation: f32,
1310 scale: f32,
1311 tint: Color,
1312 ) {
1313 RtexturesImpl::__draw_texture_ex(texture, position, rotation, scale, tint)
1314 }
1315
1316 fn draw_texture_rec(
1318 &self,
1319 texture: Texture2D,
1320 source: Rectangle,
1321 position: Vector2,
1322 tint: Color,
1323 ) {
1324 RtexturesImpl::__draw_texture_rec(texture, source, position, tint)
1325 }
1326
1327 fn draw_texture_pro(
1329 &self,
1330 texture: Texture2D,
1331 source: Rectangle,
1332 dest: Rectangle,
1333 origin: Vector2,
1334 rotation: f32,
1335 tint: Color,
1336 ) {
1337 RtexturesImpl::__draw_texture_pro(texture, source, dest, origin, rotation, tint)
1338 }
1339
1340 fn draw_texture_n_patch(
1342 &self,
1343 texture: Texture2D,
1344 info: NPatchInfo,
1345 dest: Rectangle,
1346 origin: Vector2,
1347 rotation: f32,
1348 tint: Color,
1349 ) {
1350 RtexturesImpl::__draw_texture_n_patch(texture, info, dest, origin, rotation, tint)
1351 }
1352
1353 fn fade(&self, color: Color, alpha: f32) -> Color {
1357 RtexturesImpl::__fade(color, alpha)
1358 }
1359
1360 fn color_to_int(&self, color: Color) -> i32 {
1362 RtexturesImpl::__color_to_int(color)
1363 }
1364
1365 fn color_normalize(&self, color: Color) -> Vector4 {
1367 RtexturesImpl::__color_normalize(color)
1368 }
1369
1370 fn color_from_normalized(&self, normalized: Vector4) -> Color {
1372 RtexturesImpl::__color_from_normalized(normalized)
1373 }
1374
1375 fn color_to_hsv(&self, color: Color) -> Vector3 {
1377 RtexturesImpl::__color_to_hsv(color)
1378 }
1379
1380 fn color_from_hsv(&self, hue: f32, saturation: f32, value: f32) -> Color {
1382 RtexturesImpl::__color_from_hsv(hue, saturation, value)
1383 }
1384
1385 fn color_tint(&self, color: Color, tint: Color) -> Color {
1387 RtexturesImpl::__color_tint(color, tint)
1388 }
1389
1390 fn color_brightness(&self, color: Color, factor: f32) -> Color {
1392 RtexturesImpl::__color_brightness(color, factor)
1393 }
1394
1395 fn color_contrast(&self, color: Color, contrast: f32) -> Color {
1397 RtexturesImpl::__color_contrast(color, contrast)
1398 }
1399
1400 fn color_alpha(&self, color: Color, alpha: f32) -> Color {
1402 RtexturesImpl::__color_alpha(color, alpha)
1403 }
1404
1405 fn color_alpha_blend(&self, dst: Color, src: Color, tint: Color) -> Color {
1407 RtexturesImpl::__color_alpha_blend(dst, src, tint)
1408 }
1409
1410 fn get_color(&self, hex_value: u32) -> Color {
1412 RtexturesImpl::__get_color(hex_value)
1413 }
1414
1415 fn get_pixel_color(&self, ptr: &mut Vec<u8>, format: PixelFormat) -> Color {
1417 RtexturesImpl::__get_pixel_color(ptr, format as usize)
1418 }
1419
1420 fn set_pixel_color(&self, ptr: &mut Vec<u8>, color: Color, format: PixelFormat) {
1422 RtexturesImpl::__set_pixel_color(ptr, color, format as usize)
1423 }
1424
1425 fn get_pixel_data_size(&self, width: i32, height: i32, format: PixelFormat) -> i32 {
1427 RtexturesImpl::__get_pixel_data_size(width, height, format as usize)
1428 }
1429}