diff --git a/.gitignore b/.gitignore index 0fb836e..c86e989 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ node_modules/* hexmine public/js/main.js +public/js/tessellate.js diff --git a/package.json b/package.json index 780fe6a..c4db78d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "tessellate", "version": "1.0.0", "description": "", - "main": "webpack.config.js", + "main": "./public/js/tessellate.js", "scripts": { "build": "webpack --mode production", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/public/index.html b/public/index.html index 38d02f7..c369669 100644 --- a/public/index.html +++ b/public/index.html @@ -10,6 +10,7 @@
+ diff --git a/src/main.js b/src/main.js index 0378102..70b76af 100644 --- a/src/main.js +++ b/src/main.js @@ -1,9 +1,3 @@ -import Tessellate from './tessellate.js'; - -import {utils} from './tessellate.js'; -import {DrawCircle, DrawHexagon, DrawSquare} from './tessellate.js'; -import {Cell} from './tessellate.js'; - const DEFAULTS = { board: Tessellate.BOARD_STYLES.HEX, style: Tessellate.DRAW_STYLES.FILL, @@ -21,7 +15,7 @@ class Demo { 'draw', ].map(method => this[method] = this[method].bind(this)); - const queryStringObj = utils.getQueryStringObj(); + const queryStringObj = Tessellate.utils.getQueryStringObj(); this.settings = Object.assign({}, DEFAULTS, queryStringObj); @@ -34,17 +28,10 @@ class Demo { tap: this.onTap, draw: this.draw, }, this.settings)); - - this.circle = new DrawCircle(); - this.square = new DrawSquare(); - this.hexagon = new DrawHexagon(); - - this.tiles = ['circle', 'hexagon', 'square']; - this.styles = ['filled', 'outline']; } setOriginTile() { - this.map['0,0'] = new Cell({ + this.map['0,0'] = new Tessellate.Cell({ x: 0, y: 0, scale: 1, @@ -57,10 +44,10 @@ class Demo { alpha: 1, }); - utils.rangeInclusive(0, 5) + Tessellate.utils.rangeInclusive(0, 5) .map(interval => interval ? interval * 0.2 : 0.01) .forEach(interval => { - this.taps.push(new Cell({ + this.taps.push(new Tessellate.Cell({ x: 0, y: 0, scale: interval, @@ -82,26 +69,26 @@ class Demo { tap.tile.x, tap.tile.y, - utils.random(Tessellate.DRAW_STYLES), - utils.random(Tessellate.TILE_STYLES), - utils.random(Tessellate.TILE_ORIENTATIONS), + Tessellate.utils.random(Tessellate.DRAW_STYLES), + Tessellate.utils.random(Tessellate.TILE_STYLES), + Tessellate.utils.random(Tessellate.TILE_ORIENTATIONS), )); } createTile(x, y, drawStyle, tileStyle, orientation) { - return new Cell({ + return new Tessellate.Cell({ x, y, - scale: utils.random(7, 9) / 10, + scale: Tessellate.utils.random(7, 9) / 10, drawStyle, tileStyle, orientation, - red: utils.random(255), - green: utils.random(255), - blue: utils.random(255), - alpha: utils.random(25,75)/100 + red: Tessellate.utils.random(255), + green: Tessellate.utils.random(255), + blue: Tessellate.utils.random(255), + alpha: Tessellate.utils.random(25,75)/100 }); } diff --git a/src/tessellate.js b/src/tessellate.js index 80d716a..db4db53 100644 --- a/src/tessellate.js +++ b/src/tessellate.js @@ -1,8 +1,5 @@ import * as utils from './utils'; -export {utils}; - import * as funky from './funky'; -export {funky}; import OnTap from './onTap.js'; import Point from './point.js'; @@ -11,10 +8,8 @@ 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}; import CartographerFlatXY from './cartographerFlatXY.js'; import CartographerPointyXY from './cartographerPointyXY.js'; @@ -61,13 +56,18 @@ function selectCartographer(board, orientation) { } } -export default class Tessellate { - static get TILES() {return TILES} +export class Tessellate { static get TILE_STYLES() {return TILE_STYLES} static get BOARD_STYLES() {return BOARD_STYLES} - static get TILE_ORIENTATIONS() {return TILE_ORIENTATIONS} + static get TILE_ORIENTATIONS() {return TILE_ORIENTATIONS} // TODO: rename to ORIENTATION_STYLES static get DRAW_STYLES() {return DRAW_STYLES} + static get TILES() {return TILES} + static get Cell() {return Cell} + + static get utils() {return utils} + static get funky() {return funky} + constructor(settings) { [ 'checkSettings', diff --git a/webpack.config.js b/webpack.config.js index cccba16..bd4a495 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,14 @@ var path = require('path'); module.exports = { - entry: path.join(__dirname, 'src', 'main.js'), + entry: { + main: [path.join(__dirname, 'src', 'main.js')], + Tessellate: [path.join(__dirname, 'src', 'tessellate.js')], + }, output: { libraryTarget: 'this', path: path.join(__dirname, 'public', 'js'), - filename: 'main.js' + filename: '[name].js' }, devtool: 'inline-source-map', module: { @@ -18,14 +21,5 @@ module.exports = { } ] } -// module: { -// loaders: [{ -// test: path.join(__dirname, 'src'), -// loader: 'babel-loader', -// query: { -// presets: ['es2015'] -// } -// }] -// } };