mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 02:20:17 +01:00
support de différentes tailles de camera
This commit is contained in:
@@ -26,7 +26,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
container_name: phpmyadmin
|
container_name: phpmyadmin
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
db:
|
||||||
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
PMA_ARBITRARY: 1
|
PMA_ARBITRARY: 1
|
||||||
PMA_HOST: db
|
PMA_HOST: db
|
||||||
|
|||||||
11
code/interface_borne/assets/css/main.css
Normal file
11
code/interface_borne/assets/css/main.css
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
body {
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
text-align: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
@@ -3,8 +3,10 @@ class CameraEditor {
|
|||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
this.ctx = canvas.getContext("2d");
|
this.ctx = canvas.getContext("2d");
|
||||||
this.video = document.createElement("video");
|
this.video = document.createElement("video");
|
||||||
this.width = canvas.width;
|
this.width;
|
||||||
this.height;
|
this.height; //calculé automatiquement en fonction de la largeur du flux vidéo
|
||||||
|
this.videoWidth;
|
||||||
|
this.videoHeight;
|
||||||
this.streaming = false;
|
this.streaming = false;
|
||||||
this.activeEffects = [];
|
this.activeEffects = [];
|
||||||
this.images = {};
|
this.images = {};
|
||||||
@@ -27,15 +29,19 @@ class CameraEditor {
|
|||||||
"canplay",
|
"canplay",
|
||||||
(ev) => {
|
(ev) => {
|
||||||
if (!this.streaming) {
|
if (!this.streaming) {
|
||||||
this.height = this.video.videoHeight / (this.video.videoWidth / this.width);
|
//calcul de la taille de la vidéo en fonction de la taille de la fenêtre pour qu'elle soit toujours visible
|
||||||
|
let aspectRatio = this.video.videoWidth / this.video.videoHeight;
|
||||||
// Firefox currently has a bug where the height can't be read from
|
if(window.innerHeight * aspectRatio > window.innerWidth){
|
||||||
// the video, so we will make assumptions if this happens.
|
this.width = window.innerWidth;
|
||||||
|
this.height = window.innerWidth / aspectRatio;
|
||||||
if (isNaN(this.height)) {
|
}else{
|
||||||
this.height = this.width / (4 / 3);
|
this.width = window.innerHeight * aspectRatio;
|
||||||
|
this.height = window.innerHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.videoHeight = this.video.videoHeight;
|
||||||
|
this.videoWidth = this.video.videoWidth;
|
||||||
|
|
||||||
this.video.setAttribute("width", this.width);
|
this.video.setAttribute("width", this.width);
|
||||||
this.video.setAttribute("height", this.height);
|
this.video.setAttribute("height", this.height);
|
||||||
this.canvas.setAttribute("width", this.width);
|
this.canvas.setAttribute("width", this.width);
|
||||||
@@ -65,9 +71,21 @@ class CameraEditor {
|
|||||||
requestAnimationFrame(() => this._frame());
|
requestAnimationFrame(() => this._frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_scaleEffect(x,y,width,height){
|
||||||
|
let xScale = this.width / this.videoWidth;
|
||||||
|
let yScale = this.height / this.videoHeight;
|
||||||
|
return {
|
||||||
|
x: x * xScale,
|
||||||
|
y: y * yScale,
|
||||||
|
width: width * xScale,
|
||||||
|
height: height * yScale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_drawEffects() {
|
_drawEffects() {
|
||||||
for (let {type,x,y,width,height} of this.activeEffects) {
|
for (let effect of this.activeEffects) {
|
||||||
if(type == "thumbs_up"){
|
let {x,y,width,height} = this._scaleEffect(effect.x,effect.y,effect.width,effect.height);
|
||||||
|
if(effect.type == "thumbs_up"){
|
||||||
this._drawThumbsUp(x,y,width,height);
|
this._drawThumbsUp(x,y,width,height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
let cameraEditor;
|
let cameraEditor;
|
||||||
let client
|
let client
|
||||||
|
let canvas;
|
||||||
|
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
cameraEditor = new CameraEditor(document.getElementById("canvas"));
|
canvas = document.createElement("canvas");
|
||||||
|
document.body.appendChild(canvas);
|
||||||
|
cameraEditor = new CameraEditor(canvas);
|
||||||
client = new WebsocketClient((effects) => { cameraEditor.setEffects(effects); });
|
client = new WebsocketClient((effects) => { cameraEditor.setEffects(effects); });
|
||||||
cameraEditor._frame();
|
cameraEditor._frame();
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="assets/css/main.css">
|
||||||
<title>Téléreview</title>
|
<title>Téléreview</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<canvas id="canvas"></canvas>
|
|
||||||
<script src="assets/js/main.js"></script>
|
<script src="assets/js/main.js"></script>
|
||||||
<script src="assets/js/camera_editor.js"></script>
|
<script src="assets/js/camera_editor.js"></script>
|
||||||
<script src="assets/js/network.js"></script>
|
<script src="assets/js/network.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user