Clamp transparency value (at least for set)
This commit is contained in:
1 parent
8a77329c79
commit
f61366643d
1 file changed
+4
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user