Browse Source

fixed inverted y bug, odd/even rows

visualizer2
edoardoo 10 years ago
parent
commit
b31080139a
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      public/scripts/functions.js

+ 4
- 4
public/scripts/functions.js View File

@ -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);


Loading…
Cancel
Save