code cleanup
This commit is contained in:
@@ -122,180 +122,3 @@ export default class CartographerXYZ extends Cartographer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// function getCoordinates(canvasX, canvasY) {
|
||||
// var hexWidth = sqrt3 * scale;
|
||||
// var graphY = Math.round((originY + (scale/2) - canvasY) / (1.5*scale));
|
||||
// var mapY = height ? graphY % height : graphY;
|
||||
// mapY = mapY < 0 ? mapY + height : mapY;
|
||||
// var graphX = Math.round(((canvasX - originX) / hexWidth) - (graphY/2));
|
||||
// var mapX = width ? graphX % width : graphX;
|
||||
// mapX = mapX < 0 ? (width + mapX) : mapX;
|
||||
// var mapZ = -(mapX + mapY);
|
||||
//
|
||||
// return {x:mapX, y:mapY, z:mapZ}
|
||||
// }
|
||||
//
|
||||
// var ExWhyZee = {
|
||||
// boundingBox: function(upperLeftPoint, lowerRightPoint, contained) {
|
||||
// var hexagons = [];
|
||||
// var upperRightPoint = Point(lowerRightPoint.getX(), upperLeftPoint.getY());
|
||||
//
|
||||
// // push out by a 1 axially to account for interlocking hexagons
|
||||
// // possibly return hexagons not within bounds
|
||||
// var upperLeftHex = this.pixelToHex(upperLeftPoint).moveAxial({q: 0, r: -1});
|
||||
// var lowerRightHex = this.pixelToHex(lowerRightPoint).moveAxial({q: 0, r: 1});
|
||||
// var upperRightHex = this.pixelToHex(upperRightPoint).moveAxial({q: 1, r: -1});
|
||||
//
|
||||
// var height = lowerRightHex.getR() - upperLeftHex.getR();
|
||||
// var width = upperRightHex.getQ() - upperLeftHex.getQ();
|
||||
//
|
||||
// for (var row = 0; row <= height; row++) {
|
||||
// hexagons[row] = [];
|
||||
// var r = upperLeftHex.getR() + row;
|
||||
// var qOffset = upperLeftHex.getQ() - Math.floor(row / 2);
|
||||
//
|
||||
// for (var q = qOffset; q <= qOffset + width; q++) {
|
||||
// hexagons[row].push(Hex(q, r));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return hexagons;
|
||||
// },
|
||||
//
|
||||
// cellDistance: function(hex1, hex2) {
|
||||
// return Math.max(
|
||||
// Math.abs(hex1.getX() - hex2.getX()),
|
||||
// Math.abs(hex1.getY() - hex2.getY()),
|
||||
// Math.abs(hex1.getZ() - hex2.getZ())
|
||||
// );
|
||||
// },
|
||||
//
|
||||
// setNeighbors: function(distance) {
|
||||
// if (!neighbors[distance - 1]) {
|
||||
// var length = 6 * distance;
|
||||
// for (var i=0; i<distance; i++) {
|
||||
// // each of the six directions
|
||||
// neighbors[(0 * distance) + i] = Hex( distance, (i - distance), -i);
|
||||
// neighbors[(2 * distance) + i] = Hex((distance - i), i, -i);
|
||||
// neighbors[(3 * distance) + i] = Hex( -i, distance, (i - distance));
|
||||
// neighbors[(4 * distance) + i] = Hex( -distance, (distance - i), i);
|
||||
// neighbors[(5 * distance) + i] = Hex((i - distance), -i, distance);
|
||||
// neighbors[(6 * distance) + i] = Hex( i, -distance, (distance - i));
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// getNeighborRing: function(hex, distance) {
|
||||
// if (!neighbors[distance]) {
|
||||
// ExWhyZee.setNeighbors(distance);
|
||||
// }
|
||||
//
|
||||
// return _.map(neighbors[distance], function(neighbor) {
|
||||
// return Hex(hex.getQ() + neighbor.getQ(), hex.getR() + neighbor.getR());
|
||||
// });
|
||||
// },
|
||||
//
|
||||
// getNeighbors: function getNeighbors(hex, distance) {
|
||||
// if (distance) {
|
||||
// return ExWhyZee.getNeighborRing().concat(getNeighbors(hex, distance - 1));
|
||||
// }
|
||||
// },
|
||||
//
|
||||
//// getNeighbors: function(x,y, distance) {
|
||||
//// var neighbors = [];
|
||||
////
|
||||
//// for (var curX=x-distance; curX<=x+distance; curX++) {
|
||||
//// for (var curY=y-distance; curY<=y+distance; curY++) {
|
||||
////
|
||||
//// if (cellDistance(x,y, curX,curY) <= distance) {
|
||||
//// if ((curX !== x) || (curY !== y)) {
|
||||
//// var tempX = curX < 0 ? curX + map.width : curX;
|
||||
//// tempX = tempX >= map.width ? tempX - map.width : tempX;
|
||||
//// var tempY = curY < 0 ? curY + map.height : curY;
|
||||
//// tempY = tempY >= map.height ? tempY - map.height : tempY;
|
||||
////
|
||||
//// neighbors.push({'x':tempX, 'y':tempY, 'z':-(tempX+tempY)});
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// return neighbors;
|
||||
//// },
|
||||
//
|
||||
// hexToPixel: function(hex) {
|
||||
// var minWidth = function(a, b) {
|
||||
// return scale * sqrt3 * (a + (b / 2))
|
||||
// };
|
||||
//
|
||||
// var maxWidth = function(a) {
|
||||
// return scale * 3/2 * a
|
||||
// };
|
||||
//
|
||||
// var pixelX = pointyTop ? minWidth(hex.getQ(), hex.getR()) : maxWidth(hex.getQ());
|
||||
// var pixelY = pointyTop ? maxWidth(hex.getR()) : minWidth(hex.getR(), hex.getQ());
|
||||
//
|
||||
// pixelX += originX;
|
||||
// pixelY += originY;
|
||||
//
|
||||
// return Point(pixelX, pixelY);
|
||||
// },
|
||||
//
|
||||
// pixelToHex: function(point) {
|
||||
// var radiusLong = function(a, b) {
|
||||
// return ((a * (sqrt3 / 3)) - (b / 3)) / scale;
|
||||
// };
|
||||
//
|
||||
// var radiusShort = function(a) {
|
||||
// return (a * (2 / 3)) / scale;
|
||||
// };
|
||||
//
|
||||
// var pixelX = point.getX() - originX;
|
||||
// var pixelY = point.getY() - originY;
|
||||
//
|
||||
// var q = pointyTop ? radiusLong(pixelX, pixelY) : radiusShort(pixelX);
|
||||
// var r = pointyTop ? radiusShort(pixelY) : radiusLong(pixelY, pixelX);
|
||||
//
|
||||
// return Hex(q, r);
|
||||
// },
|
||||
//
|
||||
// move: function(event) {
|
||||
// if (event.deltaX) {
|
||||
//
|
||||
// originX = Math.floor((originX*1000) + (event.deltaX*1000)) / 1000;
|
||||
// }
|
||||
//
|
||||
// if (event.deltaY) {
|
||||
//
|
||||
// originY = Math.floor((originY*1000) + (event.deltaY*1000)) / 1000;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// zoom: function(event) {
|
||||
// var scaleOrig = scale;
|
||||
//
|
||||
// var scaleTemp = parseInt((scaleOrig + (event.deltaY / 10)) * 1000) / 1000;
|
||||
//
|
||||
// // make sure 'scale' doesn't get too small nor too big
|
||||
// if (scaleTemp < scaleMin)
|
||||
// scaleTemp = scaleMin;
|
||||
// else if (scaleTemp > scaleMax)
|
||||
// scaleTemp = scaleMax;
|
||||
//
|
||||
// if (scaleOrig != scaleTemp) {
|
||||
//
|
||||
// scale = scaleTemp;
|
||||
//
|
||||
// // zoom to the current mouse location
|
||||
// this.move({
|
||||
// deltaX: (((event.offsetX - originX) / scaleOrig) * (scaleOrig - scaleTemp)),
|
||||
// deltaY: (((event.offsetY - originY) / scaleOrig) * (scaleOrig - scaleTemp))
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// return ExWhyZee;
|
||||
//};
|
||||
|
||||
|
||||
@@ -152,13 +152,8 @@ export default class Tessellate {
|
||||
|
||||
const tiles = this.cartographer.boundingBox(upperLeft, upperRight, lowerLeft, lowerRight);
|
||||
|
||||
const height = tiles.length;
|
||||
for (let r=0; r<height; r++) {
|
||||
let width = tiles[r].length;
|
||||
|
||||
for (let c=0; c<width; c++) {
|
||||
let tile = tiles[r][c];
|
||||
let tilePoint = this.cartographer.tileToPixel(tile);
|
||||
tiles.forEach(row => row.forEach(tile => {
|
||||
const tilePoint = this.cartographer.tileToPixel(tile);
|
||||
|
||||
if (!this.map[tile.getX()]) this.map[tile.getX()] = [];
|
||||
|
||||
@@ -176,12 +171,7 @@ export default class Tessellate {
|
||||
}
|
||||
|
||||
TILES[this.settings.tile].filled(context, scale, tilePoint.getX(), tilePoint.getY(), this.map[tile.getX()][tile.getY()]);
|
||||
|
||||
// let cell = map.getXY(hex.getX(), hex.getY());
|
||||
//
|
||||
// hexTiles.filled(hexPoint.getX(), hexPoint.getY(), scale * 0.9, {color: cell.getColor()});
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
draw(context) {
|
||||
|
||||
Reference in New Issue
Block a user