mirror of
https://github.com/billsonnn/nitro-imager
synced 2024-06-30 20:35:33 +02:00
40 lines
652 B
TypeScript
40 lines
652 B
TypeScript
export class Point
|
|
{
|
|
public x = 0;
|
|
public y = 0;
|
|
|
|
constructor(x: number = 0, y: number = 0)
|
|
{
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
public clone(): Point
|
|
{
|
|
return new Point(this.x, this.y);
|
|
}
|
|
|
|
public equals(p: Point): boolean
|
|
{
|
|
return ((p.x === this.x) && (p.y === this.y));
|
|
}
|
|
|
|
public set(x: number = 0, y: number = x): Point
|
|
{
|
|
this.x = x;
|
|
this.y = y;
|
|
|
|
return this;
|
|
}
|
|
|
|
public add(point: Point): Point
|
|
{
|
|
const clone = this.clone();
|
|
|
|
clone.x += point.x;
|
|
clone.y += point.y;
|
|
|
|
return clone;
|
|
}
|
|
}
|