finalized video ops

pull/89/head
jmoenig 2019-05-08 10:40:46 +02:00
rodzic 03acf231cd
commit f1e49f7cde
4 zmienionych plików z 42 dodań i 12 usunięć

Wyświetl plik

@ -80,6 +80,7 @@
### 2019-05-08 ### 2019-05-08
* Blocks, Objects, Threads: integrated video capture control into global settings prims in Sensing * Blocks, Objects, Threads: integrated video capture control into global settings prims in Sensing
* Blocks, Threads: added a %self menu * Blocks, Threads: added a %self menu
* Blocks, Threads, Objects: Finalized Video ops
### 2019-05-07 ### 2019-05-07
* Blocks, Objects, Threads, Video: optimized video motion detection * Blocks, Objects, Threads, Video: optimized video motion detection

Wyświetl plik

@ -1723,6 +1723,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
// Video motion // Video motion
/* // +++ to be removed
case '%vid': // video modes case '%vid': // video modes
part = new InputSlotMorph( part = new InputSlotMorph(
null, null,
@ -1734,7 +1735,8 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
true true
); );
break; break;
case '%motype': */
case '%vid':
part = new InputSlotMorph( part = new InputSlotMorph(
null, null,
false, { false, {
@ -2407,7 +2409,7 @@ SyntaxElementMorph.prototype.endLayout = function () {
%f - round function slot, unevaluated if replaced, %f - round function slot, unevaluated if replaced,
%r - round reporter slot %r - round reporter slot
%p - hexagonal predicate 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 %motype - chameleon colored rectangular drop-down for motion type
%on - chameleon colored rectangular drop-down for motion detection scope %on - chameleon colored rectangular drop-down for motion detection scope

Wyświetl plik

@ -1369,17 +1369,19 @@ SpriteMorph.prototype.initBlocks = function () {
spec: 'set video transparency to %n', spec: 'set video transparency to %n',
defaults: [50] defaults: [50]
}, },
reportMotionOn: { reportVideo: {
type: 'reporter', type: 'reporter',
category: 'sensing', category: 'sensing',
spec: 'video %motype on %on', spec: 'video %vid on %self',
defaults: ['motion', 'this sprite'] defaults: [['motion'], ['myself']]
}, },
/* // +++ to be removed
reportMotionOnStage: { reportMotionOnStage: {
type: 'reporter', type: 'reporter',
category: 'sensing', category: 'sensing',
spec: 'video %motype on stage' spec: 'video %motype on stage'
} }
*/
}; };
}; };
@ -2334,7 +2336,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
if (SpriteMorph.prototype.enableVideo) { if (SpriteMorph.prototype.enableVideo) {
blocks.push(block('doSetVideoTransparency')); blocks.push(block('doSetVideoTransparency'));
blocks.push(block('reportMotionOn')); blocks.push(block('reportVideo'));
blocks.push('-'); blocks.push('-');
} }
@ -8054,7 +8056,7 @@ StageMorph.prototype.blockTemplates = function (category) {
if (SpriteMorph.prototype.enableVideo) { if (SpriteMorph.prototype.enableVideo) {
blocks.push(block('doSetVideoTransparency')); blocks.push(block('doSetVideoTransparency'));
blocks.push(block('reportMotionOnStage')); blocks.push(block('reportVideo'));
blocks.push('-'); blocks.push('-');
} }

Wyświetl plik

@ -4442,17 +4442,41 @@ Process.prototype.doSetVideoTransparency = function(factor) {
} }
}; };
/* // +++ to be removed
Process.prototype.reportMotionOnStage = function(motionType) { Process.prototype.reportMotionOnStage = function(motionType) {
return this.reportMotionOn(motionType, 'stage'); return this.reportMotionOn(motionType, 'stage');
}; };
*/
Process.prototype.reportMotionOn = function(motionType, on) { Process.prototype.reportVideo = function(attribute, name) { // +++
var stage = this.homeContext.receiver.parentThatIsA(StageMorph), var thisObj = this.blockReceiver(),
sprite = this.blockReceiver(), stage = thisObj.parentThatIsA(StageMorph),
result; thatObj = this.getOtherObject(name, thisObj, stage);
if (stage === null || !stage.videoElement) {
if (!stage || !stage.videoElement) {
return null; 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)) { switch (this.inputOption(on)) {
case 'stage': case 'stage':
stage.videoMotion.getStageMotion(); stage.videoMotion.getStageMotion();
@ -4474,6 +4498,7 @@ Process.prototype.reportMotionOn = function(motionType, on) {
break; break;
} }
return result; return result;
*/
}; };
// Process code mapping // Process code mapping