| 4 | module Display { |
| 5 | |
| 6 | class DirtyArea { |
| 7 | private _xBegin:number = null; |
| 8 | private _yBegin:number = null; |
| 9 | private _xEnd:number = null; |
| 10 | private _yEnd:number = null; |
| 11 | |
| 12 | public expand(x:number, y:number) { |
| 13 | this._xBegin = this._xBegin === null ? x : Math.min(this._xBegin, x); |
| 14 | this._xEnd = this._xEnd === null ? x : Math.max(this._xEnd, x); |
| 15 | this._yBegin = this._yBegin === null ? y :Math.min(this._yBegin, y); |
| 16 | this._yEnd = this._xEnd === null ? y :Math.max(this._yEnd, y); |
| 17 | } |
| 18 | |
| 19 | public asRect():Rectangle { |
| 20 | if (this.isEmpty()) { |
| 21 | return new Rectangle(0, 0, 0, 0); |
| 22 | } |
| 23 | return new Rectangle(this._xBegin, |
| 24 | this._yBegin, |
| 25 | this._xEnd - this._xBegin, |
| 26 | this._yEnd - this._yBegin); |
| 27 | } |
| 28 | |
| 29 | public isEmpty():boolean { |
| 30 | return this._xBegin === null || this._yBegin === null || |
| 31 | this._xEnd === null || this._yEnd === null; |
| 32 | } |
| 33 | |
| 34 | public reset():void { |
| 35 | this._xBegin = null; |
| 36 | this._xEnd = null; |
| 37 | this._yBegin = null; |
| 38 | this._yEnd = null; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Bitmap AS3 Polyfill class |
nothing calls this directly
no outgoing calls
no test coverage detected