var columnWidth = cWidth/columns;
var rowHeight = cHeight/rows;
var halfColumnWidth = columnWidth/2;
var halfRowHeight = rowHeight/2;
[0, 2, 3, 4, 9], [0, 3, 6, 7, 8, 9]
[1, 5, 6, 7, 8, 10], [1, 2, 4, 5, 10]
[0, 2, 3, 4, 9], [1, 2, 4, 5, 10]
[1, 5, 6, 4, 8, 10], [1, 2, 4, 5, 10]
[1, 5, 6, 7, 8, 10], [0, 3, 6, 7, 8, 9]
[0, 2, 3, 4, 9], [0, 3, 6, 7, 8, 9]
[0, 2, 3, 4, 9], [1, 2, 4, 5, 10]
[0, 2, 3, 4, 9], [0, 3, 6, 7, 8, 9]
[1, 5, 6, 7, 8, 10], [1, 2, 4, 5, 10]
[1, 5, 6, 7, 8, 10], [0, 3, 6, 7, 8, 9]
[1, 5, 6, 7, 8, 10], [0, 3, 6, 7, 8, 9]
createCanvas(cWidth, cHeight);
for (var j=0; j<rows; j++) {
for (var i=0; i<columns; i++) {
for (var j=0; j<rows; j++) {
commons = getCommonItems(bestMatches[data[j-1][i]][1], bestMatches[data[j][i-1]][0]);
commons = bestMatches[data[j][i-1]][0];
commons = bestMatches[data[j-1][i]][1];
data[j][i] = commons[Math.floor(Math.random()*commons.length)];
data[j][i] = Math.floor(Math.random()*7);
for (var i=0; i<columns; i++) {
for (var j=0; j<rows; j++) {
setLine(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 0);
setLine(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 1);
setCross(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight);
setArc(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 0);
setArc(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 1);
setArc(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 2);
setArc(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 3);
setLineCurve(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 1);
setLineCurve(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 2);
setLineCurve(i*columnWidth + halfColumnWidth, j*rowHeight + halfRowHeight, 3);
function setLine(x, y, o) {
line(x-halfColumnWidth, y-halfRowHeight/2, x+halfColumnWidth, y-halfRowHeight/2);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
line(x-halfColumnWidth, y+halfRowHeight/2, x+halfColumnWidth, y+halfRowHeight/2);
line(x-halfColumnWidth/2, y-halfRowHeight, x-halfColumnWidth/2, y+halfRowHeight/2);
line(x, y-halfRowHeight, x, y+halfRowHeight/2);
line(x+halfColumnWidth/2, y-halfRowHeight, x+halfColumnWidth/2, y+halfRowHeight/2);
function setCross(x, y) {
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
line(x, y-halfRowHeight, x, y+halfRowHeight);
line(x-halfColumnWidth, y-halfRowHeight/2, x+halfColumnWidth, y-halfRowHeight/2);
line(x-halfColumnWidth, y+halfRowHeight/2, x+halfColumnWidth, y+halfRowHeight/2);
function setArc(x, y, o) {
arc(x-halfColumnWidth, y+halfRowHeight, columnWidth/2, rowHeight/2, 3*PI/2, 0);
arc(x-halfColumnWidth, y+halfRowHeight, columnWidth, rowHeight, 3*PI/2, 0);
arc(x-halfColumnWidth, y+halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, 3*PI/2, 0);
arc(x-halfColumnWidth, y-halfRowHeight, columnWidth/2, rowHeight/2, 0, PI/2);
arc(x-halfColumnWidth, y-halfRowHeight, columnWidth, rowHeight, 0, PI/2);
arc(x-halfColumnWidth, y-halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, 0, PI/2);
arc(x+halfColumnWidth, y-halfRowHeight, columnWidth/2, rowHeight/2, PI/2, PI);
arc(x+halfColumnWidth, y-halfRowHeight, columnWidth, rowHeight, PI/2, PI);
arc(x+halfColumnWidth, y-halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, PI/2, PI);
arc(x+halfColumnWidth, y+halfRowHeight, columnWidth/2, rowHeight/2, PI, 3*PI/2);
arc(x+halfColumnWidth, y+halfRowHeight, columnWidth, rowHeight, PI, 3*PI/2);
arc(x+halfColumnWidth, y+halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, PI, 3*PI/2);
function setDeadEnd(x, y, o) {
line(x+halfColumnWidth, y, x, y);
line(x, y-halfRowHeight, x, y+halfRowHeight);
line(x, y+halfRowHeight, x, y);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
line(x-halfColumnWidth, y, x, y);
line(x, y-halfRowHeight, x, y+halfRowHeight);
line(x, y-halfRowHeight, x, y);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
function setLineCurve(x, y, o) {
line(x-halfColumnWidth, y-halfRowHeight/2, x+halfColumnWidth, y-halfRowHeight/2);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
arc(x-halfColumnWidth, y+halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, 3*PI/2, 0);
line(x-halfColumnWidth, y-halfRowHeight/2, x+halfColumnWidth, y-halfRowHeight/2);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
arc(x-halfColumnWidth, y-halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, 0, PI/2);
line(x-halfColumnWidth, y-halfRowHeight/2, x+halfColumnWidth, y-halfRowHeight/2);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
arc(x+halfColumnWidth, y-halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, PI/2, PI);
line(x-halfColumnWidth, y-halfRowHeight/2, x+halfColumnWidth, y-halfRowHeight/2);
line(x-halfColumnWidth, y, x+halfColumnWidth, y);
arc(x+halfColumnWidth, y+halfRowHeight, 3*columnWidth/2, 3*rowHeight/2, PI, 3*PI/2);
function getCommonItems(a, b) {
for (var i = 0; i < a.length; i++) {
if (b.indexOf(a[i]) > -1) common.push(a[i]);
function mousePressed() {
saveFrames("screen-####.jpg");