From 85ebc2369b86efc5e5a6988e74f7a01d1006e9f1 Mon Sep 17 00:00:00 2001 From: Viraj Mahesh Date: Mon, 10 Mar 2014 22:21:20 -0700 Subject: Added ability to save pen trails Added dropdown menu to choose what to save --- blocks.js | 13 +++++++++++++ objects.js | 26 +++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/blocks.js b/blocks.js index 480545d..04d10e8 100644 --- a/blocks.js +++ b/blocks.js @@ -665,6 +665,19 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { // single-arg and specialized multi-arg slots: switch (spec) { + case '%imgsource': + part = new InputSlotMorph( + null, // text + false, // non-numeric + { + 'pen trails': ['pen trails'], + 'stage image': ['stage image'] + }, + true + ); + part.setContents(['pen trails']); + part.canBeEmpty = false; + break; case '%inputs': part = new MultiArgMorph('%s', 'with inputs'); part.isStatic = false; diff --git a/objects.js b/objects.js index 28c652d..5cb48ee 100644 --- a/objects.js +++ b/objects.js @@ -812,8 +812,8 @@ SpriteMorph.prototype.initBlocks = function () { doScreenshot: { type: 'command', category: 'sensing', - spec: 'save stage image as costume named %s', - defaults: ['screenshot'] + spec: 'save %imgsource as costume named %s', + defaults: ['pen trails', 'screenshot'] }, // Operators @@ -1755,6 +1755,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(block('doSetFastTracking')); blocks.push('-'); blocks.push(block('doScreenshot')); + blocks.push('-'); blocks.push(block('reportDate')); // for debugging: /////////////// @@ -3705,16 +3706,23 @@ SpriteMorph.prototype.reactToDropOf = function (morph, hand) { morph.slideBackTo(hand.grabOrigin); }; -SpriteMorph.prototype.doScreenshot = function (data) { - if (this.screenshotNames.hasOwnProperty(data)) { +SpriteMorph.prototype.doScreenshot = function (imgSource, data) { + var canvas, + stage, + costume; + if (this.screenshotNames.hasOwnProperty(data)) { // Screenshot naming this.screenshotNames[data] += 1; data += '(' + this.screenshotNames[data] + ')'; } else { this.screenshotNames[data] = 0; } - var stage = this.parentThatIsA(StageMorph), - canvas = stage.fullImageClassic(), - costume = new Costume(canvas, data); + if (imgSource[0] === "pen trails") { + canvas = this.trailsCanvas; + } else if (imgSource[0] === "stage image") { + stage = this.parentThatIsA(StageMorph); + canvas = stage.fullImageClassic(); + } + costume = new Costume(canvas, data); this.addCostume(costume); }; @@ -4482,7 +4490,7 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('doScreenshot')) + blocks.push(block('doScreenshot')); // for debugging: /////////////// @@ -4822,7 +4830,7 @@ StageMorph.prototype.deleteVariable = SpriteMorph.prototype.deleteVariable; // StageMorph block rendering StageMorph.prototype.doScreenshot - = SpriteMorph.prototype.doScreenshot; + = SpriteMorph.prototype.doScreenshot; StageMorph.prototype.blockForSelector = SpriteMorph.prototype.blockForSelector; -- cgit v1.3.1