Fix for Support ARGB for pen #393

Requires fix to scratch-render before this will work (see:
6f5acfee7b961d71237f1fd50bb3d5a5139c527e)
This commit is contained in:
griffpatch 2017-01-27 12:49:32 +00:00
parent bdabe2efa3
commit b856041d9a
2 changed files with 5 additions and 1 deletions

View file

@ -258,6 +258,9 @@ Scratch3PenBlocks.prototype.setPenColorToColor = function (args, util) {
penState.penAttributes.color4f[0] = rgb.r / 255.0; penState.penAttributes.color4f[0] = rgb.r / 255.0;
penState.penAttributes.color4f[1] = rgb.g / 255.0; penState.penAttributes.color4f[1] = rgb.g / 255.0;
penState.penAttributes.color4f[2] = rgb.b / 255.0; penState.penAttributes.color4f[2] = rgb.b / 255.0;
if (rgb.hasOwnProperty('a')) { // Will there always be an 'a'?
penState.penAttributes.color4f[3] = rgb.a/255.0;
}
}; };
/** /**

View file

@ -40,10 +40,11 @@ Color.decimalToHex = function (decimal) {
* @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}. * @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
*/ */
Color.decimalToRgb = function (decimal) { Color.decimalToRgb = function (decimal) {
var a = (decimal >> 24) & 0xFF;
var r = (decimal >> 16) & 0xFF; var r = (decimal >> 16) & 0xFF;
var g = (decimal >> 8) & 0xFF; var g = (decimal >> 8) & 0xFF;
var b = decimal & 0xFF; var b = decimal & 0xFF;
return {r: r, g: g, b: b}; return {r: r, g: g, b: b, a: a>0 ? a : 255};
}; };
/** /**