From 988a6e835df39b918a2b6daecfb48fdeb76aea72 Mon Sep 17 00:00:00 2001 From: pisouvigne Date: Wed, 3 Jun 2020 17:06:53 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20constantes=20pour=20=C3=A9viter=20les?= =?UTF-8?q?=20magics=20numbers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/js/const.js | 10 ++++++++-- site/js/createElement.js | 11 +++-------- site/js/init.js | 1 - site/vues/jeu.html | 11 +++++------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/site/js/const.js b/site/js/const.js index 030a512..de2a723 100644 --- a/site/js/const.js +++ b/site/js/const.js @@ -1,5 +1,8 @@ -const imageHeight = 50; -const imageWidth = 100; +//Portes Logiques +const imageHeight = 25; +const imageWidth = 50; + +//Image const pathImg = "../img/"; const imageLogiqueEt = "logiqueet.png"; const imageLogiqueOu = "logiqueou.png"; @@ -8,8 +11,11 @@ const imageEnd = "idea_white.png"; //line const colorLineInnactive = "black"; const colorLineActive = "#f6cd61"; +const lineStroke = 1; //switch +const SwitchHeight = 25; +const SwitchWidth = 50; const colorSwitchBorder = "black"; const colorSwitchInnactiveBackground = "red"; const colorSwitchActiveBackground = "green"; \ No newline at end of file diff --git a/site/js/createElement.js b/site/js/createElement.js index 62b09d3..f774173 100644 --- a/site/js/createElement.js +++ b/site/js/createElement.js @@ -24,27 +24,22 @@ function createSwitch(id, x, y) { var rect1 = new Konva.Rect({ x: x, y: y, - width: 100, - height: 50, + width: SwitchWidth, + height: SwitchHeight, stroke: colorSwitchBorder, fill: colorSwitchInnactiveBackground, strokeWidth: 4, id: id, id3: null, }); - - layer.add(rect1); - } function createLine(points, id) { let line = new Konva.Line({ points: points, stroke: colorLineInnactive, - strokeWidth: 3, - lineCap: 'round', - lineJoin: 'round', + strokeWidth: lineStroke, id: id, }); layer.add(line); diff --git a/site/js/init.js b/site/js/init.js index 9a6e20e..ba53bed 100644 --- a/site/js/init.js +++ b/site/js/init.js @@ -17,7 +17,6 @@ function initAllSwitch(){ }); } - function initLayer() { createEnd(500,50); } \ No newline at end of file diff --git a/site/vues/jeu.html b/site/vues/jeu.html index 728eb51..133be3e 100644 --- a/site/vues/jeu.html +++ b/site/vues/jeu.html @@ -44,12 +44,11 @@ initLayer(); - createLogique(300, 100, "logique1","et"); - createLogique(600,200,"logique2","ou"); - createLogique(900,300,"logique3","et"); - createLogique(900,500,"logique4","ou"); - createSwitch("s1", 20, 20); - createSwitch("s2", 20, 150); + createLogique(200, 100, "logique1","et"); + createLogique(300,200,"logique2","ou"); + createLogique(500,300,"logique3","et"); + createSwitch("s1", 20, 20,2,2); + createSwitch("s2", 20, 90); createSwitch("s3", 20, 300); createSwitch("s4", 20, 500);