Librarried (#7)

This commit is contained in:
gavin
2018-07-24 01:03:03 +00:00
committed by Gitea
parent 2c19266ca6
commit 18f978cc8a
6 changed files with 29 additions and 46 deletions

View File

@@ -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
});
}