The GameObjects.Graphics.fillGradientStyle method can now accept a different alpha value for each of the fill colors. The default is still 1. If you only provide a single alpha, it'll be used for all colors. Fix #5044

This commit is contained in:
Richard Davey 2020-10-16 18:08:31 +01:00
parent 5605a683ac
commit 48d9eb6321
2 changed files with 25 additions and 13 deletions

View file

@ -335,21 +335,28 @@ var Graphics = new Class({
* @webglOnly
* @since 3.12.0
*
* @param {integer} topLeft - The tint being applied to the top-left of the Game Object.
* @param {integer} topRight - The tint being applied to the top-right of the Game Object.
* @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object.
* @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object.
* @param {number} [alpha=1] - The fill alpha.
* @param {integer} topLeft - The top left fill color.
* @param {integer} topRight - The top right fill color.
* @param {integer} bottomLeft - The bottom left fill color.
* @param {integer} bottomRight - The bottom right fill color. Not used when filling triangles.
* @param {number} [alphaTopLeft=1] - The top left alpha value. If you give only this value, it's used for all corners.
* @param {number} [alphaTopRight=1] - The top right alpha value.
* @param {number} [alphaBottomLeft=1] - The bottom left alpha value.
* @param {number} [alphaBottomRight=1] - The bottom right alpha value.
*
* @return {this} This Game Object.
*/
fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alpha)
fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alphaTopLeft, alphaTopRight, alphaBottomLeft, alphaBottomRight)
{
if (alpha === undefined) { alpha = 1; }
if (alphaTopLeft === undefined) { alphaTopLeft = 1; }
if (alphaTopRight === undefined) { alphaTopRight = alphaTopLeft; }
if (alphaBottomLeft === undefined) { alphaBottomLeft = alphaTopLeft; }
if (alphaBottomRight === undefined) { alphaBottomRight = alphaTopLeft; }
this.commandBuffer.push(
Commands.GRADIENT_FILL_STYLE,
alpha, topLeft, topRight, bottomLeft, bottomRight
alphaTopLeft, alphaTopRight, alphaBottomLeft, alphaBottomRight,
topLeft, topRight, bottomLeft, bottomRight
);
return this;

View file

@ -177,11 +177,16 @@ var GraphicsWebGLRenderer = function (renderer, src, camera, parentMatrix)
break;
case Commands.GRADIENT_FILL_STYLE:
var gradientFillAlpha = commands[++cmdIndex] * alpha;
fillTint.TL = getTint(commands[++cmdIndex], gradientFillAlpha);
fillTint.TR = getTint(commands[++cmdIndex], gradientFillAlpha);
fillTint.BL = getTint(commands[++cmdIndex], gradientFillAlpha);
fillTint.BR = getTint(commands[++cmdIndex], gradientFillAlpha);
var alphaTL = commands[++cmdIndex] * alpha;
var alphaTR = commands[++cmdIndex] * alpha;
var alphaBL = commands[++cmdIndex] * alpha;
var alphaBR = commands[++cmdIndex] * alpha;
fillTint.TL = getTint(commands[++cmdIndex], alphaTL);
fillTint.TR = getTint(commands[++cmdIndex], alphaTR);
fillTint.BL = getTint(commands[++cmdIndex], alphaBL);
fillTint.BR = getTint(commands[++cmdIndex], alphaBR);
break;
case Commands.GRADIENT_LINE_STYLE: