Arm2D_Box.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "Arm2D_Box.h"
  2. #include "Arm2D_common.h"
  3. #include "asset_corner_box.h"
  4. #include "dataArgs.h"
  5. void Arm2D_Box___init__(PikaObj* self) {
  6. /* init element info */
  7. obj_setInt(self, "alpha", 255);
  8. obj_setInt(self, "x", 0);
  9. obj_setInt(self, "y", 0);
  10. /* init box info */
  11. obj_setInt(self, "weight", 50);
  12. obj_setInt(self, "height", 50);
  13. obj_setInt(self, "color", GLCD_COLOR_BLUE);
  14. }
  15. int __min(int x, int y) {
  16. return x < y ? x : y;
  17. }
  18. int __max(int x, int y) {
  19. return x > y ? x : y;
  20. }
  21. void Arm2D_Box_update(PikaObj* self) {
  22. void* target_tile = pika_arm2d_globals.pfb_tile_now;
  23. bool bIsNewFrame = pika_arm2d_globals.pfb_is_new_frame;
  24. arm_2d_region_t arg2d_regin = {0};
  25. arg2d_regin.tSize.iHeight = obj_getInt(self, "height");
  26. arg2d_regin.tSize.iWidth = obj_getInt(self, "weight");
  27. arg2d_regin.tLocation.iX = obj_getInt(self, "x");
  28. arg2d_regin.tLocation.iY = obj_getInt(self, "y");
  29. uint16_t color_code = obj_getInt(self, "color");
  30. uint8_t alpha = obj_getInt(self, "alpha");
  31. draw_round_corner_box(target_tile, &arg2d_regin, color_code, alpha, bIsNewFrame);
  32. }
  33. void Arm2D_Box_setColor(PikaObj* self, int color) {
  34. obj_setInt(self, "color", color);
  35. }
  36. void Arm2D_Box_setSize(PikaObj* self, int x, int y) {
  37. obj_setInt(self, "weight_last", obj_getInt(self, "weight"));
  38. obj_setInt(self, "height_last", obj_getInt(self, "height"));
  39. obj_setInt(self, "weight", x);
  40. obj_setInt(self, "height", y);
  41. }