Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/blocks/scratch3_pen.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ Scratch3PenBlocks.prototype.setPenColorToColor = function (args, util) {
penState.penAttributes.color4f[0] = rgb.r / 255.0;
penState.penAttributes.color4f[1] = rgb.g / 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;

This comment was marked as abuse.

}
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/util/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ Color.decimalToHex = function (decimal) {
* @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
*/
Color.decimalToRgb = function (decimal) {
var a = (decimal >> 24) & 0xFF;
var r = (decimal >> 16) & 0xFF;
var g = (decimal >> 8) & 0xFF;
var b = decimal & 0xFF;
return {r: r, g: g, b: b};
return {r: r, g: g, b: b, a: a>0 ? a : 255};

This comment was marked as abuse.

};

/**
Expand Down