diff options
| author | jmoenig <jens@moenig.org> | 2013-04-30 13:49:14 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-04-30 13:49:14 +0200 |
| commit | 1505796e19fa90ea858fc348aa2cd79817f0aab6 (patch) | |
| tree | 0671cc6e69a0593edecc3f98a1ac71e897244201 /blocks.js | |
| parent | ed3b9d1959a2b0a98ae9ce0eaf04356871ecd1e7 (diff) | |
| download | snap-byow-1505796e19fa90ea858fc348aa2cd79817f0aab6.tar.gz snap-byow-1505796e19fa90ea858fc348aa2cd79817f0aab6.zip | |
Eraser symbol
Diffstat (limited to 'blocks.js')
| -rw-r--r-- | blocks.js | 38 |
1 files changed, 35 insertions, 3 deletions
@@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2013-April-29'; +modules.blocks = '2013-April-30'; var SyntaxElementMorph; var BlockMorph; @@ -188,14 +188,14 @@ WorldMorph.prototype.customMorphs = function () { /* return [ new SymbolMorph( - 'paintbucket', + 'eraser', 50, new Color(250, 250, 250), new Point(-1, -1), new Color(20, 20, 20) ) ]; -*/ + /* var sm = new ScriptsMorph(); sm.setExtent(new Point(800, 600)); @@ -6826,6 +6826,8 @@ SymbolMorph.prototype.symbolCanvasColored = function (aColor) { return this.drawSymbolCrosshairs(canvas, aColor); case 'paintbucket': return this.drawSymbolPaintbucket(canvas, aColor); + case 'eraser': + return this.drawSymbolEraser(canvas, aColor); default: return canvas; } @@ -7583,6 +7585,36 @@ SymbolMorph.prototype.drawSymbolPaintbucket = function (canvas, color) { return canvas; }; +SymbolMorph.prototype.drawSymbolEraser = function (canvas, color) { + // answer a canvas showing an eraser + var ctx = canvas.getContext('2d'), + w = canvas.width, + h = canvas.height, + n = canvas.width / 4, + l = Math.max(w / 20, 0.5); + + ctx.strokeStyle = color.toString(); + ctx.lineWidth = l * 2; + ctx.beginPath(); + ctx.moveTo(n * 3, l); + ctx.lineTo(l, n * 3); + ctx.quadraticCurveTo(n, h, n * 2, n * 3); + ctx.lineTo(w - l, n); + ctx.closePath(); + ctx.stroke(); + + ctx.fillStyle = color.toString(); + ctx.beginPath(); + ctx.moveTo(n * 3, 0); + ctx.lineTo(n * 1.5, n * 1.5); + ctx.lineTo(n * 2.5, n * 2.5); + ctx.lineTo(w, n); + ctx.closePath(); + ctx.fill(); + + return canvas; +}; + // ColorSlotMorph ////////////////////////////////////////////////////// /* |
