@cogniplay/logic-games 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -2
- package/board.d.ts +102 -0
- package/board.d.ts.map +1 -0
- package/board.js +201 -0
- package/board.js.map +1 -0
- package/clues.d.ts +16 -0
- package/clues.d.ts.map +1 -0
- package/clues.js +64 -0
- package/clues.js.map +1 -0
- package/digits/generated/digits.d.ts +10 -0
- package/digits/generated/digits.d.ts.map +1 -0
- package/digits/generated/digits.js +397 -0
- package/digits/generated/digits.js.map +1 -0
- package/digits.d.ts +7 -0
- package/digits.d.ts.map +1 -0
- package/digits.js +38 -0
- package/digits.js.map +1 -0
- package/fair-shares.d.ts +20 -0
- package/fair-shares.d.ts.map +1 -0
- package/fair-shares.js +164 -0
- package/fair-shares.js.map +1 -0
- package/fills.d.ts +31 -0
- package/fills.d.ts.map +1 -0
- package/fills.js +142 -0
- package/fills.js.map +1 -0
- package/geometry.d.ts +14 -0
- package/geometry.d.ts.map +1 -0
- package/geometry.js +55 -0
- package/geometry.js.map +1 -0
- package/index.d.ts +12 -0
- package/index.d.ts.map +1 -0
- package/index.js +9 -0
- package/index.js.map +1 -0
- package/line-counts.d.ts +25 -0
- package/line-counts.d.ts.map +1 -0
- package/line-counts.js +136 -0
- package/line-counts.js.map +1 -0
- package/marks.d.ts +17 -0
- package/marks.d.ts.map +1 -0
- package/marks.js +50 -0
- package/marks.js.map +1 -0
- package/outline.d.ts +31 -0
- package/outline.d.ts.map +1 -0
- package/outline.js +150 -0
- package/outline.js.map +1 -0
- package/package.json +21 -4
- package/positions.d.ts +7 -0
- package/positions.d.ts.map +1 -0
- package/positions.js +28 -0
- package/positions.js.map +1 -0
- package/regions.d.ts +20 -0
- package/regions.d.ts.map +1 -0
- package/regions.js +84 -0
- package/regions.js.map +1 -0
- package/solution.d.ts +15 -0
- package/solution.d.ts.map +1 -0
- package/solution.js +50 -0
- package/solution.js.map +1 -0
- package/src/board.ts +377 -0
- package/src/clues.ts +91 -0
- package/src/digits/OFL.txt +93 -0
- package/src/digits/README.md +5 -0
- package/src/digits/generated/digits.ts +404 -0
- package/src/digits.ts +58 -0
- package/src/fair-shares.ts +257 -0
- package/src/fills.ts +176 -0
- package/src/geometry.ts +66 -0
- package/src/index.ts +31 -0
- package/src/line-counts.ts +211 -0
- package/src/marks.ts +68 -0
- package/src/outline.ts +196 -0
- package/src/positions.ts +35 -0
- package/src/regions.ts +108 -0
- package/src/solution.ts +75 -0
- package/src/svg.ts +46 -0
- package/src/tray.ts +114 -0
- package/src/types.ts +106 -0
- package/svg.d.ts +7 -0
- package/svg.d.ts.map +1 -0
- package/svg.js +29 -0
- package/svg.js.map +1 -0
- package/tray.d.ts +32 -0
- package/tray.d.ts.map +1 -0
- package/tray.js +58 -0
- package/tray.js.map +1 -0
- package/types.d.ts +95 -0
- package/types.d.ts.map +1 -0
- package/types.js +2 -0
- package/types.js.map +1 -0
package/fair-shares.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { defaultCellSize, drawCells, drawTile, lookOf, padding, requireSquare, } from "./board.js";
|
|
2
|
+
import { place } from "./geometry.js";
|
|
3
|
+
import { isPlaced, positionCount } from "./line-counts.js";
|
|
4
|
+
import { element, fmt, root } from "./svg.js";
|
|
5
|
+
import { drawTrayPieces, layTray } from "./tray.js";
|
|
6
|
+
export function isFairShares(data) {
|
|
7
|
+
return data.$type === "fair-shares";
|
|
8
|
+
}
|
|
9
|
+
/** The room between two grids, across and down, in cells. */
|
|
10
|
+
export const gridGapCells = 1;
|
|
11
|
+
/** The box around a piece left out stands this far off it, as a share of the tray's cell. */
|
|
12
|
+
const boxMargin = 0.25;
|
|
13
|
+
const boxStroke = {
|
|
14
|
+
stroke: "#555",
|
|
15
|
+
"stroke-width": 0.5,
|
|
16
|
+
"stroke-dasharray": "2 1.5",
|
|
17
|
+
fill: "none",
|
|
18
|
+
};
|
|
19
|
+
const extent = (cells, axis) => Math.max(...cells.map((cell) => cell[axis])) + 1;
|
|
20
|
+
/**
|
|
21
|
+
* A Fair Shares board as a complete SVG document: a grid for each share, all
|
|
22
|
+
* alike and unmarked, a cell apart, in rows of `gridsPerRow` with a short
|
|
23
|
+
* last row centred; and the pieces to share in a tray, above the grids unless
|
|
24
|
+
* `trayPosition` says under. At position 0 it is the start. At position 1 it
|
|
25
|
+
* is the solved board: the pieces the solution placed lie on their shares'
|
|
26
|
+
* grids with the heavy outline, and a piece it left out stays in the tray
|
|
27
|
+
* with a dashed box around it. Nothing shows a share's size.
|
|
28
|
+
*/
|
|
29
|
+
export function renderFairShares(data, options = {}) {
|
|
30
|
+
requireSquare(data);
|
|
31
|
+
if (data.board.length === 0) {
|
|
32
|
+
throw new Error("The board has no cells");
|
|
33
|
+
}
|
|
34
|
+
const shares = data.shares;
|
|
35
|
+
if (!Number.isInteger(shares) || shares < 1) {
|
|
36
|
+
throw new Error(`A board has one share or more, not ${String(shares)}`);
|
|
37
|
+
}
|
|
38
|
+
const index = options.position ?? 0;
|
|
39
|
+
const count = positionCount(data);
|
|
40
|
+
if (!Number.isInteger(index) || index < 0 || index >= count) {
|
|
41
|
+
throw new RangeError(`No position ${index}; there are ${count}, numbered 0 to ${count - 1}`);
|
|
42
|
+
}
|
|
43
|
+
const size = options.cellSizeMm ?? defaultCellSize;
|
|
44
|
+
const solved = index === 1;
|
|
45
|
+
const placements = new Map();
|
|
46
|
+
(data.solution ?? []).forEach((placement, i) => {
|
|
47
|
+
if (!data.pieces.some((p) => p.pieceId === placement.pieceId)) {
|
|
48
|
+
throw new Error(`Placement ${i + 1} names piece "${placement.pieceId}", which the board doesn't have`);
|
|
49
|
+
}
|
|
50
|
+
placements.set(placement.pieceId, placement);
|
|
51
|
+
});
|
|
52
|
+
// A piece keeps the fill its place in `pieces` gives it, in the tray and on
|
|
53
|
+
// a grid.
|
|
54
|
+
const grids = Array.from({ length: shares }, () => []);
|
|
55
|
+
const loose = [];
|
|
56
|
+
// The pieces to share at the start, whatever the position.
|
|
57
|
+
const looseAtStart = [];
|
|
58
|
+
data.pieces.forEach((piece, order) => {
|
|
59
|
+
const starts = isPlaced(piece);
|
|
60
|
+
if (!starts) {
|
|
61
|
+
looseAtStart.push({ pieceId: piece.pieceId, shape: piece.shape, order });
|
|
62
|
+
}
|
|
63
|
+
const placement = starts
|
|
64
|
+
? piece
|
|
65
|
+
: solved
|
|
66
|
+
? placements.get(piece.pieceId)
|
|
67
|
+
: undefined;
|
|
68
|
+
if (placement === undefined) {
|
|
69
|
+
loose.push({ pieceId: piece.pieceId, shape: piece.shape, order });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const grid = grids[placement.share];
|
|
73
|
+
if (grid === undefined) {
|
|
74
|
+
throw new Error(`Piece "${piece.pieceId}" is on share ${String(placement.share)}; ` +
|
|
75
|
+
`the board has ${shares}, numbered 0 to ${shares - 1}`);
|
|
76
|
+
}
|
|
77
|
+
grid.push({
|
|
78
|
+
cells: place(piece.shape, { ...placement, pieceId: piece.pieceId }),
|
|
79
|
+
id: piece.pieceId,
|
|
80
|
+
order,
|
|
81
|
+
placed: !starts,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
// Every grid is drawn within the same bounds: the board's cells and any
|
|
85
|
+
// piece that lies off them on some grid, so nothing is clipped away.
|
|
86
|
+
const cells = [
|
|
87
|
+
...data.board,
|
|
88
|
+
...grids.flatMap((grid) => grid.flatMap((piece) => piece.cells)),
|
|
89
|
+
];
|
|
90
|
+
const minX = Math.min(...cells.map(([x]) => x));
|
|
91
|
+
const minY = Math.min(...cells.map(([, y]) => y));
|
|
92
|
+
const gridWidth = (Math.max(...cells.map(([x]) => x)) - minX + 1) * size;
|
|
93
|
+
const gridHeight = (Math.max(...cells.map(([, y]) => y)) - minY + 1) * size;
|
|
94
|
+
const asked = Math.floor(options.gridsPerRow ?? NaN);
|
|
95
|
+
const across = asked >= 1 ? Math.min(asked, shares) : defaultGridsPerRow(shares);
|
|
96
|
+
const down = Math.ceil(shares / across);
|
|
97
|
+
const gap = gridGapCells * size;
|
|
98
|
+
const span = (n, each) => n * each + (n - 1) * gap;
|
|
99
|
+
const gridsWidth = span(across, gridWidth);
|
|
100
|
+
const gridsHeight = span(down, gridHeight);
|
|
101
|
+
const trayCell = size * (options.trayScale ?? 1);
|
|
102
|
+
// With `keepTrayRoom` the tray is laid out as at the start, and the pieces
|
|
103
|
+
// since placed leave their room empty.
|
|
104
|
+
const room = layTray(options.keepTrayRoom ? looseAtStart : loose, trayCell, options.trayWidthMm ?? gridsWidth);
|
|
105
|
+
const stillLoose = new Set(loose.map((piece) => piece.pieceId));
|
|
106
|
+
const shown = room.pieces.filter(({ piece }) => stillLoose.has(piece.pieceId));
|
|
107
|
+
// Solved, a piece still in the tray is one the solution left out, and gets
|
|
108
|
+
// a box. The box needs room around the tray; kept at the start too when the
|
|
109
|
+
// tray's room is kept, so the two drawings are the same size.
|
|
110
|
+
const leavesOut = placements.size > 0 &&
|
|
111
|
+
looseAtStart.some((piece) => !placements.has(piece.pieceId));
|
|
112
|
+
const boxed = leavesOut && (solved || options.keepTrayRoom === true);
|
|
113
|
+
const margin = boxed ? trayCell * boxMargin : 0;
|
|
114
|
+
const hasTray = room.pieces.length > 0;
|
|
115
|
+
const trayRoom = hasTray ? room.height + 2 * margin + size / 2 : 0;
|
|
116
|
+
const width = Math.max(gridsWidth, hasTray ? room.width + 2 * margin : 0);
|
|
117
|
+
const above = (options.trayPosition ?? "above") === "above";
|
|
118
|
+
const gridsTop = padding + (above ? trayRoom : 0);
|
|
119
|
+
const trayTop = padding + margin + (above ? 0 : gridsHeight + size / 2);
|
|
120
|
+
const trayLeft = padding + (width - room.width) / 2;
|
|
121
|
+
const boxes = !solved
|
|
122
|
+
? ""
|
|
123
|
+
: shown
|
|
124
|
+
.map(({ piece, cells: shape, x, y }) => element("rect", {
|
|
125
|
+
class: "left-out-box",
|
|
126
|
+
"data-piece": piece.pieceId,
|
|
127
|
+
x: trayLeft + x - margin,
|
|
128
|
+
y: trayTop + y - margin,
|
|
129
|
+
width: extent(shape, 0) * trayCell + 2 * margin,
|
|
130
|
+
height: extent(shape, 1) * trayCell + 2 * margin,
|
|
131
|
+
rx: margin,
|
|
132
|
+
...boxStroke,
|
|
133
|
+
}))
|
|
134
|
+
.join("");
|
|
135
|
+
const tray = shown.length === 0
|
|
136
|
+
? ""
|
|
137
|
+
: element("g", { class: "tray" }, boxes +
|
|
138
|
+
drawTrayPieces(shown, solved ? "piece left-out" : "piece to-share", trayLeft, trayTop, trayCell, options));
|
|
139
|
+
const drawnGrids = element("g", { class: "shares" }, grids
|
|
140
|
+
.map((grid, share) => {
|
|
141
|
+
const row = Math.floor(share / across);
|
|
142
|
+
const inRow = row === down - 1 ? shares - row * across : across;
|
|
143
|
+
// A short last row is centred under the rows above it.
|
|
144
|
+
const left = padding +
|
|
145
|
+
(width - span(inRow, gridWidth)) / 2 +
|
|
146
|
+
(share % across) * (gridWidth + gap);
|
|
147
|
+
const top = gridsTop + row * (gridHeight + gap);
|
|
148
|
+
const toMm = ([x, y]) => [
|
|
149
|
+
left + (x - minX) * size,
|
|
150
|
+
top + (y - minY) * size,
|
|
151
|
+
];
|
|
152
|
+
return element("g", { class: "share", "data-share": share }, drawCells(data.board, toMm, size) +
|
|
153
|
+
element("g", { class: "pieces" }, grid
|
|
154
|
+
.map((piece) => drawTile(piece.id, piece.cells, lookOf(piece.id, piece.order, options), piece.placed ? "piece placed" : "piece", piece.placed, toMm, size))
|
|
155
|
+
.join("")));
|
|
156
|
+
})
|
|
157
|
+
.join(""));
|
|
158
|
+
return root(Number(fmt(padding * 2 + width)), Number(fmt(padding * 2 + gridsHeight + trayRoom)), above ? tray + drawnGrids : drawnGrids + tray);
|
|
159
|
+
}
|
|
160
|
+
/** As near a square of grids as there is: two across for two, three or four shares. */
|
|
161
|
+
export function defaultGridsPerRow(shares) {
|
|
162
|
+
return Math.ceil(Math.sqrt(shares));
|
|
163
|
+
}
|
|
164
|
+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AG,KAAK,CAAC,CAAC,EAChC,MAAM,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAC,EACjD,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAC9C,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
package/fills.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Point } from "./outline.js";
|
|
2
|
+
/** How many distinct piece fills there are before they repeat. */
|
|
3
|
+
export declare const fillCount = 6;
|
|
4
|
+
/** A piece's shape in millimetres: its cells' top-left corners, the cell size, and its outline loops, already inset. */
|
|
5
|
+
export interface Shape {
|
|
6
|
+
cells: readonly Point[];
|
|
7
|
+
size: number;
|
|
8
|
+
loops: readonly Point[][];
|
|
9
|
+
}
|
|
10
|
+
/** A piece's fill: one colour for the whole piece, and a pattern drawn on top. */
|
|
11
|
+
export interface Fill {
|
|
12
|
+
colour: string;
|
|
13
|
+
/** The pattern over the shape, or "" for a plain fill. */
|
|
14
|
+
pattern: (shape: Shape) => string;
|
|
15
|
+
}
|
|
16
|
+
/** The fill for the piece at `index` in its position's order; they cycle. */
|
|
17
|
+
export declare function pieceFill(index: number): Fill;
|
|
18
|
+
/** A flat fill in one colour, for a piece drawn in its kit's. */
|
|
19
|
+
export declare function flatFill(colour: string): Fill;
|
|
20
|
+
/** The grey a ghost is drawn in when its piece has no colour. */
|
|
21
|
+
export declare const ghostGrey = "#777";
|
|
22
|
+
/**
|
|
23
|
+
* A ghost's fill: white, with wide light stripes in the piece's colour
|
|
24
|
+
* lightened half-way to white, or a light grey without one. Every ghost looks
|
|
25
|
+
* the same whatever its order, since on the child's sheet the shapes tell the
|
|
26
|
+
* pieces apart and the real piece covers the drawing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ghostFill(colour: string | undefined): Fill;
|
|
29
|
+
/** The colour mixed half and half with white; a colour that isn't `#rrggbb` comes back as it is. */
|
|
30
|
+
export declare function lighten(colour: string): string;
|
|
31
|
+
//# sourceMappingURL=fills.d.ts.map
|
package/fills.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fills.d.ts","sourceRoot":"","sources":["src/fills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,kEAAkE;AAClE,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,wHAAwH;AACxH,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,KAAK,EAAE,EAAE,CAAC;CAC3B;AAED,kFAAkF;AAClF,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;CACnC;AAiHD,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,iEAAiE;AACjE,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAW1D;AAED,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAW9C"}
|
package/fills.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { element, fmt } from "./svg.js";
|
|
2
|
+
/** How many distinct piece fills there are before they repeat. */
|
|
3
|
+
export const fillCount = 6;
|
|
4
|
+
const hatchStroke = { stroke: "#000", "stroke-width": 0.3 };
|
|
5
|
+
/**
|
|
6
|
+
* Segments of the lines x + y = d (or x - y = d when mirrored), d stepping by
|
|
7
|
+
* `spacing` from the first cell's corner, clipped to the shape's loops.
|
|
8
|
+
*/
|
|
9
|
+
function diagonals(shape, mirrored, spacing) {
|
|
10
|
+
const [first] = shape.cells;
|
|
11
|
+
if (first === undefined)
|
|
12
|
+
return "";
|
|
13
|
+
const level = ([x, y]) => (mirrored ? x - y : x + y);
|
|
14
|
+
const along = ([x, y]) => (mirrored ? x + y : x - y);
|
|
15
|
+
const corners = shape.loops.flat();
|
|
16
|
+
const levels = corners.map(level);
|
|
17
|
+
const base = level(first);
|
|
18
|
+
const from = Math.ceil((Math.min(...levels) - base) / spacing);
|
|
19
|
+
const to = Math.floor((Math.max(...levels) - base) / spacing);
|
|
20
|
+
const parts = [];
|
|
21
|
+
for (let k = from; k <= to; k++) {
|
|
22
|
+
const d = base + k * spacing;
|
|
23
|
+
for (const [a, b] of crossings(shape.loops, (p) => level(p) - d, along)) {
|
|
24
|
+
parts.push(`M${fmt(a[0])} ${fmt(a[1])}L${fmt(b[0])} ${fmt(b[1])}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return parts.join("");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Where a line crosses the loops' edges, paired into the stretches inside the
|
|
31
|
+
* shape. `side` is a point's signed distance from the line; `along` orders
|
|
32
|
+
* points on it. An edge counts when its ends are on different sides, with a
|
|
33
|
+
* point on the line counted as the positive side, so a line through a corner
|
|
34
|
+
* is counted once if it crosses there and twice or not at all if it touches.
|
|
35
|
+
*/
|
|
36
|
+
function crossings(loops, side, along) {
|
|
37
|
+
const points = [];
|
|
38
|
+
for (const loop of loops) {
|
|
39
|
+
loop.forEach((a, i) => {
|
|
40
|
+
const b = loop[(i + 1) % loop.length];
|
|
41
|
+
const sa = side(a);
|
|
42
|
+
const sb = side(b);
|
|
43
|
+
if (sa < 0 === sb < 0)
|
|
44
|
+
return;
|
|
45
|
+
const t = sa / (sa - sb);
|
|
46
|
+
points.push([a[0] + t * (b[0] - a[0]), a[1] + t * (b[1] - a[1])]);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
points.sort((p, q) => along(p) - along(q));
|
|
50
|
+
const pairs = [];
|
|
51
|
+
for (let i = 0; i + 1 < points.length; i += 2) {
|
|
52
|
+
const a = points[i];
|
|
53
|
+
const b = points[i + 1];
|
|
54
|
+
if (along(b) - along(a) > 1e-6)
|
|
55
|
+
pairs.push([a, b]);
|
|
56
|
+
}
|
|
57
|
+
return pairs;
|
|
58
|
+
}
|
|
59
|
+
function dots(shape) {
|
|
60
|
+
const step = shape.size / 3;
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const [x, y] of shape.cells) {
|
|
63
|
+
for (let i = 0; i < 3; i++) {
|
|
64
|
+
for (let j = 0; j < 3; j++) {
|
|
65
|
+
out.push(element("circle", {
|
|
66
|
+
cx: x + step * (i + 0.5),
|
|
67
|
+
cy: y + step * (j + 0.5),
|
|
68
|
+
r: shape.size / 16,
|
|
69
|
+
fill: "#000",
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return out.join("");
|
|
75
|
+
}
|
|
76
|
+
const plain = () => "";
|
|
77
|
+
/**
|
|
78
|
+
* The fills in order: light grey, mid grey, hatched, cross-hatched, dotted,
|
|
79
|
+
* white, so the first pieces read against the white board by fill and
|
|
80
|
+
* apart from the blockers' darker grey. None uses an id.
|
|
81
|
+
*/
|
|
82
|
+
const fills = [
|
|
83
|
+
{ colour: "#dcdcdc", pattern: plain },
|
|
84
|
+
{ colour: "#b3b3b3", pattern: plain },
|
|
85
|
+
{
|
|
86
|
+
colour: "#fff",
|
|
87
|
+
pattern: (shape) => element("path", {
|
|
88
|
+
d: diagonals(shape, false, shape.size / 4),
|
|
89
|
+
...hatchStroke,
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
colour: "#fff",
|
|
94
|
+
pattern: (shape) => element("path", {
|
|
95
|
+
d: diagonals(shape, false, shape.size / 4) +
|
|
96
|
+
diagonals(shape, true, shape.size / 4),
|
|
97
|
+
...hatchStroke,
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
{ colour: "#fff", pattern: dots },
|
|
101
|
+
{ colour: "#fff", pattern: plain },
|
|
102
|
+
];
|
|
103
|
+
/** The fill for the piece at `index` in its position's order; they cycle. */
|
|
104
|
+
export function pieceFill(index) {
|
|
105
|
+
return fills[((index % fillCount) + fillCount) % fillCount];
|
|
106
|
+
}
|
|
107
|
+
/** A flat fill in one colour, for a piece drawn in its kit's. */
|
|
108
|
+
export function flatFill(colour) {
|
|
109
|
+
return { colour, pattern: plain };
|
|
110
|
+
}
|
|
111
|
+
/** The grey a ghost is drawn in when its piece has no colour. */
|
|
112
|
+
export const ghostGrey = "#777";
|
|
113
|
+
/**
|
|
114
|
+
* A ghost's fill: white, with wide light stripes in the piece's colour
|
|
115
|
+
* lightened half-way to white, or a light grey without one. Every ghost looks
|
|
116
|
+
* the same whatever its order, since on the child's sheet the shapes tell the
|
|
117
|
+
* pieces apart and the real piece covers the drawing.
|
|
118
|
+
*/
|
|
119
|
+
export function ghostFill(colour) {
|
|
120
|
+
const stripe = colour === undefined ? "#b3b3b3" : lighten(colour);
|
|
121
|
+
return {
|
|
122
|
+
colour: "#fff",
|
|
123
|
+
pattern: (shape) => element("path", {
|
|
124
|
+
d: diagonals(shape, false, shape.size / 3),
|
|
125
|
+
stroke: stripe,
|
|
126
|
+
"stroke-width": 0.3,
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** The colour mixed half and half with white; a colour that isn't `#rrggbb` comes back as it is. */
|
|
131
|
+
export function lighten(colour) {
|
|
132
|
+
const match = /^#([0-9a-f]{6})$/i.exec(colour);
|
|
133
|
+
if (match === null)
|
|
134
|
+
return colour;
|
|
135
|
+
const hex = match[1];
|
|
136
|
+
return ("#" +
|
|
137
|
+
[0, 2, 4]
|
|
138
|
+
.map((i) => Math.round((parseInt(hex.slice(i, i + 2), 16) + 255) / 2))
|
|
139
|
+
.map((n) => n.toString(16).padStart(2, "0"))
|
|
140
|
+
.join(""));
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=fills.js.map
|
package/fills.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fills.js","sourceRoot":"","sources":["src/fills.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAExC,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAgB3B,MAAM,WAAW,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC;AAE5D;;;GAGG;AACH,SAAS,SAAS,CAAC,KAAY,EAAE,QAAiB,EAAE,OAAe;IACjE,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,O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CAAC,IAAI,GAAG,CAAC,CAAC;YAC1C,MAAM,EAAE,MAAM;YACd,cAAc,EAAE,GAAG;SACpB,CAAC;KACL,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;IAC/B,OAAO,CACL,GAAG;QACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;aACrE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aAC3C,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;AACJ,CAAC"}
|
package/geometry.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Cell, Placement } from "./types.js";
|
|
2
|
+
/** "x,y", for sets and maps keyed by cell. */
|
|
3
|
+
export declare function cellKey(cell: Cell): string;
|
|
4
|
+
/** Shifted so the smallest x and smallest y are 0, sorted by y then x. */
|
|
5
|
+
export declare function normalise(cells: readonly Cell[]): Cell[];
|
|
6
|
+
/**
|
|
7
|
+
* The shape's distinct orientations, each normalised: first its quarter turns
|
|
8
|
+
* clockwise, starting with the shape itself, then the turns of its mirror image
|
|
9
|
+
* that aren't already in the list. An orientation number is a position here.
|
|
10
|
+
*/
|
|
11
|
+
export declare function orientations(shape: readonly Cell[]): Cell[][];
|
|
12
|
+
/** The cells a placement covers. Throws RangeError if the orientation is past the list. */
|
|
13
|
+
export declare function place(shape: readonly Cell[], placement: Placement): Cell[];
|
|
14
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["src/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAElD,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE1C;AAMD,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,EAAE,CAIxD;AAwBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,CAO7D;AAED,2FAA2F;AAC3F,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,CAU1E"}
|
package/geometry.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** "x,y", for sets and maps keyed by cell. */
|
|
2
|
+
export function cellKey(cell) {
|
|
3
|
+
return `${cell[0]},${cell[1]}`;
|
|
4
|
+
}
|
|
5
|
+
function sorted(cells) {
|
|
6
|
+
return [...cells].sort((a, b) => a[1] - b[1] || a[0] - b[0]);
|
|
7
|
+
}
|
|
8
|
+
/** Shifted so the smallest x and smallest y are 0, sorted by y then x. */
|
|
9
|
+
export function normalise(cells) {
|
|
10
|
+
const minX = Math.min(...cells.map(([x]) => x));
|
|
11
|
+
const minY = Math.min(...cells.map(([, y]) => y));
|
|
12
|
+
return sorted(cells.map(([x, y]) => [x - minX, y - minY]));
|
|
13
|
+
}
|
|
14
|
+
/** A quarter turn clockwise, with y growing down. */
|
|
15
|
+
function turned(cells) {
|
|
16
|
+
return cells.map(([x, y]) => [-y, x]);
|
|
17
|
+
}
|
|
18
|
+
/** The shape's four quarter turns, normalised, without repeats. */
|
|
19
|
+
function turns(shape) {
|
|
20
|
+
const out = [];
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
let cells = [...shape];
|
|
23
|
+
for (let i = 0; i < 4; i++) {
|
|
24
|
+
const normalised = normalise(cells);
|
|
25
|
+
const key = normalised.map(cellKey).join(";");
|
|
26
|
+
if (!seen.has(key)) {
|
|
27
|
+
seen.add(key);
|
|
28
|
+
out.push(normalised);
|
|
29
|
+
}
|
|
30
|
+
cells = turned(cells);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The shape's distinct orientations, each normalised: first its quarter turns
|
|
36
|
+
* clockwise, starting with the shape itself, then the turns of its mirror image
|
|
37
|
+
* that aren't already in the list. An orientation number is a position here.
|
|
38
|
+
*/
|
|
39
|
+
export function orientations(shape) {
|
|
40
|
+
const own = turns(shape);
|
|
41
|
+
const seen = new Set(own.map((o) => o.map(cellKey).join(";")));
|
|
42
|
+
const mirrored = turns(shape.map(([x, y]) => [-x, y])).filter((o) => !seen.has(o.map(cellKey).join(";")));
|
|
43
|
+
return [...own, ...mirrored];
|
|
44
|
+
}
|
|
45
|
+
/** The cells a placement covers. Throws RangeError if the orientation is past the list. */
|
|
46
|
+
export function place(shape, placement) {
|
|
47
|
+
const all = orientations(shape);
|
|
48
|
+
const orientation = all[placement.orientation];
|
|
49
|
+
if (orientation === undefined) {
|
|
50
|
+
throw new RangeError(`Piece "${placement.pieceId}" has no orientation ${placement.orientation}; it has ${all.length}`);
|
|
51
|
+
}
|
|
52
|
+
const [originX, originY] = placement.origin;
|
|
53
|
+
return orientation.map(([x, y]) => [x + originX, y + originY]);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=geometry.js.map
|
package/geometry.js.map
ADDED
|
@@ -0,0 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G,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAC3C,CAAC;IACF,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,KAAK,CAAC,KAAsB,EAAE,SAAoB;IAChE,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,UAAU,CAClB,UAAU,SAAS,CAAC,OAAO,wBAAwB,SAAS,CAAC,WAAW,YAAY,GAAG,CAAC,MAAM,EAAE,CACjG,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;IAC5C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { Cell, Clue, FairSharesInstance, GameData, Instance, LineCountsInstance, LoosePiece, Mark, Piece, Placement, Position, SharePiece, SharePlacement, } from "./types.js";
|
|
2
|
+
export { normalise, orientations, place } from "./geometry.js";
|
|
3
|
+
export { positions } from "./positions.js";
|
|
4
|
+
export type { MarkCell, MarkDrawer } from "./marks.js";
|
|
5
|
+
export { placeholder, standardMarkKinds, standardMarks, star, target, } from "./marks.js";
|
|
6
|
+
export type { RenderOptions } from "./board.js";
|
|
7
|
+
export { renderBoard } from "./board.js";
|
|
8
|
+
export { renderSolution } from "./solution.js";
|
|
9
|
+
export { clueBands } from "./clues.js";
|
|
10
|
+
export { isLineCounts, isPlaced, positionCount } from "./line-counts.js";
|
|
11
|
+
export { gridGapCells, isFairShares } from "./fair-shares.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,IAAI,EACJ,IAAI,EACJ,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,UAAU,EACV,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,MAAM,GACP,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { normalise, orientations, place } from "./geometry.js";
|
|
2
|
+
export { positions } from "./positions.js";
|
|
3
|
+
export { placeholder, standardMarkKinds, standardMarks, star, target, } from "./marks.js";
|
|
4
|
+
export { renderBoard } from "./board.js";
|
|
5
|
+
export { renderSolution } from "./solution.js";
|
|
6
|
+
export { clueBands } from "./clues.js";
|
|
7
|
+
export { isLineCounts, isPlaced, positionCount } from "./line-counts.js";
|
|
8
|
+
export { gridGapCells, isFairShares } from "./fair-shares.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,MAAM,GACP,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
package/line-counts.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type RenderOptions } from "./board.js";
|
|
2
|
+
import type { GameData, LineCountsInstance, LoosePiece, Piece } from "./types.js";
|
|
3
|
+
export declare function isLineCounts(data: GameData): data is LineCountsInstance;
|
|
4
|
+
/**
|
|
5
|
+
* Whether a piece starts on the board, or in Fair Shares on a share's grid. A
|
|
6
|
+
* piece to place has no origin, or a null one: a delivery file may carry
|
|
7
|
+
* either, and the API leaves it out.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPlaced<P extends Piece>(piece: P | LoosePiece): piece is P;
|
|
10
|
+
/**
|
|
11
|
+
* How many positions a board has, for `renderBoard`'s `position`. Amoeba has
|
|
12
|
+
* the start and one per move. Line Counts and Fair Shares have the start
|
|
13
|
+
* and, when the solution places anything, the solved board.
|
|
14
|
+
*/
|
|
15
|
+
export declare function positionCount(data: GameData): number;
|
|
16
|
+
/**
|
|
17
|
+
* A Line Counts board as a complete SVG document: at position 0 the start,
|
|
18
|
+
* with the pieces to place in a tray under the board, or above it when
|
|
19
|
+
* `trayPosition` says so; at position 1 the
|
|
20
|
+
* solved board, where the pieces the solution placed have the heavy outline.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderLineCounts(data: LineCountsInstance, options?: RenderOptions & {
|
|
23
|
+
position?: number;
|
|
24
|
+
}): string;
|
|
25
|
+
//# sourceMappingURL=line-counts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-counts.d.ts","sourceRoot":"","sources":["src/line-counts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAOnB,MAAM,YAAY,CAAC;AAOpB,OAAO,KAAK,EAEV,QAAQ,EACR,kBAAkB,EAClB,UAAU,EACV,KAAK,EAEN,MAAM,YAAY,CAAC;AAEpB,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,kBAAkB,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,GAAG,KAAK,IAAI,CAAC,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAIpD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,kBAAkB,EACxB,OAAO,GAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,MAAM,CAyJR"}
|