bitmap_draw.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // albitmap
  2. package al
  3. /*
  4. #include <stdlib.h>
  5. #include <allegro5/allegro.h>
  6. #include "helpers.h"
  7. #include "callbacks.h"
  8. */
  9. import "C"
  10. const (
  11. FLIP_HORIZONTAL = C.ALLEGRO_FLIP_HORIZONTAL
  12. FLIP_VERTICAL = C.ALLEGRO_FLIP_VERTICAL
  13. )
  14. func (bmp * Bitmap) Draw(dx, dy float32, flags int) {
  15. C.al_draw_bitmap(bmp.handle, C.float(dx), C.float(dy), C.int(flags))
  16. }
  17. func (bmp * Bitmap) DrawRegion(sx, sy, sw, sh, dx, dy float32, flags int) {
  18. C.al_draw_bitmap_region(bmp.handle, C.float(sx), C.float(sy),
  19. C.float(sw), C.float(sh), C.float(dx), C.float(dy), C.int(flags))
  20. }
  21. func (bmp * Bitmap) DrawScaled(sx, sy, sw, sh, dx, dy, dw, dh float32, flags int) {
  22. C.al_draw_scaled_bitmap(bmp.handle, C.float(sx), C.float(sy),
  23. C.float(sw), C.float(sh), C.float(dx), C.float(dy),
  24. C.float(dw), C.float(dh), C.int(flags))
  25. }
  26. func (bmp * Bitmap) DrawRotated(cx, cy, dx, dy, angle float32, flags int) {
  27. C.al_draw_rotated_bitmap(bmp.handle, C.float(cx), C.float(cy),
  28. C.float(dx), C.float(dy), C.float(angle), C.int(flags))
  29. }
  30. func (bmp * Bitmap) DrawScaledRotated(cx, cy, dx, dy, xscale, yscale, angle float32, flags int) {
  31. C.al_draw_scaled_rotated_bitmap(bmp.handle, C.float(cx), C.float(cy),
  32. C.float(dx), C.float(dy),
  33. C.float(xscale), C.float(yscale), C.float(angle), C.int(flags))
  34. }
  35. func (bmp * Bitmap) DrawTinted(color Color, dx, dy float32, flags int) {
  36. C.al_draw_tinted_bitmap(bmp.handle, color.toC(), C.float(dx), C.float(dy), C.int(flags))
  37. }
  38. func (bmp * Bitmap) DrawTintedRegion(color Color, sx, sy, sw, sh, dx, dy float32, flags int) {
  39. C.al_draw_tinted_bitmap_region(bmp.handle, color.toC(), C.float(sx), C.float(sy),
  40. C.float(sw), C.float(sh), C.float(dx), C.float(dy), C.int(flags))
  41. }
  42. func (bmp * Bitmap) DrawTintedScaled(color Color, sx, sy, sw, sh, dx, dy, dw, dh float32, flags int) {
  43. C.al_draw_tinted_scaled_bitmap(bmp.handle, color.toC(), C.float(sx), C.float(sy),
  44. C.float(sw), C.float(sh), C.float(dx), C.float(dy),
  45. C.float(dw), C.float(dh), C.int(flags))
  46. }
  47. func (bmp * Bitmap) DrawTintedRotated(color Color, cx, cy, dx, dy, angle float32, flags int) {
  48. C.al_draw_tinted_rotated_bitmap(bmp.handle, color.toC(), C.float(cx), C.float(cy),
  49. C.float(dx), C.float(dy), C.float(angle), C.int(flags))
  50. }
  51. func (bmp * Bitmap) DrawTintedScaledRotated(color Color, cx, cy, dx, dy, xscale, yscale, angle float32, flags int) {
  52. C.al_draw_tinted_scaled_rotated_bitmap(bmp.handle, color.toC(), C.float(cx), C.float(cy),
  53. C.float(dx), C.float(dy),
  54. C.float(xscale), C.float(yscale), C.float(angle), C.int(flags))
  55. }
  56. func (bmp * Bitmap) DrawTintedScaledRotatedRegion(sx, sy, sw, sh float32, color Color, cx, cy, dx, dy, xscale, yscale, angle float32, flags int) {
  57. C.al_draw_tinted_scaled_rotated_bitmap_region(bmp.handle,
  58. C.float(sx), C.float(sy), C.float(sw), C.float(sh),
  59. color.toC(), C.float(cx), C.float(cy),
  60. C.float(dx), C.float(dy),
  61. C.float(xscale), C.float(yscale), C.float(angle), C.int(flags))
  62. }