diff options
| author | jmoenig <jens@moenig.org> | 2013-04-17 17:28:49 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-04-17 17:28:49 +0200 |
| commit | 06d35dae6c6810c3db369b0cf6902c1af3e6f956 (patch) | |
| tree | b663e4aae943db63d6a0b7061e4e1daafefcc821 /blocks.js | |
| parent | 15718f44a30a022a5f45001f3fd2d506da504ff1 (diff) | |
| download | snap-byow-06d35dae6c6810c3db369b0cf6902c1af3e6f956.tar.gz snap-byow-06d35dae6c6810c3db369b0cf6902c1af3e6f956.zip | |
Export picture of all scripts
* new entry in the ScriptsMorph's userMenu lets you export a picture of
all scripts, including comments.
* place sticky comments on World layer on dragging their anchor block,
fixes both #8 and #18
* additional settings for developing the backend
Diffstat (limited to 'blocks.js')
| -rw-r--r-- | blocks.js | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2013-April-05'; +modules.blocks = '2013-April-17'; var SyntaxElementMorph; var BlockMorph; @@ -4285,6 +4285,11 @@ ScriptsMorph.prototype.userMenu = function () { } menu.addItem('clean up', 'cleanUp', 'arrange scripts\nvertically'); menu.addItem('add comment', 'addComment'); + menu.addItem( + 'scripts pic...', + 'exportScriptsPicture', + 'open a new window\nwith a picture of all scripts' + ); if (ide) { menu.addLine(); menu.addItem( @@ -4343,6 +4348,29 @@ ScriptsMorph.prototype.cleanUp = function () { this.adjustBounds(); }; +ScriptsMorph.prototype.exportScriptsPicture = function () { + var boundingBox, pic, ctx; + if (this.children.length === 0) {return; } + boundingBox = this.children[0].fullBounds(); + this.children.forEach(function (child) { + if (child.isVisible) { + boundingBox = boundingBox.merge(child.fullBounds()); + } + }); + pic = newCanvas(boundingBox.extent()); + ctx = pic.getContext('2d'); + this.children.forEach(function (child) { + var pos = child.position(); + if (child.isVisible) { + ctx.drawImage( + child.fullImageClassic(), + pos.x - boundingBox.origin.x, + pos.y - boundingBox.origin.y + ); + } + }); + window.open(pic.toDataURL()); +}; ScriptsMorph.prototype.addComment = function () { new CommentMorph().pickUp(this.world()); @@ -9057,6 +9085,7 @@ CommentMorph.prototype.align = function (topBlock, ignoreLayer) { CommentMorph.prototype.startFollowing = function (topBlock) { var myself = this; this.align(topBlock); + this.world().add(this); this.addShadow(); this.stickyOffset = this.position().subtract(this.block.position()); this.step = function () { |
