define.go 746 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package ax
  2. import "surdeus.su/core/gg"
  3. type Animation []*gg.Image
  4. type RectIndex struct {
  5. X, Y int
  6. }
  7. // The type is used
  8. // to structurely define
  9. // animations.
  10. type AnimationDefine struct{
  11. Id AnimationID
  12. Indexes []RectIndex
  13. }
  14. // Animation define shortcut.
  15. func AD(
  16. id AnimationID,
  17. indexes ...RectIndex,
  18. ) AnimationDefine {
  19. return AnimationDefine{
  20. Id: id,
  21. Indexes: indexes,
  22. }
  23. }
  24. func (ad AnimationDefine) DefRow(
  25. y int, xs ...int,
  26. ) AnimationDefine {
  27. for _, x := range xs {
  28. ad.Indexes = append(
  29. ad.Indexes,
  30. RectIndex{x, y},
  31. )
  32. }
  33. return ad
  34. }
  35. func (ad AnimationDefine) DefCol(
  36. x int, ys ...int,
  37. ) AnimationDefine {
  38. for _, y := range ys {
  39. ad.Indexes = append(
  40. ad.Indexes,
  41. RectIndex{x, y},
  42. )
  43. }
  44. return ad
  45. }