2
0

Rectangle.js 2.0 KB

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