diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index fc503dc..26033c4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -187,6 +187,9 @@ this._spriteRect = null; this._fastRect = false; + this._prevRectTint = null; + this._prevRectFillColor = null; + /** * When cacheAsBitmap is set to true the graphics object will be rendered as if it was a sprite. * This is useful if your graphics element does not change often, as it will speed up the rendering @@ -962,17 +965,18 @@ } const sprite = this._spriteRect; + const fillColor = this.graphicsData[0].fillColor; if (this.tint === 0xffffff) { - sprite.tint = this.graphicsData[0].fillColor; + sprite.tint = fillColor; } - else + else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor) { const t1 = tempColor1; const t2 = tempColor2; - hex2rgb(this.graphicsData[0].fillColor, t1); + hex2rgb(fillColor, t1); hex2rgb(this.tint, t2); t1[0] *= t2[0]; @@ -980,7 +984,11 @@ t1[2] *= t2[2]; sprite.tint = rgb2hex(t1); + + this._prevRectTint = this.tint; + this._prevRectFillColor = fillColor; } + sprite.alpha = this.graphicsData[0].fillAlpha; sprite.worldAlpha = this.worldAlpha * sprite.alpha; sprite.blendMode = this.blendMode;