From 85230f1914d5d7061848b0051dcd2d7975b09ada Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 6 Jun 2019 12:45:08 +0200 Subject: Fix for overlapping lines if match boxes are wider than expected --- playoff.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'playoff.js') diff --git a/playoff.js b/playoff.js index 3b57cdf..e83c33f 100644 --- a/playoff.js +++ b/playoff.js @@ -198,6 +198,18 @@ var playoff = { (lines.vTo[1] + lines.vTo[3]) / 2 ] ] + for (var h in lines.hTo) { + lines.hTo[h][2] = Math.max( + lines.hTo[h][2], + lines.midpoints[2][0] + ); + } + for (var h in lines.hFrom) { + lines.hFrom[h][2] = Math.min( + lines.hFrom[h][2], + lines.midpoints[0][0] + ); + } return lines; } }; @@ -220,10 +232,12 @@ var playoff = { } this.drawLine(ctx, linesToDraw.vTo); for (var m = 0; m < linesToDraw.midpoints.length-1; m++) { - this.drawLine(ctx, [ - linesToDraw.midpoints[m][0], linesToDraw.midpoints[m][1], - linesToDraw.midpoints[m+1][0], linesToDraw.midpoints[m+1][1] - ]); + if (linesToDraw.midpoints[m][0] <= linesToDraw.midpoints[m+1][0]) { + this.drawLine(ctx, [ + linesToDraw.midpoints[m][0], linesToDraw.midpoints[m][1], + linesToDraw.midpoints[m+1][0], linesToDraw.midpoints[m+1][1] + ]); + } } } } -- cgit v1.2.3