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.

61 lines
1.7 KiB

  1. cc.Point = cc.Point or {}
  2. cc.Color4F = cc.Color4F or {}
  3. cc.Color3B = cc.Color3B or {}
  4. cc.Size = cc.Size or {}
  5. cc.Rect = cc.Rect or {}
  6. cc.Margin = cc.Margin or {}
  7. function cc.Point:toString()
  8. return tostring(self.x) .. " " .. tostring(self.y);
  9. end
  10. function cc.Point.fromString(str)
  11. local arr = string.split(str , " ");
  12. return cc.p(arr[1] , arr[2]);
  13. end
  14. function cc.Color4F:toString()
  15. return tostring(self.r) .. " " .. tostring(self.g) .. " " .. tostring(self.b) .. " " .. tostring(self.a);
  16. end
  17. function cc.Color4F.fromString(str)
  18. local arr = string.split(str , " ");
  19. return cc.c4f(arr[1] , arr[2] , arr[3] , arr[4])
  20. end
  21. function cc.Color3B:toString()
  22. return tostring(self.r) .. " " .. tostring(self.g) .. " " .. tostring(self.b);
  23. end
  24. function cc.Color3B.fromString(str)
  25. local arr = string.split(str , " ");
  26. return cc.c3b(arr[1] , arr[2] , arr[3])
  27. end
  28. function cc.Size:toString()
  29. return tostring(self.width) .. " " .. tostring(self.height);
  30. end
  31. function cc.Size.fromString(str)
  32. local arr = string.split(str , " ");
  33. return cc.size(arr[1] , arr[2]);
  34. end
  35. function cc.Rect:toString()
  36. return tostring(self.x) .. " " .. tostring(self.y) .. " " ..tostring(self.width) .. " " .. tostring(self.height);
  37. end
  38. function cc.Rect.fromString(str)
  39. local arr = string.split(str , " ");
  40. return cc.rect(arr[1] , arr[2] , arr[3] , arr[4]);
  41. end
  42. function cc.margin(l,t,r,b)
  43. return {left = l;top = t;right = r;bottom = b};
  44. end
  45. function cc.Margin:toString()
  46. return tostring(self.left) .. " " .. tostring(self.top) .. " " .. tostring(self.right) .. " " .. tostring(self.bottom);
  47. end
  48. function cc.Margin.fromString(str)
  49. local arr = string.split(str , " ");
  50. return cc.margin(arr[1] , arr[2] , arr[3] , arr[4]);
  51. end
  52. require("luaScript.Tools.ObjectBinder")