From 000bf48699944089d3968ae90dc89f9035e255f2 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 29 Apr 2020 12:15:10 +0200 Subject: [PATCH] refactored blocks coloring --- src/blocks.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/blocks.js b/src/blocks.js index 8bfcbb94..f6ee5047 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -3869,13 +3869,13 @@ BlockMorph.prototype.scriptPic = function () { fb = this.stackFullBounds(), pic = newCanvas(fb.extent()), ctx = pic.getContext('2d'); - this.allComments().forEach(function (comment) { + this.allComments().forEach(comment => ctx.drawImage( comment.fullImage(), comment.fullBounds().left() - fb.left(), comment.top() - fb.top() - ); - }); + ) + ); ctx.drawImage(scr, 0, 0); return pic; }; @@ -4087,10 +4087,8 @@ BlockMorph.prototype.highlightImageBlurred = function (color, blur) { BlockMorph.prototype.getHighlight = function () { var highlights; - highlights = this.children.slice(0).reverse().filter( - function (child) { - return child instanceof BlockHighlightMorph; - } + highlights = this.children.slice(0).reverse().filter(child => + child instanceof BlockHighlightMorph ); if (highlights.length !== 0) { return highlights[0]; @@ -4210,12 +4208,11 @@ BlockMorph.prototype.fixLabelColor = function () { }; BlockMorph.prototype.fixChildrensBlockColor = function (isForced) { - var myself = this; - this.children.forEach(function (morph) { + this.children.forEach(morph => { if (morph instanceof CommandBlockMorph) { morph.fixBlockColor(null, isForced); } else if (morph instanceof SyntaxElementMorph) { - morph.fixBlockColor(myself, isForced); + morph.fixBlockColor(this, isForced); if (morph instanceof BooleanSlotMorph) { morph.fixLayout(); } @@ -4229,9 +4226,7 @@ BlockMorph.prototype.setCategory = function (aString) { }; BlockMorph.prototype.hasLabels = function () { - return this.children.some(function (any) { - return any instanceof StringMorph; - }); + return this.children.some(any => any instanceof StringMorph); }; // BlockMorph copying