SPoint.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SPoint = void 0;
  4. var SPoint = (function () {
  5. function SPoint(x, y) {
  6. if (x == undefined) {
  7. this.x = 0;
  8. this.y = 0;
  9. }
  10. else if (x instanceof SPoint) {
  11. this.x = x.x;
  12. this.y = x.y;
  13. }
  14. else {
  15. this.x = x;
  16. this.y = y;
  17. }
  18. }
  19. SPoint.prototype.setPoint = function (x, y) {
  20. if (x instanceof SPoint) {
  21. this.x = x.x;
  22. this.y = x.y;
  23. }
  24. else {
  25. this.x = x;
  26. this.y = y;
  27. }
  28. };
  29. SPoint.prototype.manhattanLength = function () {
  30. return Math.abs(this.x) + Math.abs(this.y);
  31. };
  32. SPoint.prototype.matrixTransform = function (mat) {
  33. var p = new SPoint();
  34. p.x = this.x * mat.a + this.y * mat.b + mat.e;
  35. p.y = this.x * mat.c + this.y * mat.d + mat.f;
  36. return p;
  37. };
  38. SPoint.prototype.translate = function (dx, dy) {
  39. this.x += dx;
  40. this.y += dy;
  41. };
  42. return SPoint;
  43. }());
  44. exports.SPoint = SPoint;