From 6b3c1370210ea5009ebab66a6f99bf32848cf78b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 21 Jul 2020 08:28:52 +0200 Subject: [PATCH] tweaked block highlights for fade-out --- HISTORY.md | 3 +++ snap.html | 2 +- src/blocks.js | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 45ebeee3..44b506c5 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,9 @@ ## in development: +### 2020-07-21 +* blocks: tweaked block highlights for fade-out + ### 2020-07-20 * objects: fixed a list-watcher direct-editing offset bug * morphic: update the Hand's position on mouse-down - avoid triggering at the origin point diff --git a/snap.html b/snap.html index 3d3eef96..6760f06a 100755 --- a/snap.html +++ b/snap.html @@ -7,7 +7,7 @@ - + diff --git a/src/blocks.js b/src/blocks.js index 2f7ebc03..6dec32aa 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2020-July-20'; +modules.blocks = '2020-July-21'; var SyntaxElementMorph; var BlockMorph; @@ -785,6 +785,13 @@ SyntaxElementMorph.prototype.unflash = function () { } }; +SyntaxElementMorph.prototype.doWithAlpha = function (alpha, callback) { + var current = this.alpha; + SyntaxElementMorph.prototype.alpha = alpha; + callback(); + SyntaxElementMorph.prototype.alpha = current; +}; + // SyntaxElementMorph zebra coloring SyntaxElementMorph.prototype.fixBlockColor = function ( @@ -4198,7 +4205,7 @@ BlockMorph.prototype.highlight = function (color, blur, border) { BlockMorph.prototype.highlightImage = function (color, border) { var fb, img, hi, ctx, out; fb = this.fullBounds().extent(); - img = this.fullImage(); + this.doWithAlpha(1, () => img = this.fullImage()); hi = newCanvas(fb.add(border * 2)); ctx = hi.getContext('2d'); @@ -4228,7 +4235,7 @@ BlockMorph.prototype.highlightImage = function (color, border) { BlockMorph.prototype.highlightImageBlurred = function (color, blur) { var fb, img, hi, ctx; fb = this.fullBounds().extent(); - img = this.fullImage(); + this.doWithAlpha(1, () => img = this.fullImage()); hi = newCanvas(fb.add(blur * 2)); ctx = hi.getContext('2d');