Clamp transparency value (at least for set)

This commit is contained in:
Ken authored and GitHub committed 2017-08-31 09:24:41 +08:00
1 parent 8a77329c79
commit f61366643d
1 file changed
+4 -4
+4 -4
View File
@@ -382,8 +382,8 @@ class Scratch3PenBlocks {
*/
changePenTransparencyBy (args, util) {
const penState = this._getPenState(util.target);
penState.penAttributes.color4f[3] = penState.penAttributes.color4f[3] + (args.TRANSPARENCY / 100);
const TRANSPARENCY = args.TRANSPARENCY / 100;
penState.penAttributes.color4f[3] = penState.penAttributes.color4f[3] + TRANSPARENCY;
this._updatePenColor(penState);
}
@@ -395,8 +395,8 @@ class Scratch3PenBlocks {
*/
setPenTransparencyTo (args, util) {
const penState = this._getPenState(util.target);
penState.penAttributes.color4f[3] = args.TRANSPARENCY / 100;
const TRANSPARENCY = MathUtil.clamp(args.TRANSPARENCY, 0, 100) / 100;
penState.penAttributes.color4f[3] = TRANSPARENCY;
this._updatePenColor(penState);
}
}