added pen attribute reporter

pull/89/head
jmoenig 2019-04-09 16:58:26 +02:00
rodzic a6891658a4
commit ac3e7aeda1
3 zmienionych plików z 36 dodań i 0 usunięć

Wyświetl plik

@ -23,6 +23,7 @@
* pixel access primitives for bitmap and vector (!) graphics
* new "stretch" primitive for costumes, also for flipping
* new "get graphic effect" reporter
* new "get pen attribute" reporter
* added "neg" selector to monadic function reporter in "Operators" category
* added "log2" selector to monadic function reporter in "Operators" category
* added "^" reporter (power of) in the Operators category
@ -73,6 +74,7 @@
* Objects, Threads: added "current" to costume input slot dropdown
* Blocks: deprecated graphic effects: "duplicate", "comic" and "confetti"
* Objects: added reporter for graphic effects
* Objects, Blocks: added pen attribute reporter
### 2019-04-08
* Blocks, Objects, Threads: new "getSoundAttribute" reporter primitive

Wyświetl plik

@ -1369,6 +1369,21 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
);
part.setContents(['hue']);
break;
case '%pen':
part = new InputSlotMorph(
null,
false,
{
size : ['size'],
hue : ['hue'],
saturation : ['saturation'],
brightness : ['brightness'],
transparency : ['transparency']
},
true
);
part.setContents(['hue']);
break;
case '%asp': // aspect
part = new InputSlotMorph(
null,

Wyświetl plik

@ -602,6 +602,12 @@ SpriteMorph.prototype.initBlocks = function () {
spec: 'change pen %hsva by %n',
defaults: [['hue'], 10]
},
getPenAttribute: {
type: 'reporter',
category: 'pen',
spec: 'pen %pen',
defaults: [['hue']]
},
setBackgroundColor: {
only: StageMorph,
type: 'command',
@ -2117,6 +2123,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('setColor'));
blocks.push(block('changePenHSVA'));
blocks.push(block('setPenHSVA'));
blocks.push(block('getPenAttribute'));
blocks.push('-');
blocks.push(block('changeSize'));
blocks.push(block('setSize'));
@ -3914,6 +3921,15 @@ SpriteMorph.prototype.setColor = function (aColor) {
SpriteMorph.prototype.setBackgroundColor = SpriteMorph.prototype.setColor;
SpriteMorph.prototype.getPenAttribute = function (attrib) {
var name = attrib instanceof Array ? attrib[0] : null,
options = ['hue', 'saturation', 'brightness', 'transparency'];
if (name === 'size') {
return this.size || 0;
}
return this.getColorComponentHSLA(options.indexOf(name));
};
// SpriteMorph layers
SpriteMorph.prototype.comeToFront = function () {
@ -8079,6 +8095,9 @@ StageMorph.prototype.setColor = function (aColor) {
StageMorph.prototype.setBackgroundColor = StageMorph.prototype.setColor;
StageMorph.prototype.getPenAttribute
= SpriteMorph.prototype.getPenAttribute;
// StageMorph pseudo-inherited behavior
StageMorph.prototype.categories = SpriteMorph.prototype.categories;