diff --git a/HISTORY.md b/HISTORY.md index 4b72676e..8c52374f 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,6 +5,7 @@ ### 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 +* symbols: added hooks for dynamic coloring ### 2020-07-19 * blocks: blocks-fade-out support for label arrows (under construction) diff --git a/snap.html b/snap.html index bdb787f1..3d3eef96 100755 --- a/snap.html +++ b/snap.html @@ -5,7 +5,7 @@ Snap! Build Your Own Blocks 6.0.1 - dev - - + diff --git a/src/symbols.js b/src/symbols.js index 3b168a79..d5b3d014 100644 --- a/src/symbols.js +++ b/src/symbols.js @@ -41,7 +41,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.symbols = '2020-July-13'; +modules.symbols = '2020-July-20'; var SymbolMorph; @@ -194,6 +194,18 @@ SymbolMorph.prototype.setLabelColor = function ( this.setColor(textColor); }; +// SymbolMorph dynamic coloring: + +SymbolMorph.prototype.getRenderColor = function () { + // answer the rendering color, can be overridden for my children + return this.color; +}; + +SymbolMorph.prototype.getShadowRenderColor = function () { + // answer the shadow rendering color, can be overridden for my children + return this.shadowColor; +}; + // SymbolMorph layout: SymbolMorph.prototype.setExtent = function (aPoint) { @@ -221,12 +233,12 @@ SymbolMorph.prototype.render = function (ctx) { if (this.shadowColor) { ctx.save(); ctx.translate(sx, sy); - this.renderShape(ctx, this.shadowColor); + this.renderShape(ctx, this.getShadowRenderColor()); ctx.restore(); } ctx.save(); ctx.translate(x, y); - this.renderShape(ctx, this.color); + this.renderShape(ctx, this.getRenderColor()); ctx.restore(); };