--- /dev/null
+-- PrisePhoto.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+
+-- Instanciation de l'objet
+
+PrisePhoto = {}
+
+-- Constructeur
+
+function PrisePhoto:new()
+
+prisePhoto = display.newGroup()
+
+-- fonction d'activation de la prise de photo
+local function onPhoto( event )
+
+ if isPhotoActive then
+
+ -- fonction de gestion de la prise de photo
+ local function onComplete( event )
+
+ local newPhoto = event.target
+
+ -- si la prise de photo n'est pas annulée
+ if newPhoto ~= nil then
+
+ local btn = prisePhoto.boutonPhoto
+
+ -- Une photo a été prise
+ isPhotoTaken = true
+
+ -- sauvegarder la photo
+ display.save( newPhoto, { filename = "photo.jpg", baseDir = system.TemporaryDirectory } )
+
+ -- masquer l'ancienne photo
+ local clear = display.newRect( 0, 0, btn.width, btn.height )
+ clear:setFillColor( 0, 0, 0 )
+ clear.anchorX = 0
+ clear.anchorY = 0
+ -- prisePhoto:insert( clear )
+
+ -- nouvelle photo
+ photo = newPhoto
+ photo.anchorX = 0
+ photo.anchorY = 0
+ photo.x = btn.x
+ photo.y = btn.y
+ photo.width = 70
+ photo.height = 70
+ photo.alpha = 1
+ ticket:insert( photo )
+
+ end
+
+ end
+
+ -- si le terminal a un appareil photo, on déclenche la prise
+ if media.hasSource( media.Camera ) then
+ media.capturePhoto( { listener = onComplete } )
+ else
+ native.showAlert( "Hum.", "Ce terminal n'a pas d'appareil photo.", { "OK" } )
+ end
+
+ end
+
+end
+
+-- le bouton cliquable
+local boutonPhoto = widget.newButton
+{
+ shape = "rect",
+ width = 70,
+ height = 70,
+ fillColor = { default = { 253/255, 105/255, 0, .5 }, over = { 253/255, 105/255, 0, .8 } },
+ onRelease = onPhoto,
+
+}
+prisePhoto:insert( boutonPhoto )
+prisePhoto.boutonPhoto = boutonPhoto
+
+photo = display.newRect( 0, 0, 80, 80 )
+photo.alpha = 0
+prisePhoto:insert( photo )
+
+-- le bouton est initialisé, il devient actif
+isPhotoActive = true
+
+return prisePhoto
+
+end
+
+return prisePhoto
\ No newline at end of file