You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

116 lines
2.4 KiB

  1. package structures.basic;
  2. import com.fasterxml.jackson.annotation.JsonIgnore;
  3. /**
  4. * Sprites when extracted are not full size (there is white space around the sprite).
  5. * We need to correct for this as well as centre the sprite on the tile. This class
  6. * contains information to do this.
  7. *
  8. * @author Dr. Richard McCreadie
  9. *
  10. */
  11. public class ImageCorrection {
  12. double imgWidth;
  13. double imgHeight;
  14. double spriteTopLeftX;
  15. double spriteTopLeftY;
  16. double offsetX;
  17. double offsetY;
  18. double scale;
  19. boolean reflected;
  20. public ImageCorrection() {}
  21. public ImageCorrection(double imgWidth, double imgHeight, double spriteTopLeftX, double spriteTopLeftY,
  22. double offsetX, double offsetY, double scale, boolean reflected) {
  23. super();
  24. this.imgWidth = imgWidth;
  25. this.imgHeight = imgHeight;
  26. this.spriteTopLeftX = spriteTopLeftX;
  27. this.spriteTopLeftY = spriteTopLeftY;
  28. this.offsetX = offsetX;
  29. this.offsetY = offsetY;
  30. this.scale = scale;
  31. this.reflected = reflected;
  32. }
  33. public double getImgWidth() {
  34. return imgWidth;
  35. }
  36. public void setImgWidth(double imgWidth) {
  37. this.imgWidth = imgWidth;
  38. }
  39. public double getImgHeight() {
  40. return imgHeight;
  41. }
  42. public void setImgHeight(double imgHeight) {
  43. this.imgHeight = imgHeight;
  44. }
  45. public double getSpriteTopLeftX() {
  46. return spriteTopLeftX;
  47. }
  48. public void setSpriteTopLeftX(double spriteTopLeftX) {
  49. this.spriteTopLeftX = spriteTopLeftX;
  50. }
  51. public double getSpriteTopLeftY() {
  52. return spriteTopLeftY;
  53. }
  54. public void setSpriteTopLeftY(double spriteTopLeftY) {
  55. this.spriteTopLeftY = spriteTopLeftY;
  56. }
  57. public double getOffsetX() {
  58. return offsetX;
  59. }
  60. public void setOffsetX(double offsetX) {
  61. this.offsetX = offsetX;
  62. }
  63. public double getOffsetY() {
  64. return offsetY;
  65. }
  66. public void setOffsetY(double offsetY) {
  67. this.offsetY = offsetY;
  68. }
  69. public double getScale() {
  70. return scale;
  71. }
  72. public void setScale(double scale) {
  73. this.scale = scale;
  74. }
  75. public boolean isReflected() {
  76. return reflected;
  77. }
  78. public void setReflected(boolean reflected) {
  79. this.reflected = reflected;
  80. }
  81. @JsonIgnore
  82. public double getCorrectedImgWidth() {
  83. return imgWidth*(1+(spriteTopLeftX/imgWidth));
  84. }
  85. @JsonIgnore
  86. public double getCorrectedImgHeight() {
  87. return imgHeight*(1+(spriteTopLeftY/imgHeight));
  88. }
  89. }