import * as utils from './utils'; export {utils}; import OnTap from './onTap.js'; import Point from './point.js'; import Sketch from './sketch.js'; import DrawCircle from './drawCircle.js'; import DrawSquare from './drawSquare.js'; import DrawHexagon from './drawHexagon.js'; export {DrawCircle, DrawHexagon, DrawSquare}; import Cell from './cell.js'; export {Cell}; export default class Tessellate { constructor(settings) { ['click', 'draw'].map(method => {this[method] = this[method].bind(this)}); this.drawCB = settings.draw || utils.noop; this.clickCB = settings.click || utils.noop; this.element = document.querySelector(settings.element); this.sketch = new Sketch({ element: this.element, draw: this.draw }); this.onTap = new OnTap({ element: this.element, click: this.click }); } click(event) { this.clickCB(event); } draw(context) { let canvas = context.canvas; let width = canvas.width; let height = canvas.height; context.clearRect(0, 0, width, height); this.drawCB(context); } }