22 lines
374 B
JavaScript
22 lines
374 B
JavaScript
|
|
export default class Point {
|
|
constructor(x, y) {
|
|
if (typeof x === 'object') {
|
|
y = x.y;
|
|
x = x.x;
|
|
}
|
|
|
|
// add zero to turn -0 into 0
|
|
this.x = Math.round(x) + 0;
|
|
this.y = Math.round(y) + 0;
|
|
}
|
|
|
|
getX() { return this.x; }
|
|
getY() { return this.y; }
|
|
|
|
setX(newX) { this.x = newX; }
|
|
setY(newY) { this.y = newY; }
|
|
|
|
getPoint() { return {x: this.x, y: this.y}; }
|
|
}
|