Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderer.render(this, renderTexture, true, m, false);
// now restore the state be setting the new properties
renderer.context = cachedRenderTarget;
this.renderCanvas = this._renderCachedCanvas;
// the rest is the same as for WebGL
this.updateTransform = this.displayObjectUpdateTransform;
this.calculateBounds = this._calculateCachedBounds;
this.getLocalBounds = this._getCachedLocalBounds;
this._mask = null;
this.filterArea = null;
// create our cached sprite
const cachedSprite = new Sprite(renderTexture);
cachedSprite.transform.worldTransform = this.transform.worldTransform;
cachedSprite.anchor.x = -(bounds.x / bounds.width);
cachedSprite.anchor.y = -(bounds.y / bounds.height);
cachedSprite.alpha = cacheAlpha;
cachedSprite._bounds = this._bounds;
this._cacheData.sprite = cachedSprite;
this.transform._parentID = -1;
// restore the transform of the cached sprite to avoid the nasty flicker..
if (!this.parent)
{
this.parent = renderer._tempDisplayObjectParent;
this.updateTransform();
this.parent = null;
}
const lenChars = chars.length;
const tint = this.tint;
for (let i = 0; i < lenChars; i++)
{
let c = this._glyphs[i]; // get the next glyph sprite
if (c)
{
c.texture = chars[i].texture;
}
else
{
c = new Sprite(chars[i].texture);
this._glyphs.push(c);
}
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
c.position.y = chars[i].position.y * scale;
c.scale.x = c.scale.y = scale;
c.tint = tint;
if (!c.parent)
{
this.addChild(c);
}
}
// remove unnecessary children.
for (let i = lenChars; i < this._glyphs.length; ++i)
}
const lenChars = chars.length;
const tint = this.tint;
for (let i = 0; i < lenChars; i++)
{
let c = this._glyphs[i]; // get the next glyph sprite
if (c)
{
c.texture = chars[i].texture;
}
else
{
c = new Sprite(chars[i].texture);
c.roundPixels = this.roundPixels;
this._glyphs.push(c);
}
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
c.position.y = chars[i].position.y * scale;
c.scale.x = c.scale.y = scale;
c.tint = tint;
if (!c.parent)
{
this.addChild(c);
}
}
// remove unnecessary children.
renderer.renderTexture.bind(cachedRenderTarget);
// renderer.filterManager.filterStack = stack;
this.render = this._renderCached;
// the rest is the same as for Canvas
this.updateTransform = this.displayObjectUpdateTransform;
this.calculateBounds = this._calculateCachedBounds;
this.getLocalBounds = this._getCachedLocalBounds;
this._mask = null;
this.filterArea = null;
// create our cached sprite
const cachedSprite = new Sprite(renderTexture);
cachedSprite.transform.worldTransform = this.transform.worldTransform;
cachedSprite.anchor.x = -(bounds.x / bounds.width);
cachedSprite.anchor.y = -(bounds.y / bounds.height);
cachedSprite.alpha = cacheAlpha;
cachedSprite._bounds = this._bounds;
this._cacheData.sprite = cachedSprite;
this.transform._parentID = -1;
// restore the transform of the cached sprite to avoid the nasty flicker..
if (!this.parent)
{
this.parent = renderer._tempDisplayObjectParent;
this.updateTransform();
this.parent = null;
_renderSpriteRect(renderer)
{
const rect = this.graphicsData[0].shape;
if (!this._spriteRect)
{
this._spriteRect = new Sprite(new Texture(Texture.WHITE));
}
const sprite = this._spriteRect;
const fillColor = this.graphicsData[0].fillColor;
if (this.tint === 0xffffff)
{
sprite.tint = fillColor;
}
else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor)
{
const t1 = tempColor1;
const t2 = tempColor2;
hex2rgb(fillColor, t1);
hex2rgb(this.tint, t2);
* Cached tinted texture.
* @memberof PIXI.Sprite#
* @member {HTMLCanvasElement} _tintedCanvas
* @protected
*/
Sprite.prototype._tintedCanvas = null;
/**
* Renders the object using the Canvas renderer
*
* @private
* @method _renderCanvas
* @memberof PIXI.Sprite#
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
Sprite.prototype._renderCanvas = function _renderCanvas(renderer)
{
renderer.plugins.sprite.render(this);
};
import { Sprite } from '@pixi/sprite';
/**
* Cached tinted texture.
* @memberof PIXI.Sprite#
* @member {HTMLCanvasElement} _tintedCanvas
* @protected
*/
Sprite.prototype._tintedCanvas = null;
/**
* Renders the object using the Canvas renderer
*
* @private
* @method _renderCanvas
* @memberof PIXI.Sprite#
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
Sprite.prototype._renderCanvas = function _renderCanvas(renderer)
{
renderer.plugins.sprite.render(this);
};