Librarried (#7)
This commit is contained in:
39
src/main.js
39
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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user