Refactor Maps (#2)

This commit is contained in:
gavin
2018-07-17 21:28:17 +00:00
committed by Gitea
parent 0545c0a5d9
commit 57ada13a8d
13 changed files with 167 additions and 86 deletions

View File

@@ -50,6 +50,8 @@ export default class CartographerFlatXYZ extends Cartographer {
}
tileToPixel(hex) {
hex = typeof hex === 'Hex' ? hex : new Hex(...arguments);
const pixelX = this.scale * 3/2 * hex.getQ();
const pixelY = this.scale * sqrt3 * (hex.getR() + (hex.getQ() / 2));
@@ -57,6 +59,8 @@ export default class CartographerFlatXYZ extends Cartographer {
}
pixelToTile(point) {
point = typeof point === 'Point' ? point : new Point(x, y);
const pixelX = point.getX() - this.originX;
const pixelY = point.getY() - this.originY;