Created
April 17, 2018 12:33
-
-
Save mrmccormack/eab8bee5278972704a00dcf6c56e8408 to your computer and use it in GitHub Desktop.
IM415 Simple Camera App
This file contains 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
const { Button, ImageView, ui } = require('tabris') | |
const widthPhoto = 300 | |
const heightPhoto = 400 | |
function takePhoto () { | |
let onSuccess = image => imgPhoto.image = image | |
let onFail = message => console.log('Camera failed because: ' + message) | |
navigator.camera.getPicture(onSuccess, onFail, { | |
quality: 50, | |
targetWidth: widthPhoto, | |
targetHeight: heightPhoto, | |
destinationType: window.Camera.DestinationType.FILE_URI | |
}) | |
} | |
let btnShutter = new Button({ centerX: 0, top: 40, text: 'Take Picture' }) | |
.on('select', () => { | |
takePhoto() | |
}).appendTo(ui.contentView) | |
let imgPhoto = new ImageView({ | |
top: 'prev() 10', | |
class: 'image', | |
width: widthPhoto, | |
height: heightPhoto, | |
centerX: 0, | |
image: 'https://raw.githubusercontent.com/mrmccormack/imd-learning-tabris/master/images/photo.png', | |
scaleMode: 'fit', | |
zoomEnabled: true | |
}).appendTo(ui.contentView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment