import { Matrix2D } from "./math2D" ; import { Vector2 } from "babylonjs/Maths/math.vector" ; let tmpRect = [ new Vector2 ( 0 , 0 ) , new Vector2 ( 0 , 0 ) , new Vector2 ( 0 , 0 ) , new Vector2 ( 0 , 0 ) , ] ; let tmpRect2 = [ new Vector2 ( 0 , 0 ) , new Vector2 ( 0 , 0 ) , new Vector2 ( 0 , 0 ) , new Vector2 ( 0 , 0 ) , ] ; let tmpV1 = new Vector2 ( 0 , 0 ) ; let tmpV2 = new Vector2 ( 0 , 0 ) ; /**
 * Class used to store 2D control sizes
 */ export class Measure { param left param top param width param height public constructor ( /** defines left coordinate */ public left , /** defines top coordinate  */ public top , /** defines width dimension  */ public width , /** defines height dimension */ public height ) { } param other public copyFrom ( other ) { this . left = other . left ; this . top = other . top ; this . width = other . width ; this . height = other . height ; } param left param top param width param height public copyFromFloats ( left , top , width , height ) { this . left = left ; this . top = top ; this . width = width ; this . height = height ; } param a param b param result public static CombineToRef ( a , b , result ) { var left = Math . min ( a . left , b . left ) ; var top = Math . min ( a . top , b . top ) ; var right = Math . max ( a . left + a . width , b . left + b . width ) ; var bottom = Math . max ( a . top + a . height , b . top + b . height ) ; result . left = left ; result . top = top ; result . width = right - left ; result . height = bottom - top ; } param transform param addX param addY param addWidth param addHeight param result public addAndTransformToRef ( transform , addX , addY , addWidth , addHeight , result ) { const left = this . left + addX ; const top = this . top + addY ; const width = this . width + addWidth ; const height = this . height + addHeight ; tmpRect [ 0 ] . copyFromFloats ( left , top ) ; tmpRect [ 1 ] . copyFromFloats ( left + width , top ) ; tmpRect [ 2 ] . copyFromFloats ( left + width , top + height ) ; tmpRect [ 3 ] . copyFromFloats ( left , top + height ) ; tmpV1 . copyFromFloats ( Number . MAX_VALUE , Number . MAX_VALUE ) ; tmpV2 . copyFromFloats ( 0 , 0 ) ; for ( var i = 0 ; i < 4 ; i ++ ) { transform . transformCoordinates ( tmpRect [ i ] . x , tmpRect [ i ] . y , tmpRect2 [ i ] ) ; tmpV1 . x = Math . floor ( Math . min ( tmpV1 . x , tmpRect2 [ i ] . x ) ) ; tmpV1 . y = Math . floor ( Math . min ( tmpV1 . y , tmpRect2 [ i ] . y ) ) ; tmpV2 . x = Math . ceil ( Math . max ( tmpV2 . x , tmpRect2 [ i ] . x ) ) ; tmpV2 . y = Math . ceil ( Math . max ( tmpV2 . y , tmpRect2 [ i ] . y ) ) ; } result . left = tmpV1 . x ; result . top = tmpV1 . y ; result . width = tmpV2 . x - tmpV1 . x ; result . height = tmpV2 . y - tmpV1 . y ; } param transform param result public transformToRef ( transform , result ) { this . addAndTransformToRef ( transform , 0 , 0 , 0 , 0 , result ) ; } param other returns public isEqualsTo ( other ) { if ( this . left !== other . left ) { return false ; } if ( this . top !== other . top ) { return false ; } if ( this . width !== other . width ) { return false ; } if ( this . height !== other . height ) { return false ; } return true ; } returns public static Empty ( ) { return new Measure ( 0 , 0 , 0 , 0 ) ; } }