-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhands-blockly.js
39 lines (37 loc) · 1.16 KB
/
hands-blockly.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
+(async function (window, webduino) {
'use strict';
window.createOrGetVideoEle = function (id, url, width, height) {
var videlem = document.getElementById(id);
if (videlem == null) {
var videlem = document.createElement("video");
videlem.id = id;
document.body.appendChild(videlem);
}
var sourceMP4 = document.createElement("source");
videlem.appendChild(sourceMP4);
sourceMP4.type = "video/mp4";
sourceMP4.src = url;
videlem.width = width;
videlem.height = height;
return videlem;
}
window.createCamera = function (camSource, width, height, rotate, flip) {
function pageX(elem) {
return elem.offsetParent ? elem.offsetLeft + pageX(elem.offsetParent) : elem.offsetLeft;
}
function pageY(elem) {
return elem.offsetParent ? elem.offsetTop + pageY(elem.offsetParent) : elem.offsetTop;
}
var c1 = document.createElement('canvas');
c1.width = width;
c1.height = height;
document.body.appendChild(c1);
var cam = new Camera(camSource);
cam.setFlip(flip);
cam.setCanvas(c1);
if (rotate) {
cam.setRotate(90);
}
return cam;
}
}(window, window.webduino));