Browse Source

fixed wrong row shift problem

visualizer2
edoardoo 9 years ago
parent
commit
88271fab2c
2 changed files with 8 additions and 4 deletions
  1. +4
    -3
      public/scripts/functions.js
  2. +4
    -1
      sample_problems/problem_1.json

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

@ -19,6 +19,7 @@ function loadImageGroup(urls, onCompleteFunc) {
}
function prePopulate(honeyCells){
var honeyCells = JSON.parse(honeyCells);
console.dir(honeyCells);
var urls = [
'images/neutral.png',
'images/active.png',
@ -80,7 +81,7 @@ function populateHoneycomb( honeyCells , index){
var context = canvas.getContext('2d');
for (var i = 0; i < honeyCells.height; i++) {
var even = (i%2 == 0) ? false : true;
var even = (i%2 == 0) ? true : false;
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;
@ -112,7 +113,7 @@ function setFilled( honeyCells, cellsToCheck, className, cellWidth, cellHeigth,
for (var i = 0; i < cellsToCheck.length; i++) {
var x = cellsToCheck[i].x;
var y = cellsToCheck[i].y;
var even = ( y % 2 == 0 ) ? false : true;
var even = ( y % 2 == 0 ) ? true : false;
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);
@ -156,7 +157,7 @@ function slidePlay(){
if( play.getAttribute("data-intervalId") == "-1"){
var intervalID = setInterval( function(){
slideForward();
}, 500);
}, 50);
play.setAttribute('data-intervalId', intervalID);
}else{
var intervalID = play.getAttribute("data-intervalId");


+ 4
- 1
sample_problems/problem_1.json View File

@ -1 +1,4 @@
{"height":15,"width":15,"sourceSeeds":[0],"units":[{"members":[{"x":0,"y":0}],"pivot":{"x":0,"y":0}}],"id":1,"touched":[{"x":2,"y":4}],"filled":[{"x":2,"y":4},{"x":3,"y":4},{"x":4,"y":4},{"x":5,"y":4},{"x":6,"y":4},{"x":11,"y":4},{"x":2,"y":5},{"x":8,"y":5},{"x":11,"y":5},{"x":2,"y":6},{"x":11,"y":6},{"x":2,"y":7},{"x":3,"y":7},{"x":4,"y":7},{"x":8,"y":7},{"x":11,"y":7},{"x":2,"y":8},{"x":9,"y":8},{"x":11,"y":8},{"x":2,"y":9},{"x":8,"y":9},{"x":2,"y":10},{"x":3,"y":10},{"x":4,"y":10},{"x":5,"y":10},{"x":6,"y":10},{"x":9,"y":10},{"x":11,"y":10}],"sourceLength":100}
{"height":15,"width":15,"sourceSeeds":[0],"units":[{"members":[{"x":0,"y":0}],"pivot":{"x":0,"y":0}}],"id":1,"touched":[{"x":2,"y":4}],"filled":[{"x":2,"y":4},{"x":3,"y":4},{"x":4,"y":4},{"x":5,"y":4},{"x":6,"y":4},{"x":11,"y":4},{"x":2,"y":5},{"x":8,"y":5},{"x":11,"y":5},{"x":2,"y":6},{"x":11,"y":6},{"x":2,"y":7},{"x":3,"y":7},{"x":4,"y":7},{"x":8,"y":7},{"x":11,"y":7},{"x":2,"y":8},{"x":9,"y":8},{"x":11,"y":8},{"x":2,"y":9},{"x":8,"y":9},{"x":2,"y":10},{"x":3,"y":10},{"x":4,"y":10},{"x":5,"y":10},{"x":6,"y":10},{"x":9,"y":10},{"x":11,"y":10}],"sourceLength":100}
{"height":15,"width":15,"sourceSeeds":[0],"units":[{"members":[{"x":0,"y":0}],"pivot":{"x":0,"y":0}}],"id":1,"touched":[{"x":2,"y":4}],"filled":[{"x":0,"y":0},{"x":0,"y":1},{"x":1,"y":0},{"x":1,"y":1}],"sourceLength":100}

Loading…
Cancel
Save