export interface IRect { Position : Point ; Size : Point ; } export class Point { private x : number ; private y : number ; constructor ( ) ; constructor ( x ) ; constructor ( x , y ) ; constructor ( x ? , y ? ) { this . x = x != null ? x : 0 ; this . y = y != null ? y : x != null ? x : 0 ; } get X ( ) : number { return this . x ; } set X ( x ) { this . x = x ; } get Y ( ) : number { return this . y ; } set Y ( y ) { this . y = y ; } Add ( point ) { return new Point ( this . X + point . X , this . Y + point . Y ) ; } Clone ( ) { return new Point ( this . X , this . Y ) ; } Div ( point ) { return new Point ( this . X / point . X , this . Y / point . Y ) ; } IsInRect ( rect ) { return this . X >= rect . Position . X && this . X <= rect . Position . Add ( rect . Size ) . X && this . Y >= rect . Position . Y && this . Y <= rect . Position . Add ( rect . Size ) . Y ; } Mult ( point ) { return new Point ( this . X * point . X , this . Y * point . Y ) ; } Sub ( point ) { return this . Add ( new Point ( - point . X , - point . Y ) ) ; } }