Rectangle.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function Rectangle() {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.Rectangle()
  4. }
  5. Object.defineProperties(this, {
  6. 'x': { enumerable: true, configurable: true, get: Rectangle.prototype.__get_x, set: Rectangle.prototype.__set_x},
  7. 'y': { enumerable: true, configurable: true, get: Rectangle.prototype.__get_y, set: Rectangle.prototype.__set_y},
  8. 'w': { enumerable: true, configurable: true, get: Rectangle.prototype.__get_w, set: Rectangle.prototype.__set_w},
  9. 'h': { enumerable: true, configurable: true, get: Rectangle.prototype.__get_h, set: Rectangle.prototype.__set_h}
  10. })
  11. }
  12. Rectangle.prototype.__get_x = function() {
  13. return Polycode.Rectangle__get_x(this.__ptr)
  14. }
  15. Rectangle.prototype.__set_x = function(val) {
  16. Polycode.Rectangle__set_x(this.__ptr, val)
  17. }
  18. Rectangle.prototype.__get_y = function() {
  19. return Polycode.Rectangle__get_y(this.__ptr)
  20. }
  21. Rectangle.prototype.__set_y = function(val) {
  22. Polycode.Rectangle__set_y(this.__ptr, val)
  23. }
  24. Rectangle.prototype.__get_w = function() {
  25. return Polycode.Rectangle__get_w(this.__ptr)
  26. }
  27. Rectangle.prototype.__set_w = function(val) {
  28. Polycode.Rectangle__set_w(this.__ptr, val)
  29. }
  30. Rectangle.prototype.__get_h = function() {
  31. return Polycode.Rectangle__get_h(this.__ptr)
  32. }
  33. Rectangle.prototype.__set_h = function(val) {
  34. Polycode.Rectangle__set_h(this.__ptr, val)
  35. }
  36. Duktape.fin(Rectangle.prototype, function (x) {
  37. if (x === Rectangle.prototype) {
  38. return;
  39. }
  40. Polycode.Rectangle__delete(x.__ptr)
  41. })
  42. Rectangle.prototype.setRect = function(x,y,w,h) {
  43. Polycode.Rectangle_setRect(this.__ptr, x, y, w, h)
  44. }
  45. Rectangle.prototype.Clipped = function(rect) {
  46. var retVal = new Rectangle()
  47. retVal.__ptr = Polycode.Rectangle_Clipped(this.__ptr, rect)
  48. return retVal
  49. }
  50. Rectangle.prototype.minX = function() {
  51. return Polycode.Rectangle_minX(this.__ptr)
  52. }
  53. Rectangle.prototype.maxX = function() {
  54. return Polycode.Rectangle_maxX(this.__ptr)
  55. }
  56. Rectangle.prototype.minY = function() {
  57. return Polycode.Rectangle_minY(this.__ptr)
  58. }
  59. Rectangle.prototype.maxY = function() {
  60. return Polycode.Rectangle_maxY(this.__ptr)
  61. }