From 7b6306a8f359821b352995f5b9a27ba278dc5d48 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Mon, 19 Apr 2021 15:26:27 +0200 Subject: [PATCH] Fix squares colors on diagrams --- client/src/utils/printDiagram.js | 17 +++++------------ client/src/views/Game.vue | 3 +-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/client/src/utils/printDiagram.js b/client/src/utils/printDiagram.js index ef0d2b55..4a3a50ee 100644 --- a/client/src/utils/printDiagram.js +++ b/client/src/utils/printDiagram.js @@ -73,13 +73,14 @@ export function getDiagram(args) { // Obtain the array of pieces images names: const board = V.GetBoard(args.position); const orientation = args.orientation || "w"; - const darkBottomRight = !!args.darkBottomRight; const markArray = getMarkArray(args.marks); const shadowArray = getShadowArray(args.shadow); - const vr = new V(); //just for pieces images paths + const vr = new V(); //TODO: just for pieces images paths let boardDiv = ""; const [startX, startY, inc] = orientation == "w" ? [0, 0, 1] : [V.size.x - 1, V.size.y - 1, -1]; + let lightOddity = (V.size.x + V.size.y) % 2; + if (V.DarkBottomRight) lightOddity = 1 - lightOddity; for (let i = startX; i >= 0 && i < V.size.x; i += inc) { boardDiv += "<div class='row"; if (i == startX && V.Monochrome) boardDiv += " border-top"; @@ -91,16 +92,8 @@ export function getDiagram(args) { (V.Notoodark ? "middle-square" : "dark-square"); if (j == startY) boardDiv += " border-left"; } - else { - const oddity = (i + j) % 2; - if ( - (oddity == 0 && !V.DarkBottomRight) || - (oddity == 1 && V.DarkBottomRight) - ) { - boardDiv += "light-square"; - } - else boardDiv += "dark-square"; - } + else if ((i + j) % 2 == lightOddity) boardDiv += "light-square"; + else boardDiv += "dark-square"; boardDiv += " " + store.state.settings.bcolor; if (shadowArray.length > 0 && shadowArray[i][j]) boardDiv += " in-shadow"; diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 2968b8f8..0e430fe2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -1618,8 +1618,7 @@ export default { if (["all","byrow"].includes(V.ShowMoves)) { this.curDiag = getDiagram({ position: position, - orientation: V.CanFlip ? this.game.mycolor : "w", - darkBottomRight: V.DarkBottomRight + orientation: V.CanFlip ? this.game.mycolor : "w" }); document.querySelector("#confirmDiv > .card").style.width = boardDiv.offsetWidth + "px"; -- 2.44.0