Point.js 333 B

12345678910111213141516171819
  1. export class Point {
  2. constructor(x, y){
  3. this.x = x;
  4. this.y = y;
  5. }
  6. scale(x, y) {
  7. this.x *= x;
  8. this.y *= y;
  9. }
  10. distanceTo(point) {
  11. return Math.hypot(point.x - this.x, point.y - this.y);
  12. }
  13. equals(point) {
  14. return point.x == this.x && point.y == this.y
  15. }
  16. }