mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Add new blocks
change pen transparency by (num) set pen transparency to (num)
This commit is contained in:
parent
f6189903f8
commit
e30e5809d1
1 changed files with 29 additions and 1 deletions
|
@ -214,7 +214,9 @@ class Scratch3PenBlocks {
|
||||||
pen_changepenshadeby: this.changePenShadeBy,
|
pen_changepenshadeby: this.changePenShadeBy,
|
||||||
pen_setpenshadeto: this.setPenShadeToNumber,
|
pen_setpenshadeto: this.setPenShadeToNumber,
|
||||||
pen_changepensizeby: this.changePenSizeBy,
|
pen_changepensizeby: this.changePenSizeBy,
|
||||||
pen_setpensizeto: this.setPenSizeTo
|
pen_setpensizeto: this.setPenSizeTo,
|
||||||
|
pen_changepentransparencyby: this.changePenTransparencyBy,
|
||||||
|
pen_setpentransparencyto: this.setPenTransparencyTo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +373,32 @@ class Scratch3PenBlocks {
|
||||||
const penAttributes = this._getPenState(util.target).penAttributes;
|
const penAttributes = this._getPenState(util.target).penAttributes;
|
||||||
penAttributes.diameter = this._clampPenSize(Cast.toNumber(args.SIZE));
|
penAttributes.diameter = this._clampPenSize(Cast.toNumber(args.SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pen "change pen transparency by {number}" block changes the "transparency" of the pen, related to the RGB value.
|
||||||
|
* @param {object} args - the block arguments.
|
||||||
|
* @property {number} TRANSPARENCY - the amount of desired transparency change.
|
||||||
|
* @param {object} util - utility object provided by the runtime.
|
||||||
|
*/
|
||||||
|
changePenTransparencyBy (args, util) {
|
||||||
|
const penState = this._getPenState(util.target);
|
||||||
|
|
||||||
|
penState.penAttributes.color4f[3] = penState.penAttributes.color4f[3] + (args.TRANSPARENCY / 255);
|
||||||
|
this._updatePenColor(penState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pen "set pen transparency to {number}" block sets the "transparency" of the pen, related to the RGB value.
|
||||||
|
* @param {object} args - the block arguments.
|
||||||
|
* @property {number} TRANSPARENCY - the amount of desired transparency change.
|
||||||
|
* @param {object} util - utility object provided by the runtime.
|
||||||
|
*/
|
||||||
|
setPenTransparencyTo (args, util) {
|
||||||
|
const penState = this._getPenState(util.target);
|
||||||
|
|
||||||
|
penState.penAttributes.color4f[3] = args.TRANSPARENCY / 255;
|
||||||
|
this._updatePenColor(penState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Scratch3PenBlocks;
|
module.exports = Scratch3PenBlocks;
|
||||||
|
|
Loading…
Reference in a new issue