bitmap_draw.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. }