mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-05-02 00:07:24 +08:00
Ajout d'un exemple de grille. Encore des soucis lorsque l'on tourne l'écran. Changer l'optention du width / height pour prendre celui de l'écran total (pour palier au soucis de barre de notification visible ou non.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user