Last active
January 2, 2016 13:49
-
-
Save scottgwald/8313043 to your computer and use it in GitHub Desktop.
[wearscript] Two ways to take a photo and show *on canvas*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html style="width:100%; height:100%; overflow:hidden"> | |
| <body style="width:100%; height:100%; overflow:hidden; margin:0"> | |
| <canvas id="myCanvas" width="640" height="360"></canvas> | |
| <script> | |
| function photoPath(data) { | |
| WS.say("I got your photo"); | |
| var img = new Image(); | |
| img.src = data; | |
| img.onload = function() { | |
| context.drawImage(img, 0, 0, canvas.width, canvas.height); | |
| } | |
| } | |
| function photo(data) { | |
| WS.say("I got your camera photo"); | |
| var img = new Image(); | |
| img.src = 'data:image/jpeg;base64,' + data; | |
| img.onload = function() { | |
| context.drawImage(img, 0, 0, canvas.width, canvas.height); | |
| } | |
| } | |
| function main() { | |
| canvas = document.getElementById('myCanvas'); | |
| context = canvas.getContext('2d'); | |
| if (WS.scriptVersion(1)) return; | |
| //WS.cameraPhotoPath('photoPath'); | |
| WS.cameraPhoto('photo'); | |
| } | |
| window.onload = main; | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "Canvas Photo" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment