Clamp transparency value (at least for set)

This commit is contained in:
Ken 2017-08-31 09:24:41 +08:00 committed by GitHub
parent 8a77329c79
commit f61366643d

View file

@ -382,8 +382,8 @@ class Scratch3PenBlocks {
*/ */
changePenTransparencyBy (args, util) { changePenTransparencyBy (args, util) {
const penState = this._getPenState(util.target); const penState = this._getPenState(util.target);
const TRANSPARENCY = args.TRANSPARENCY / 100;
penState.penAttributes.color4f[3] = penState.penAttributes.color4f[3] + (args.TRANSPARENCY / 100); penState.penAttributes.color4f[3] = penState.penAttributes.color4f[3] + TRANSPARENCY;
this._updatePenColor(penState); this._updatePenColor(penState);
} }
@ -395,8 +395,8 @@ class Scratch3PenBlocks {
*/ */
setPenTransparencyTo (args, util) { setPenTransparencyTo (args, util) {
const penState = this._getPenState(util.target); const penState = this._getPenState(util.target);
const TRANSPARENCY = MathUtil.clamp(args.TRANSPARENCY, 0, 100) / 100;
penState.penAttributes.color4f[3] = args.TRANSPARENCY / 100; penState.penAttributes.color4f[3] = TRANSPARENCY;
this._updatePenColor(penState); this._updatePenColor(penState);
} }
} }