Skip to content

Commit 26c80db

Browse files
committed
Expand Entropy for sizes 5 and 6
1 parent 5263804 commit 26c80db

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/renderers/entropy.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export class EntropyRenderer extends RendererBase {
3030
throw new Error(`This 'board' schema cannot be handled by the '${ EntropyRenderer.rendererName }' renderer.`);
3131
}
3232

33+
let size = 7;
34+
if ("size" in this.json.board) {
35+
size = this.json.board.size as number;
36+
}
3337
let label1 = "Player 1: Order";
3438
let label2 = "Player 2: Order";
3539
let occlude1 = false;
@@ -65,9 +69,9 @@ export class EntropyRenderer extends RendererBase {
6569
baseOpacity = this.json.board.strokeOpacity;
6670
}
6771

68-
const width = 7;
69-
const height = 7;
70-
const boardOffset = cellsize * 8;
72+
const width = size;
73+
const height = size;
74+
const boardOffset = cellsize * (size+1);
7175
// Get a grid of points
7276
const grid1 = rectOfRects({gridHeight: height, gridWidth: width, cellSize: cellsize});
7377
let startx = boardOffset;
@@ -89,10 +93,11 @@ export class EntropyRenderer extends RendererBase {
8993
boardlabel = label2;
9094
}
9195
let titlePoint: IPoint = {x: 0, y: 0};
96+
const half = Math.floor(size / 2);
9297
if (this.json.board.orientation === "vertical") {
93-
titlePoint = {x: grid[0][0].x - (cellsize * 1.5), y: grid[3][0].y};
98+
titlePoint = {x: grid[0][0].x - (cellsize * 1.5), y: grid[half][0].y};
9499
} else {
95-
titlePoint = {x: grid[0][3].x, y: grid[0][0].y - (cellsize * 1.5)};
100+
titlePoint = {x: grid[0][half].x, y: grid[0][0].y - (cellsize * 1.5)};
96101
}
97102

98103
const board = this.rootSvg.group().id(boardid);

src/schemas/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ export interface MarkerGlyph {
950950
*/
951951
export interface BoardEntropy {
952952
style: "entropy";
953+
size?: 5 | 6 | 7;
953954
/**
954955
* Describes the left-hand or top board
955956
*/

src/schemas/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,10 @@
23252325
"style": {
23262326
"enum": ["entropy"]
23272327
},
2328+
"size": {
2329+
"enum": [5, 6, 7],
2330+
"default": 7
2331+
},
23282332
"boardOne": {
23292333
"description": "Describes the left-hand or top board",
23302334
"type": "object",

0 commit comments

Comments
 (0)