bitmap_draw.go 3.0 KB

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