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