From b31080139aa97c632afc95312b8305105805aab1 Mon Sep 17 00:00:00 2001 From: edoardoo Date: Sun, 9 Aug 2015 14:23:47 +0200 Subject: [PATCH] fixed inverted y bug, odd/even rows --- public/scripts/functions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/scripts/functions.js b/public/scripts/functions.js index ac7f6f4..fff6569 100644 --- a/public/scripts/functions.js +++ b/public/scripts/functions.js @@ -58,7 +58,7 @@ function populateHoneycomb( honeyCells , index){ var cellHeigth = (cellWidth / Math.sqrt(3))*2; var canvas = document.createElement("canvas"); canvas.id = "canvas_"+index; - canvas.width = honeyCells.width*cellWidth; + canvas.width = (honeyCells.width+1)*cellWidth; var heightDifference = 0; for( var i = 0; i < honeyCells.height; i++){ heightDifference = ((cellHeigth-(cellHeigth/2))/2)*i; @@ -80,7 +80,7 @@ function populateHoneycomb( honeyCells , index){ var context = canvas.getContext('2d'); for (var i = 0; i < honeyCells.height; i++) { - var even = (i%2 == 0) ? true : false; + var even = (i%2 == 0) ? false : true; for (var j = 0; j < honeyCells.width; j++) { var startx = (even) ? j*cellWidth : (j*cellWidth)+(cellWidth*0.5); var starty = i*cellHeigth-((cellHeigth-(cellHeigth/2))/2)*i; @@ -111,8 +111,8 @@ function setFilled( honeyCells, cellsToCheck, className, cellWidth, cellHeigth, for (var i = 0; i < cellsToCheck.length; i++) { var x = cellsToCheck[i].x; - var y = honeyCells.height - cellsToCheck[i].y; - var even = ( y % 2 == 0 ) ? true : false; + var y = cellsToCheck[i].y; + var even = ( y % 2 == 0 ) ? false : true; var startx = (even) ? x*cellWidth : (x*cellWidth)+(cellWidth*0.5); var starty = y*cellHeigth-((cellHeigth-(cellHeigth/2))/2)*y; context.drawImage(urlToImageMap['images/'+className+'.png'], startx, starty , cellWidth, cellHeigth);