diff --git a/HISTORY.md b/HISTORY.md index d8038e1b..f141cc10 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -80,6 +80,7 @@ ### 2019-05-08 * Blocks, Objects, Threads: integrated video capture control into global settings prims in Sensing * Blocks, Threads: added a %self menu +* Blocks, Threads, Objects: Finalized Video ops ### 2019-05-07 * Blocks, Objects, Threads, Video: optimized video motion detection diff --git a/src/blocks.js b/src/blocks.js index d70ed7a7..3a018622 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -1723,6 +1723,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { // Video motion +/* // +++ to be removed case '%vid': // video modes part = new InputSlotMorph( null, @@ -1734,7 +1735,8 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { true ); break; - case '%motype': +*/ + case '%vid': part = new InputSlotMorph( null, false, { @@ -2407,7 +2409,7 @@ SyntaxElementMorph.prototype.endLayout = function () { %f - round function slot, unevaluated if replaced, %r - round reporter slot %p - hexagonal predicate slot - %vid - chameleon colored rectangular drop-down for video modes + %vid - chameleon colored rectangular drop-down for video modes // +++ check these %motype - chameleon colored rectangular drop-down for motion type %on - chameleon colored rectangular drop-down for motion detection scope diff --git a/src/objects.js b/src/objects.js index a5662a71..13c675b9 100644 --- a/src/objects.js +++ b/src/objects.js @@ -1369,17 +1369,19 @@ SpriteMorph.prototype.initBlocks = function () { spec: 'set video transparency to %n', defaults: [50] }, - reportMotionOn: { + reportVideo: { type: 'reporter', category: 'sensing', - spec: 'video %motype on %on', - defaults: ['motion', 'this sprite'] + spec: 'video %vid on %self', + defaults: [['motion'], ['myself']] }, + /* // +++ to be removed reportMotionOnStage: { type: 'reporter', category: 'sensing', spec: 'video %motype on stage' } + */ }; }; @@ -2334,7 +2336,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { if (SpriteMorph.prototype.enableVideo) { blocks.push(block('doSetVideoTransparency')); - blocks.push(block('reportMotionOn')); + blocks.push(block('reportVideo')); blocks.push('-'); } @@ -8054,7 +8056,7 @@ StageMorph.prototype.blockTemplates = function (category) { if (SpriteMorph.prototype.enableVideo) { blocks.push(block('doSetVideoTransparency')); - blocks.push(block('reportMotionOnStage')); + blocks.push(block('reportVideo')); blocks.push('-'); } diff --git a/src/threads.js b/src/threads.js index 73ff5a37..ba6dd72d 100644 --- a/src/threads.js +++ b/src/threads.js @@ -4442,17 +4442,41 @@ Process.prototype.doSetVideoTransparency = function(factor) { } }; +/* // +++ to be removed Process.prototype.reportMotionOnStage = function(motionType) { return this.reportMotionOn(motionType, 'stage'); }; +*/ -Process.prototype.reportMotionOn = function(motionType, on) { - var stage = this.homeContext.receiver.parentThatIsA(StageMorph), - sprite = this.blockReceiver(), - result; - if (stage === null || !stage.videoElement) { +Process.prototype.reportVideo = function(attribute, name) { // +++ + var thisObj = this.blockReceiver(), + stage = thisObj.parentThatIsA(StageMorph), + thatObj = this.getOtherObject(name, thisObj, stage); + + if (!stage || !stage.videoElement) { return null; } + + + switch (this.inputOption(attribute)) { + case 'motion': + if (thatObj instanceof SpriteMorph) { + stage.videoMotion.getLocalMotion(thatObj); + return thatObj.motionAmount; + } + stage.videoMotion.getStageMotion(); + return stage.videoMotion.motionAmount; + case 'direction': + if (thatObj instanceof SpriteMorph) { + stage.videoMotion.getLocalMotion(thatObj); + return thatObj.motionDirection; + } + stage.videoMotion.getStageMotion(); + return stage.videoMotion.motionDirection; + } + return -1; + +/* // +++ remove switch (this.inputOption(on)) { case 'stage': stage.videoMotion.getStageMotion(); @@ -4474,6 +4498,7 @@ Process.prototype.reportMotionOn = function(motionType, on) { break; } return result; +*/ }; // Process code mapping