From 573d421d02572cdbc321ca94e8bd15eba55210d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Tue, 26 Sep 2017 09:03:33 +0200 Subject: [PATCH] added 'keyboard' and 'keyboardFilled' icons --- history.txt | 6 ++++- symbols.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/history.txt b/history.txt index c5c9dd4b..f368cb1e 100755 --- a/history.txt +++ b/history.txt @@ -3653,6 +3653,10 @@ Fixes: * Objects: added "Make a block" button to every category * Symbols, Objects: new "floating" make-a-block button in the palette +170926 +------ +* Symbols: added 'keyboard' and 'keyboardFilled' icons + v4.1 Features: * polymorphic sprite-local custom blocks @@ -3671,7 +3675,7 @@ v4.1 Features: * sprites’s rotation centers can be adjusted onstage * clones share their original sprite’s scripts, not a shallow-copy of them * a highlight-colored balloon indicates the number of active processes per shared script -* new musical “notes”, "location", "footprints" and "cross" symbols +* new musical “notes”, "location", "footprints", "cross" and "keyboard" symbols * new “visible stepping” toggle button in the control bar * turn on the “Inheritance support” setting per default * Assert data types to list operations for more meaningful error messages diff --git a/symbols.js b/symbols.js index 61577ed4..eb7fa163 100644 --- a/symbols.js +++ b/symbols.js @@ -41,7 +41,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.symbols = '2017-September-25'; +modules.symbols = '2017-September-26'; var SymbolMorph; @@ -51,8 +51,8 @@ WorldMorph.prototype.customMorphs = function () { return [ new SymbolMorph( - 'footprints', - 18, + 'keyboardFilled', + 50, new Color(250, 250, 250), new Point(-1, -1), new Color(20, 20, 20) @@ -134,7 +134,9 @@ SymbolMorph.prototype.names = [ 'notes', 'camera', 'location', - 'footprints' + 'footprints', + 'keyboard', + 'keyboardFilled' ]; // SymbolMorph instance creation: @@ -318,6 +320,10 @@ SymbolMorph.prototype.symbolCanvasColored = function (aColor) { return this.drawSymbolLocation(canvas, aColor); case 'footprints': return this.drawSymbolFootprints(canvas, aColor); + case 'keyboard': + return this.drawSymbolKeyboard(canvas, aColor); + case 'keyboardFilled': + return this.drawSymbolKeyboardFilled(canvas, aColor); default: return canvas; } @@ -350,6 +356,8 @@ SymbolMorph.prototype.symbolWidth = function () { case 'cloudOutline': case 'turnBack': case 'turnForward': + case 'keyboard': + case 'keyboardFilled': return size * 1.6; case 'turnRight': case 'turnLeft': @@ -1676,3 +1684,52 @@ SymbolMorph.prototype.drawSymbolFootprints = function (canvas, color) { ctx.fill(); return canvas; }; + +SymbolMorph.prototype.drawSymbolKeyboard = function (canvas, color) { + // answer a canvas showing a typing keyboard + var ctx = canvas.getContext('2d'), + h = canvas.height, + u = h / 10, + k = h / 5, + row, col; + + ctx.fillStyle = color.toString(); + for (row = 0; row < 2; row += 1) { + for (col = 0; col < 5; col += 1) { + ctx.fillRect( + ((u + k) * col) + u, + ((u + k) * row) + u, + k, + k + ); + } + } + ctx.fillRect(u * 4, u * 7, k * 4, k); + return canvas; +}; + +SymbolMorph.prototype.drawSymbolKeyboardFilled = function (canvas, color) { + // answer a canvas showing a typing keyboard + var ctx = canvas.getContext('2d'), + w = canvas.width, + h = canvas.height, + u = h / 10, + k = h / 5, + row, col; + + ctx.fillStyle = color.toString(); + ctx.fillRect(0, 0, w, h); + ctx.globalCompositeOperation = 'destination-out'; + for (row = 0; row < 2; row += 1) { + for (col = 0; col < 5; col += 1) { + ctx.fillRect( + ((u + k) * col) + u, + ((u + k) * row) + u, + k, + k + ); + } + } + ctx.fillRect(u * 4, u * 7, k * 4, k); + return canvas; +};