From 9e0b9348f568aba08b08a775e2bed1285b9753ba Mon Sep 17 00:00:00 2001 From: Christophe Boucaut Date: Wed, 28 Jan 2015 11:36:07 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20exemple=20de=20grille.=20Encore?= =?UTF-8?q?=20des=20soucis=20lorsque=20l'on=20tourne=20l'=C3=A9cran.=20Cha?= =?UTF-8?q?nger=20l'optention=20du=20width=20/=20height=20pour=20prendre?= =?UTF-8?q?=20celui=20de=20l'=C3=A9cran=20total=20(pour=20palier=20au=20so?= =?UTF-8?q?ucis=20de=20barre=20de=20notification=20visible=20ou=20non.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/grid/.gitignore | 9 ++++++ examples/grid/config.xml | 12 ++++++++ examples/grid/www/index.html | 35 +++++++++++++++++++++++ examples/grid/www/js/index.js | 52 +++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 examples/grid/.gitignore create mode 100644 examples/grid/config.xml create mode 100644 examples/grid/www/index.html create mode 100644 examples/grid/www/js/index.js diff --git a/examples/grid/.gitignore b/examples/grid/.gitignore new file mode 100644 index 0000000..602549b --- /dev/null +++ b/examples/grid/.gitignore @@ -0,0 +1,9 @@ +platforms/* +!platforms/.gitkeep + +plugins/* +!plugins/.gitkeep + +node_modules/* + +*.DS_Store \ No newline at end of file diff --git a/examples/grid/config.xml b/examples/grid/config.xml new file mode 100644 index 0000000..693fc7c --- /dev/null +++ b/examples/grid/config.xml @@ -0,0 +1,12 @@ + + + grid + + A sample Apache Cordova application that responds to the deviceready event. + + + Apache Cordova Team + + + + diff --git a/examples/grid/www/index.html b/examples/grid/www/index.html new file mode 100644 index 0000000..7b8556c --- /dev/null +++ b/examples/grid/www/index.html @@ -0,0 +1,35 @@ + + + + + + + + + + Grid + + + + + + + + diff --git a/examples/grid/www/js/index.js b/examples/grid/www/js/index.js new file mode 100644 index 0000000..6231fa9 --- /dev/null +++ b/examples/grid/www/js/index.js @@ -0,0 +1,52 @@ +function getGrid() { + var format = "image/png"; + var width = window.innerWidth * devicePixelRatio; + var height = window.innerHeight * devicePixelRatio; + var widthInterval = width * 0.25; + var heightInterval = height * 0.25; + var x = widthInterval; + var y = heightInterval; + + var canvas = document.getElementById('my-canvas');; + canvas.width = width; + canvas.height = height; + + var ctx = canvas.getContext("2d"); + + ctx.beginPath(); + + while (x < width) { + ctx.moveTo(x, 0); + ctx.lineTo(x, height); + x += widthInterval; + } + + while (y < height) { + ctx.moveTo(0, y); + ctx.lineTo(width, y); + y += heightInterval; + } + ctx.stroke(); + + ctx.closePath(); + + var base64 = canvas.toDataURL(format); + + return base64.replace(/data:[^\/]*\/[^\,]*,/, ""); +}; + +document.getElementById("start-camera").onclick = function() { + navigator.GeneanetCustomCamera.startCamera( + { + imgBackgroundBase64: getGrid(), + opacity: false, + miniature: false + }, + function() { + window.console.log("success"); + }, + function() { + window.console.log("fail"); + } + ); +} \ No newline at end of file