a bad idea caused problems: no more Cell.getColor()
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {getColor, random} from './utils.js';
|
||||
import {random} from './utils.js';
|
||||
import {
|
||||
HEX, CIRCLE, SQUARE,
|
||||
FLAT, POINTY,
|
||||
@@ -25,13 +25,7 @@ const DEFAULTS = {
|
||||
|
||||
export default class Cell {
|
||||
constructor(settings) {
|
||||
this.getColor = this.getColor.bind(this);
|
||||
|
||||
Object.assign(this, DEFAULTS, settings);
|
||||
}
|
||||
|
||||
getColor() {
|
||||
return getColor(this.color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {getColor} from './utils.js';
|
||||
|
||||
export default class DrawCircle {
|
||||
constructor(settings) {
|
||||
@@ -6,7 +7,7 @@ export default class DrawCircle {
|
||||
fill(context, scale, x, y, cell) {
|
||||
context.beginPath();
|
||||
context.arc(x, y, scale * cell.scale, 0, 2*Math.PI, false);
|
||||
context.fillStyle = cell.getColor();
|
||||
context.fillStyle = getColor(cell.color);
|
||||
context.fill();
|
||||
}
|
||||
|
||||
@@ -14,7 +15,7 @@ export default class DrawCircle {
|
||||
context.beginPath();
|
||||
context.arc(x, y, scale * cell.scale, 0, 2*Math.PI, false);
|
||||
context.lineWidth = cell.width;
|
||||
context.strokeStyle = cell.getColor();
|
||||
context.strokeStyle = getColor(cell.color);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {FLAT, POINTY} from './consts.js';
|
||||
import {range, toFixed} from './utils.js';
|
||||
import {getColor, range, toFixed} from './utils.js';
|
||||
|
||||
export default class DrawHexagon {
|
||||
constructor(settings) {
|
||||
@@ -46,7 +46,7 @@ export default class DrawHexagon {
|
||||
context.closePath();
|
||||
|
||||
context.lineWidth = cell.width;
|
||||
context.strokeStyle = cell.getColor();
|
||||
context.strokeStyle = getColor(cell.color);
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export default class DrawHexagon {
|
||||
context.lineTo(x + scale * hexCornerX[4], y + scale * hexCornerY[4]);
|
||||
context.lineTo(x + scale * hexCornerX[5], y + scale * hexCornerY[5]);
|
||||
|
||||
context.fillStyle = cell.getColor();
|
||||
context.fillStyle = getColor(cell.color);
|
||||
context.fill();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {sqrt2} from './utils.js';
|
||||
import {getColor, sqrt2} from './utils.js';
|
||||
import {FLAT, POINTY} from './consts.js';
|
||||
|
||||
export default class DrawSquare {
|
||||
@@ -22,7 +22,7 @@ export default class DrawSquare {
|
||||
context.lineTo(x + scale * squareCornerX[2], y + scale * squareCornerY[2]);
|
||||
context.lineTo(x + scale * squareCornerX[3], y + scale * squareCornerY[3]);
|
||||
|
||||
context.fillStyle = cell.getColor();
|
||||
context.fillStyle = getColor(cell.color);
|
||||
context.fill();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class DrawSquare {
|
||||
context.closePath();
|
||||
|
||||
context.lineWidth = cell.width;
|
||||
context.strokeStyle = cell.getColor();
|
||||
context.strokeStyle = getColor(cell.color);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user