export class Bound { private _xmin : number ; private _ymin : number ; private _xmax : number ; private _ymax : number ; private _xscale : number = 1 ; private _yscale : number = 1 ; get xmin ( ) : number { return this . _xmin ; } get ymin ( ) : number { return this . _ymin ; } get xmax ( ) : number { return this . _xmax ; } get ymax ( ) : number { return this . _ymax ; } get xscale ( ) : number { return this . _xscale ; } get yscale ( ) : number { return this . _yscale ; } getCenter ( ) { return [ ( this . _xmin + this . _xmax ) / 2 , ( this . _ymin + this . _ymax ) / 2 ] ; } constructor ( xmin , ymin , xmax , ymax ) { this . _xmin = Math . min ( xmin , xmax ) ; this . _ymin = Math . min ( ymin , ymax ) ; this . _xmax = Math . max ( xmin , xmax ) ; this . _ymax = Math . max ( ymin , ymax ) ; this . _xscale = xmin <= xmax ? 1 : - 1 ; this . _yscale = ymin <= ymax ? 1 : - 1 ; } intersect ( bound ) { return ( bound . xmax >= this . _xmin ) && ( bound . xmin <= this . _xmax ) && ( bound . ymax >= this . _ymin ) && ( bound . ymin <= this . _ymax ) ; } scale ( s ) { this . _xmin = this . _xmin - ( s - 1 ) * ( this . _xmax - this . _xmin ) / 2 ; this . _xmax = this . _xmax + ( s - 1 ) * ( this . _xmax - this . _xmin ) / 2 ; this . _ymin = this . _ymin - ( s - 1 ) * ( this . _ymax - this . _ymin ) / 2 ; this . _ymax = this . _ymax + ( s - 1 ) * ( this . _ymax - this . _ymin ) / 2 ; } buffer ( size ) { this . _xmin -= size ; this . _ymin -= size ; this . _xmax += size ; this . _ymax += size ; } }