import { any } from "vue-types"; import { Point } from "./point"; export class ObservablePoint { cb: any; scope: any; _x = 0; _y = 0; constructor(cb:any, scope:any, x=0 , y=0) { this._x = x; this._y = y; this.cb = cb; this.scope = scope; } clone(cb = this.cb, scope = this.scope) { return new ObservablePoint(cb, scope, this._x, this._y); } set(x = 0, y = x) { if (this._x !== x || this._y !== y) { this._x = x; this._y = y; this.cb.call(this.scope); } } copyFrom(p: Point) { if (this._x !== p.x || this._y !== p.y) { this._x = p.x; this._y = p.y; this.cb.call(this.scope); } return this; } copyTo(p: Point) { p.set(this._x, this._y); return p; } equals(p: Point) { return p.x === this._x && p.y === this._y; } get x() { return this._x; } set x( value // eslint-disable-line require-jsdoc ) { if (this._x !== value) { this._x = value; this.cb.call(this.scope); } } get y() { return this._y; } set y(value) { if (this._y !== value) { this._y = value; this.cb.call(this.scope); } } }