diff --git a/HISTORY.md b/HISTORY.md index 81d14785..e8034396 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -51,7 +51,8 @@ ### 2021-11-08 * objects: renamed some internal color methods -* objects, store: renamed internal pen color channel cache +* objects, store: renamed internal pen color channel cache +* objects, blocks, threads: renamed internal pen accessor methods ### 2021-11-07 * widgets, blocks, byob: allow block-instances to be dragged off from templates in the "hide blocks" dialog diff --git a/snap.html b/snap.html index a9f285d0..af851cdb 100755 --- a/snap.html +++ b/snap.html @@ -16,8 +16,8 @@ - - + + diff --git a/src/blocks.js b/src/blocks.js index f46ea5c9..5f93a551 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2021-November-07'; +modules.blocks = '2021-November-08'; var SyntaxElementMorph; var BlockMorph; @@ -646,7 +646,7 @@ SyntaxElementMorph.prototype.labelParts = { back : ['back'] } }, - '%hsva': { + '%clrdim': { type: 'input', tags: 'read-only static', menu: { diff --git a/src/objects.js b/src/objects.js index 7a4782c5..85170684 100644 --- a/src/objects.js +++ b/src/objects.js @@ -630,18 +630,18 @@ SpriteMorph.prototype.initBlocks = function () { category: 'pen', spec: 'set pen color to %clr' }, - setPenHSVA: { + setPenColorDimension: { only: SpriteMorph, type: 'command', category: 'pen', - spec: 'set pen %hsva to %n', + spec: 'set pen %clrdim to %n', defaults: [['hue'], 50] }, - changePenHSVA: { + changePenColorDimension: { only: SpriteMorph, type: 'command', category: 'pen', - spec: 'change pen %hsva by %n', + spec: 'change pen %clrdim by %n', defaults: [['hue'], 10] }, getPenAttribute: { @@ -656,18 +656,18 @@ SpriteMorph.prototype.initBlocks = function () { category: 'pen', spec: 'set background color to %clr' }, - setBackgroundHSVA: { + setBackgroundColorDimension: { only: StageMorph, type: 'command', category: 'pen', - spec: 'set background %hsva to %n', + spec: 'set background %clrdim to %n', defaults: [['hue'], 50] }, - changeBackgroundHSVA: { + changeBackgroundColorDimension: { only: StageMorph, type: 'command', category: 'pen', - spec: 'change background %hsva by %n', + spec: 'change background %clrdim by %n', defaults: [['hue'], 10] }, changeSize: { @@ -1608,25 +1608,41 @@ SpriteMorph.prototype.initBlockMigrations = function () { inputs: [['front']] }, setHue: { - selector: 'setPenHSVA', + selector: 'setPenColorDimension', inputs: [['hue']], offset: 1 }, setBrightness: { - selector: 'setPenHSVA', + selector: 'setPenColorDimension', inputs: [['brightness']], offset: 1 }, + setPenHSVA: { + selector: 'setPenColorDimension', + offset: 0 + }, changeHue: { - selector: 'changePenHSVA', + selector: 'changePenColorDimension', inputs: [['hue']], offset: 1 }, changeBrightness: { - selector: 'changePenHSVA', + selector: 'changePenColorDimension', inputs: [['brightness']], offset: 1 }, + changePenHSVA: { + selector: 'changePenColorDimension', + offset: 0 + }, + setBackgroundHSVA: { + selector: 'setBackgroundColorDimension', + offset: 0 + }, + changeBackgroundHSVA: { + selector: 'changeBackgroundColorDimension', + offset: 0 + }, reportIsFastTracking: { selector: 'reportGlobalFlag', inputs: [['turbo mode']], @@ -1719,10 +1735,10 @@ SpriteMorph.prototype.blockAlternatives = { doPasteOn: ['doCutFrom'], doCutFrom: ['doPasteOn'], doStamp: ['clear', 'down', 'up'], - setPenHSVA: ['changePenHSVA'], - changePenHSVA: ['setPenHSVA'], - setBackgroundHSVA: ['changeBackgroundHSVA'], - changeBackgroundHSVA: ['setBackgroundHSVA'], + setPenColorDimension: ['changePenColorDimension'], + changePenColorDimension: ['setPenColorDimension'], + setBackgroundColorDimension: ['changeBackgroundColorDimension'], + changeBackgroundColorDimension: ['setBackgroundColorDimension'], changeSize: ['setSize'], setSize: ['changeSize'], @@ -2496,8 +2512,8 @@ SpriteMorph.prototype.blockTemplates = function ( blocks.push(block('getPenDown', this.inheritsAttribute('pen down?'))); blocks.push('-'); blocks.push(block('setColor')); - blocks.push(block('changePenHSVA')); - blocks.push(block('setPenHSVA')); + blocks.push(block('changePenColorDimension')); + blocks.push(block('setPenColorDimension')); blocks.push(block('getPenAttribute')); blocks.push('-'); blocks.push(block('changeSize')); @@ -4416,7 +4432,7 @@ SpriteMorph.prototype.reportShown = function () { // SpriteMorph pen color -SpriteMorph.prototype.setColorComponentHSVA = function (idx, num) { +SpriteMorph.prototype.setColorDimension = function (idx, num) { var x = this.xPosition(), y = this.yPosition(), n = +num; @@ -4442,7 +4458,7 @@ SpriteMorph.prototype.setColorComponentHSVA = function (idx, num) { this.gotoXY(x, y); }; -SpriteMorph.prototype.getColorComponentHSVA = function (idx) { +SpriteMorph.prototype.getColorDimension = function (idx) { idx = +idx; if (idx === 3) { return (1 - this.color.a) * 100; @@ -4450,10 +4466,10 @@ SpriteMorph.prototype.getColorComponentHSVA = function (idx) { return (this.cachedColorDimensions[idx] || 0) * 100; }; -SpriteMorph.prototype.changeColorComponentHSVA = function (idx, delta) { - this.setColorComponentHSVA( +SpriteMorph.prototype.changeColorDimension = function (idx, delta) { + this.setColorDimension( idx, - this.getColorComponentHSVA(idx) + (+delta || 0) + this.getColorDimension(idx) + (+delta || 0) ); }; @@ -4478,7 +4494,7 @@ SpriteMorph.prototype.getPenAttribute = function (attrib) { if (name === 'size') { return this.size || 0; } - return this.getColorComponentHSVA(options.indexOf(name)); + return this.getColorDimension(options.indexOf(name)); }; // SpriteMorph layers @@ -8780,8 +8796,8 @@ StageMorph.prototype.blockTemplates = function ( blocks.push(block('clear')); blocks.push('-'); blocks.push(block('setBackgroundColor')); - blocks.push(block('changeBackgroundHSVA')); - blocks.push(block('setBackgroundHSVA')); + blocks.push(block('changeBackgroundColorDimension')); + blocks.push(block('setBackgroundColorDimension')); blocks.push('-'); blocks.push(block('reportPenTrailsAsCostume')); blocks.push('-'); @@ -9262,7 +9278,7 @@ StageMorph.prototype.newClone = nop; // StageMorph background color setting -StageMorph.prototype.setColorComponentHSVA = function (idx, num) { +StageMorph.prototype.setColorDimension = function (idx, num) { var n = +num; idx = +idx; @@ -9283,11 +9299,11 @@ StageMorph.prototype.setColorComponentHSVA = function (idx, num) { this.rerender(); }; -StageMorph.prototype.getColorComponentHSVA - = SpriteMorph.prototype.getColorComponentHSVA; +StageMorph.prototype.getColorDimension = + SpriteMorph.prototype.getColorDimension; -StageMorph.prototype.changeColorComponentHSVA - = SpriteMorph.prototype.changeColorComponentHSVA; +StageMorph.prototype.changeColorDimension = + SpriteMorph.prototype.changeColorDimension; StageMorph.prototype.setColor = function (aColor) { if (!this.color.eq(aColor, true)) { // observeAlpha diff --git a/src/threads.js b/src/threads.js index 33521727..4e18c56c 100644 --- a/src/threads.js +++ b/src/threads.js @@ -4747,26 +4747,33 @@ Process.prototype.doSwitchToScene = function (id, transmission) { // Process color primitives -Process.prototype.setHSVA = function (name, num) { +Process.prototype.setColorDimension = function (name, num) { var options = ['hue', 'saturation', 'brightness', 'transparency']; - this.blockReceiver().setColorComponentHSVA( + this.blockReceiver().setColorDimension( options.indexOf(this.inputOption(name)), +num ); }; -Process.prototype.changeHSVA = function (name, num) { +Process.prototype.changeColorDimension = function (name, num) { var options = ['hue', 'saturation', 'brightness', 'transparency']; - this.blockReceiver().changeColorComponentHSVA( + this.blockReceiver().changeColorDimension( options.indexOf(this.inputOption(name)), +num ); }; -Process.prototype.setPenHSVA = Process.prototype.setHSVA; -Process.prototype.changePenHSVA = Process.prototype.changeHSVA; -Process.prototype.setBackgroundHSVA = Process.prototype.setHSVA; -Process.prototype.changeBackgroundHSVA = Process.prototype.changeHSVA; +Process.prototype.setPenColorDimension = + Process.prototype.setColorDimension; + +Process.prototype.changePenColorDimension = + Process.prototype.changeColorDimension; + +Process.prototype.setBackgroundColorDimension = + Process.prototype.setColorDimension; + +Process.prototype.changeBackgroundColorDimension = + Process.prototype.changeColorDimension; // Process cutting & pasting primitives