Spaces:
Runtime error
Runtime error
send hidden graphic unmirrored
Browse files- public/sketch.js +13 -4
public/sketch.js
CHANGED
|
@@ -19,6 +19,8 @@ let camConfig = "user";
|
|
| 19 |
let isOnMobile;
|
| 20 |
let camIsON = false;
|
| 21 |
|
|
|
|
|
|
|
| 22 |
function isMobileDevice() {
|
| 23 |
return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
|
| 24 |
}
|
|
@@ -54,7 +56,9 @@ function call_api(socket, instructions){
|
|
| 54 |
console.log("Calling API ... ")
|
| 55 |
waiting = true;
|
| 56 |
show_loading()
|
| 57 |
-
cnv_data = myCanvas.elt.toDataURL('image/png');
|
|
|
|
|
|
|
| 58 |
let data = [
|
| 59 |
cnv_data,
|
| 60 |
instructions
|
|
@@ -72,15 +76,19 @@ function windowResized() {
|
|
| 72 |
|
| 73 |
function setup() {
|
| 74 |
pixelDensity(1)
|
| 75 |
-
if(windowWidth
|
| 76 |
-
|
|
|
|
| 77 |
} else {
|
| 78 |
-
|
|
|
|
| 79 |
}
|
| 80 |
background(220)
|
| 81 |
myCanvas.id('myCanvas')
|
| 82 |
myCanvas.parent("canvas-container")
|
| 83 |
|
|
|
|
|
|
|
| 84 |
socket.on("api_response", (response) => {
|
| 85 |
waiting = false;
|
| 86 |
clearTimeout(timerWaiting)
|
|
@@ -238,6 +246,7 @@ function draw() {
|
|
| 238 |
text('turn on your webcam', width/2, height/2);
|
| 239 |
|
| 240 |
if(capture != undefined){
|
|
|
|
| 241 |
if(!active_rearcam){
|
| 242 |
push()
|
| 243 |
//move image by the width of image to the left
|
|
|
|
| 19 |
let isOnMobile;
|
| 20 |
let camIsON = false;
|
| 21 |
|
| 22 |
+
let graphicsToSend;
|
| 23 |
+
|
| 24 |
function isMobileDevice() {
|
| 25 |
return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
|
| 26 |
}
|
|
|
|
| 56 |
console.log("Calling API ... ")
|
| 57 |
waiting = true;
|
| 58 |
show_loading()
|
| 59 |
+
//cnv_data = myCanvas.elt.toDataURL('image/png');
|
| 60 |
+
graphicsToSend.loadPixels()
|
| 61 |
+
cnv_data = graphicsToSend.canvas.toDataURL('image/png');
|
| 62 |
let data = [
|
| 63 |
cnv_data,
|
| 64 |
instructions
|
|
|
|
| 76 |
|
| 77 |
function setup() {
|
| 78 |
pixelDensity(1)
|
| 79 |
+
if(windowWidth <= 550){
|
| 80 |
+
resizeCanvas(390, 390*320/576);
|
| 81 |
+
graphicsToSend.resizeCanvas(myCanvas.width, myCanvas.height);
|
| 82 |
} else {
|
| 83 |
+
resizeCanvas(576, 320);
|
| 84 |
+
graphicsToSend.resizeCanvas(myCanvas.width, myCanvas.height);
|
| 85 |
}
|
| 86 |
background(220)
|
| 87 |
myCanvas.id('myCanvas')
|
| 88 |
myCanvas.parent("canvas-container")
|
| 89 |
|
| 90 |
+
graphicsToSend = createGraphics(myCanvas.width, myCanvas.height)
|
| 91 |
+
|
| 92 |
socket.on("api_response", (response) => {
|
| 93 |
waiting = false;
|
| 94 |
clearTimeout(timerWaiting)
|
|
|
|
| 246 |
text('turn on your webcam', width/2, height/2);
|
| 247 |
|
| 248 |
if(capture != undefined){
|
| 249 |
+
graphicsToSend.image(capture, 0, 0)
|
| 250 |
if(!active_rearcam){
|
| 251 |
push()
|
| 252 |
//move image by the width of image to the left
|