Refactor Maps (#2)
This commit is contained in:
36
src/cell.js
36
src/cell.js
@@ -1,23 +1,31 @@
|
||||
import {random} from './utils.js';
|
||||
import {
|
||||
HEX, CIRCLE, SQUARE,
|
||||
FLAT, POINTY,
|
||||
FILL, OUTLINE,
|
||||
} from './consts.js';
|
||||
|
||||
const DEFAULTS = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
||||
scale: 10,
|
||||
orientation: FLAT,
|
||||
tileStyle: HEX,
|
||||
drawStyle: FILL,
|
||||
width: 1,
|
||||
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
alpha: 0.5,
|
||||
};
|
||||
|
||||
export default class Cell {
|
||||
constructor(settings) {
|
||||
this.getColor = this.getColor.bind(this);
|
||||
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.scale = 10;
|
||||
this.pointyTop = false;
|
||||
this.tile = 'circle';
|
||||
this.style = 'filled';
|
||||
this.width = 1;
|
||||
this.red = 0;
|
||||
this.green = 0;
|
||||
this.blue = 0;
|
||||
this.alpha = 0.5;
|
||||
this.created = Date.now();
|
||||
|
||||
Object.assign(this, settings);
|
||||
Object.assign(this, DEFAULTS, settings);
|
||||
}
|
||||
|
||||
getColor() {
|
||||
|
||||
Reference in New Issue
Block a user