Phaser.Component.Crop = function (){ } ; Phaser.Component.Crop.prototype = { cropRect: null , _crop: null , crop: function (rect, copy){ if (copy === undefined) { copy = false ; } if (rect) { if (copy && this.cropRect !== null ) { this.cropRect.setTo(rect.x, rect.y, rect.width, rect.height); } else if (copy && this.cropRect === null ) { this.cropRect = new Phaser.Rectangle(rect.x, rect.y, rect.width, rect.height); } else { this.cropRect = rect; } this.updateCrop(); } else { this._crop = null ; this.cropRect = null ; this.resetFrame(); } } , updateCrop: function (){ if (!this.cropRect) { return ; } this._crop = Phaser.Rectangle.clone(this.cropRect, this._crop); this._crop.x += this._frame.x; this._crop.y += this._frame.y; var cx = Math.max(this._frame.x, this._crop.x); var cy = Math.max(this._frame.y, this._crop.y); var cw = Math.min(this._frame.right, this._crop.right) - cx; var ch = Math.min(this._frame.bottom, this._crop.bottom) - cy; this.texture.crop.x = cx; this.texture.crop.y = cy; this.texture.crop.width = cw; this.texture.crop.height = ch; this.texture.frame.width = Math.min(cw, this.cropRect.width); this.texture.frame.height = Math.min(ch, this.cropRect.height); this.texture.width = this.texture.frame.width; this.texture.height = this.texture.frame.height; this.texture._updateUvs(); } } ;