diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 698ab59..5069940 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -244,16 +244,18 @@ * @param {PIXI.DisplayObject} displayObject - The displayObject the object will be generated from * @param {number} scaleMode - Should be one of the scaleMode consts * @param {number} resolution - The resolution / device pixel ratio of the texture being generated + * @param {PIXI.Rectangle} [region] - The region of the displayObject, that shall be rendered, + * if no region is specified, defaults to the local bounds of the displayObject. * @return {PIXI.Texture} a texture of the graphics object */ - generateTexture(displayObject, scaleMode, resolution) + generateTexture(displayObject, scaleMode, resolution, region) { - const bounds = displayObject.getLocalBounds(); + region = region || displayObject.getLocalBounds(); - const renderTexture = RenderTexture.create(bounds.width | 0, bounds.height | 0, scaleMode, resolution); + const renderTexture = RenderTexture.create(region.width | 0, region.height | 0, scaleMode, resolution); - tempMatrix.tx = -bounds.x; - tempMatrix.ty = -bounds.y; + tempMatrix.tx = -region.x; + tempMatrix.ty = -region.y; this.render(displayObject, renderTexture, false, tempMatrix, true);