implemented zooming

This commit is contained in:
Gavin McDonald
2016-02-24 15:32:03 -05:00
parent 42e0d7c8d2
commit 4e06b756d8
7 changed files with 163 additions and 39 deletions

View File

@@ -18,7 +18,7 @@ import ExWhyZee from './exWhyZee.js';
export default class Tessellate {
constructor(settings) {
['click', 'draw', 'drawMap'].map(method => {this[method] = this[method].bind(this)});
['tap', 'draw', 'drawMap', 'zoom'].map(method => {this[method] = this[method].bind(this)});
this.drawCB = settings.draw || utils.noop;
this.clickCB = settings.click || utils.noop;
@@ -31,7 +31,8 @@ export default class Tessellate {
this.onTap = new OnTap({
element: this.element,
click: this.click
tap: this.tap,
zoom: this.zoom
});
this.map = [];
@@ -45,10 +46,14 @@ export default class Tessellate {
this.hexagon = new DrawHexagon();
}
click(event) {
tap(event) {
this.clickCB(event);
}
zoom(event) {
this.xyz.zoom(event);
}
drawMap(context) {
let scale = this.xyz.getScale();
let upperLeft = new Point(0, 0);
@@ -67,18 +72,18 @@ export default class Tessellate {
if (!this.map[hex.getX()][hex.getY()]) {
this.map[hex.getX()][hex.getY()] = new Cell({
x: hexPoint.getX(),
y: hexPoint.getY(),
x: hex.getX(),
y: hex.getY(),
pointyTop: true,
red: utils.random(255),
green: utils.random(255),
blue: utils.random(255),
alpha: utils.random(25, 75) / 100,
scale: scale * utils.random(5,9)/10
scale: utils.random(5,9)/10
});
}
this.hexagon.filled(context, this.map[hex.getX()][hex.getY()]);
this.hexagon.filled(context, scale, hexPoint.getX(), hexPoint.getY(), this.map[hex.getX()][hex.getY()]);
// let cell = map.getXY(hex.getX(), hex.getY());
//