X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Futils%2FprintDiagram.js;h=524e12bca3d67c3affcdb3af4baa4fbadbc9ec63;hb=e50a802531b99829c533f22ecd21e359e7e1e049;hp=00ff2c792f3329d6cd055c70acfbd18c0c503806;hpb=07052665845283c65b50a76537669d0602ba436b;p=vchess.git diff --git a/client/src/utils/printDiagram.js b/client/src/utils/printDiagram.js index 00ff2c79..524e12bc 100644 --- a/client/src/utils/printDiagram.js +++ b/client/src/utils/printDiagram.js @@ -1,4 +1,5 @@ import { ArrayFun } from "@/utils/array"; +import { store } from "@/store"; // Turn (human) marks into coordinates function getMarkArray(marks) { @@ -18,7 +19,7 @@ function getShadowArray(shadow) { let shadowArray = ArrayFun.init(V.size.x, V.size.y, false); const squares = shadow.split(","); for (let i = 0; i < squares.length; i++) { - const rownum = V.size.x - parseInt(squares[i]); + const rownum = V.size.x - parseInt(squares[i], 10); if (!isNaN(rownum)) { // Shadow a full row for (let i = 0; i < V.size.y; i++) shadowArray[rownum][i] = true; @@ -64,6 +65,10 @@ function getShadowArray(shadow) { // args: object with position (mandatory), and // orientation, marks, shadow (optional) +// TODO: in time, find a strategy to draw middle lines (weiqi, xianqi...) +// and maybe also some diagonals (fanorona...) +// https://stackoverflow.com/questions/40697231/horizontal-line-in-the-middle-of-divs +// + CSS rotate? export function getDiagram(args) { // Obtain the array of pieces images names: const board = V.GetBoard(args.position); @@ -75,15 +80,22 @@ export function getDiagram(args) { const [startX, startY, inc] = orientation == "w" ? [0, 0, 1] : [V.size.x - 1, V.size.y - 1, -1]; for (let i = startX; i >= 0 && i < V.size.x; i += inc) { - boardDiv += "
"; + boardDiv += "
"; for (let j = startY; j >= 0 && j < V.size.y; j += inc) { - boardDiv += - "
"; + boardDiv += "
"; if (board[i][j] != V.EMPTY) { boardDiv += "