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,9 @@
|
|||||||
|
platforms/*
|
||||||
|
!platforms/.gitkeep
|
||||||
|
|
||||||
|
plugins/*
|
||||||
|
!plugins/.gitkeep
|
||||||
|
|
||||||
|
node_modules/*
|
||||||
|
|
||||||
|
*.DS_Store
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<widget id="org.geneanet.customCamera.grid" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||||
|
<name>grid</name>
|
||||||
|
<description>
|
||||||
|
A sample Apache Cordova application that responds to the deviceready event.
|
||||||
|
</description>
|
||||||
|
<author email="dev@cordova.apache.org" href="http://cordova.io">
|
||||||
|
Apache Cordova Team
|
||||||
|
</author>
|
||||||
|
<content src="index.html" />
|
||||||
|
<access origin="*" />
|
||||||
|
</widget>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="format-detection" content="telephone=no" />
|
||||||
|
<meta name="msapplication-tap-highlight" content="no" />
|
||||||
|
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
|
||||||
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
|
||||||
|
<title>Grid</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="my-canvas"></canvas>
|
||||||
|
<button id="start-camera">Start camera</button>
|
||||||
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
|
<script type="text/javascript" src="js/index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -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