diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ae55353..1122612 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1,7 +1,5 @@ var Container = require('../display/Container'), - Texture = require('../textures/Texture'), RenderTexture = require('../textures/RenderTexture'), - CanvasRenderTarget = require('../renderers/canvas/utils/CanvasRenderTarget'), GraphicsData = require('./GraphicsData'), Sprite = require('../sprites/Sprite'), math = require('../math'), @@ -675,34 +673,6 @@ return this; }; -/** - * Useful function that returns a texture of the graphics object that can then be used to create sprites - * This can be quite useful if your geometry is complicated and needs to be reused multiple times. - * - * @param resolution {number} The resolution of the texture being generated - * @param scaleMode {number} Should be one of the scaleMode consts - * @return {PIXI.Texture} a texture of the graphics object - */ -Graphics.prototype.generateTexture = function (renderer, resolution, scaleMode) -{ - - resolution = resolution || 1; - - var bounds = this.getLocalBounds(); - - var canvasRenderTarget = new CanvasRenderTarget(bounds.width * resolution, bounds.height * resolution); - - var texture = Texture.fromCanvas(canvasRenderTarget.canvas, scaleMode); - texture.baseTexture.resolution = resolution; - - canvasRenderTarget.context.scale(resolution, resolution); - - canvasRenderTarget.context.translate(-bounds.x,-bounds.y); - - CanvasGraphics.renderGraphics(this, canvasRenderTarget.context); - - return texture; -}; /** * Renders the object using the WebGL renderer diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index ae55353..1122612 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1,7 +1,5 @@ var Container = require('../display/Container'), - Texture = require('../textures/Texture'), RenderTexture = require('../textures/RenderTexture'), - CanvasRenderTarget = require('../renderers/canvas/utils/CanvasRenderTarget'), GraphicsData = require('./GraphicsData'), Sprite = require('../sprites/Sprite'), math = require('../math'), @@ -675,34 +673,6 @@ return this; }; -/** - * Useful function that returns a texture of the graphics object that can then be used to create sprites - * This can be quite useful if your geometry is complicated and needs to be reused multiple times. - * - * @param resolution {number} The resolution of the texture being generated - * @param scaleMode {number} Should be one of the scaleMode consts - * @return {PIXI.Texture} a texture of the graphics object - */ -Graphics.prototype.generateTexture = function (renderer, resolution, scaleMode) -{ - - resolution = resolution || 1; - - var bounds = this.getLocalBounds(); - - var canvasRenderTarget = new CanvasRenderTarget(bounds.width * resolution, bounds.height * resolution); - - var texture = Texture.fromCanvas(canvasRenderTarget.canvas, scaleMode); - texture.baseTexture.resolution = resolution; - - canvasRenderTarget.context.scale(resolution, resolution); - - canvasRenderTarget.context.translate(-bounds.x,-bounds.y); - - CanvasGraphics.renderGraphics(this, canvasRenderTarget.context); - - return texture; -}; /** * Renders the object using the WebGL renderer diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 28b2972..f37befe 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -224,6 +224,15 @@ } }; +/** + * Useful function that returns a texture of the display object that can then be used to create sprites + * This can be quite useful if your displayObject is complicated and needs to be reused multiple times. + * + * @param displayObject {number} The displayObject the object will be generated from + * @param scaleMode {number} Should be one of the scaleMode consts + * @param resolution {number} The resolution of the texture being generated + * @return {PIXI.Texture} a texture of the graphics object + */ SystemRenderer.prototype.generateTexture = function (displayObject, scaleMode, resolution) { var bounds = displayObject.getLocalBounds();