@altnovatrail/picture-kit 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/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +27 -2
- package/lib/emoji.d.ts +16 -0
- package/lib/emoji.js +64 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +10 -0
- package/lib/kind.d.ts +22 -0
- package/lib/kind.js +2 -0
- package/lib/kinds/balance.d.ts +34 -0
- package/lib/kinds/balance.js +217 -0
- package/lib/kinds/branches.d.ts +33 -0
- package/lib/kinds/branches.js +473 -0
- package/lib/kinds/calendar.d.ts +55 -0
- package/lib/kinds/calendar.js +532 -0
- package/lib/kinds/chart.d.ts +48 -0
- package/lib/kinds/chart.js +645 -0
- package/lib/kinds/choices.d.ts +14 -0
- package/lib/kinds/choices.js +53 -0
- package/lib/kinds/clock.d.ts +36 -0
- package/lib/kinds/clock.js +219 -0
- package/lib/kinds/coins.d.ts +37 -0
- package/lib/kinds/coins.js +550 -0
- package/lib/kinds/column.d.ts +37 -0
- package/lib/kinds/column.js +410 -0
- package/lib/kinds/commands-parts.d.ts +12 -0
- package/lib/kinds/commands-parts.js +24 -0
- package/lib/kinds/commands.d.ts +66 -0
- package/lib/kinds/commands.js +789 -0
- package/lib/kinds/containers.d.ts +52 -0
- package/lib/kinds/containers.js +758 -0
- package/lib/kinds/countfig.d.ts +41 -0
- package/lib/kinds/countfig.js +372 -0
- package/lib/kinds/cubes.d.ts +70 -0
- package/lib/kinds/cubes.js +371 -0
- package/lib/kinds/die.d.ts +32 -0
- package/lib/kinds/die.js +301 -0
- package/lib/kinds/domino.d.ts +37 -0
- package/lib/kinds/domino.js +450 -0
- package/lib/kinds/dotgrid.d.ts +38 -0
- package/lib/kinds/dotgrid.js +411 -0
- package/lib/kinds/figure.d.ts +62 -0
- package/lib/kinds/figure.js +687 -0
- package/lib/kinds/fold-parts.d.ts +73 -0
- package/lib/kinds/fold-parts.js +315 -0
- package/lib/kinds/fold.d.ts +52 -0
- package/lib/kinds/fold.js +650 -0
- package/lib/kinds/fraction.d.ts +50 -0
- package/lib/kinds/fraction.js +568 -0
- package/lib/kinds/gauges.d.ts +53 -0
- package/lib/kinds/gauges.js +880 -0
- package/lib/kinds/gears.d.ts +40 -0
- package/lib/kinds/gears.js +787 -0
- package/lib/kinds/grid.d.ts +45 -0
- package/lib/kinds/grid.js +591 -0
- package/lib/kinds/groups.d.ts +23 -0
- package/lib/kinds/groups.js +335 -0
- package/lib/kinds/index.d.ts +3 -0
- package/lib/kinds/index.js +87 -0
- package/lib/kinds/lanes.d.ts +36 -0
- package/lib/kinds/lanes.js +220 -0
- package/lib/kinds/layers.d.ts +31 -0
- package/lib/kinds/layers.js +419 -0
- package/lib/kinds/line.d.ts +38 -0
- package/lib/kinds/line.js +739 -0
- package/lib/kinds/magic-parts.d.ts +72 -0
- package/lib/kinds/magic-parts.js +186 -0
- package/lib/kinds/magic.d.ts +66 -0
- package/lib/kinds/magic.js +664 -0
- package/lib/kinds/map.d.ts +32 -0
- package/lib/kinds/map.js +370 -0
- package/lib/kinds/matchsticks.d.ts +26 -0
- package/lib/kinds/matchsticks.js +434 -0
- package/lib/kinds/necklace.d.ts +27 -0
- package/lib/kinds/necklace.js +342 -0
- package/lib/kinds/net.d.ts +47 -0
- package/lib/kinds/net.js +241 -0
- package/lib/kinds/overlay.d.ts +50 -0
- package/lib/kinds/overlay.js +519 -0
- package/lib/kinds/pieces.d.ts +41 -0
- package/lib/kinds/pieces.js +420 -0
- package/lib/kinds/pipes.d.ts +46 -0
- package/lib/kinds/pipes.js +657 -0
- package/lib/kinds/plane-parts.d.ts +105 -0
- package/lib/kinds/plane-parts.js +372 -0
- package/lib/kinds/plane.d.ts +35 -0
- package/lib/kinds/plane.js +755 -0
- package/lib/kinds/pyramid.d.ts +26 -0
- package/lib/kinds/pyramid.js +228 -0
- package/lib/kinds/ropes.d.ts +30 -0
- package/lib/kinds/ropes.js +571 -0
- package/lib/kinds/shapes.d.ts +59 -0
- package/lib/kinds/shapes.js +490 -0
- package/lib/kinds/solids.d.ts +78 -0
- package/lib/kinds/solids.js +1058 -0
- package/lib/kinds/tangram.d.ts +52 -0
- package/lib/kinds/tangram.js +713 -0
- package/lib/kinds/target.d.ts +39 -0
- package/lib/kinds/target.js +761 -0
- package/lib/kinds/tiles.d.ts +55 -0
- package/lib/kinds/tiles.js +606 -0
- package/lib/kinds/venn.d.ts +38 -0
- package/lib/kinds/venn.js +710 -0
- package/lib/noto.d.ts +2 -0
- package/lib/noto.js +212 -0
- package/lib/objects.d.ts +7 -0
- package/lib/objects.js +226 -0
- package/lib/pen.d.ts +32 -0
- package/lib/pen.js +60 -0
- package/lib/read.d.ts +9 -0
- package/lib/read.js +49 -0
- package/lib/render.d.ts +24 -0
- package/lib/render.js +68 -0
- package/lib/solve/balance.d.ts +46 -0
- package/lib/solve/balance.js +118 -0
- package/lib/style.d.ts +70 -0
- package/lib/style.js +39 -0
- package/lib/svg.d.ts +22 -0
- package/lib/svg.js +48 -0
- package/lib/things.d.ts +40 -0
- package/lib/things.js +269 -0
- package/package.json +28 -4
package/lib/kinds/die.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { margin } from "../kind.js";
|
|
2
|
+
import { textWidth } from "../pen.js";
|
|
3
|
+
import { int, isObj, list, only, text } from "../read.js";
|
|
4
|
+
import { colors, ink, outline } from "../style.js";
|
|
5
|
+
import { n } from "../svg.js";
|
|
6
|
+
import { box, cornersOf, onFace, projector } from "./cubes.js";
|
|
7
|
+
const shown = ["top", "front", "right"];
|
|
8
|
+
const biggest = 62;
|
|
9
|
+
const room = 640 - 2 * margin;
|
|
10
|
+
const across = Math.cos(Math.PI / 6);
|
|
11
|
+
const spot = 6.2;
|
|
12
|
+
/** pips are the places of the pips of each value on a box × box face. */
|
|
13
|
+
export const pips = {
|
|
14
|
+
1: [[32, 32]],
|
|
15
|
+
2: [
|
|
16
|
+
[17, 17],
|
|
17
|
+
[47, 47],
|
|
18
|
+
],
|
|
19
|
+
3: [
|
|
20
|
+
[17, 17],
|
|
21
|
+
[32, 32],
|
|
22
|
+
[47, 47],
|
|
23
|
+
],
|
|
24
|
+
4: [
|
|
25
|
+
[17, 17],
|
|
26
|
+
[47, 17],
|
|
27
|
+
[17, 47],
|
|
28
|
+
[47, 47],
|
|
29
|
+
],
|
|
30
|
+
5: [
|
|
31
|
+
[17, 17],
|
|
32
|
+
[47, 17],
|
|
33
|
+
[32, 32],
|
|
34
|
+
[17, 47],
|
|
35
|
+
[47, 47],
|
|
36
|
+
],
|
|
37
|
+
6: [
|
|
38
|
+
[17, 15],
|
|
39
|
+
[47, 15],
|
|
40
|
+
[17, 32],
|
|
41
|
+
[47, 32],
|
|
42
|
+
[17, 49],
|
|
43
|
+
[47, 49],
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
function isView(die) {
|
|
47
|
+
return "top" in die;
|
|
48
|
+
}
|
|
49
|
+
function checkValue(value, path, problems) {
|
|
50
|
+
if (value === "?")
|
|
51
|
+
return;
|
|
52
|
+
if (typeof value !== "number") {
|
|
53
|
+
problems.push(`${path}: must be a number of pips from 1 to 6, or "?"`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
int(value, path, problems, 1, 6);
|
|
57
|
+
}
|
|
58
|
+
// The faces of a die by where they face: up, down, north (back), south
|
|
59
|
+
// (front), east (right), west (left), each with its outward direction.
|
|
60
|
+
const sides = ["U", "D", "N", "S", "E", "W"];
|
|
61
|
+
const normal = {
|
|
62
|
+
U: [0, 0, 1],
|
|
63
|
+
D: [0, 0, -1],
|
|
64
|
+
N: [0, -1, 0],
|
|
65
|
+
S: [0, 1, 0],
|
|
66
|
+
E: [1, 0, 0],
|
|
67
|
+
W: [-1, 0, 0],
|
|
68
|
+
};
|
|
69
|
+
function det(a, b, c) {
|
|
70
|
+
return (a[0] * (b[1] * c[2] - b[2] * c[1]) -
|
|
71
|
+
a[1] * (b[0] * c[2] - b[2] * c[0]) +
|
|
72
|
+
a[2] * (b[0] * c[1] - b[1] * c[0]));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The eight corners of a die, each as its three faces in the turn a view
|
|
76
|
+
* shows them: top, then right, then front, clockwise seen from outside.
|
|
77
|
+
*/
|
|
78
|
+
const corners = ["U", "D"].flatMap((a) => ["N", "S"].flatMap((b) => ["E", "W"].map((c) => {
|
|
79
|
+
const three = [a, c, b];
|
|
80
|
+
return det(normal[a], normal[c], normal[b]) > 0 ? three : [a, b, c];
|
|
81
|
+
})));
|
|
82
|
+
function labellings(standard) {
|
|
83
|
+
const out = [];
|
|
84
|
+
const walk = (left, got) => {
|
|
85
|
+
if (left.length === 0) {
|
|
86
|
+
const l = Object.fromEntries(sides.map((s, i) => [s, got[i]]));
|
|
87
|
+
if (!standard || (l.U + l.D === 7 && l.N + l.S === 7 && l.E + l.W === 7))
|
|
88
|
+
out.push(l);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
left.forEach((v, i) => {
|
|
92
|
+
walk([...left.slice(0, i), ...left.slice(i + 1)], [...got, v]);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
walk([1, 2, 3, 4, 5, 6], []);
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/** shows tells whether a die labelled so can be turned to show a view. */
|
|
99
|
+
function shows(l, view) {
|
|
100
|
+
const want = [view.top, view.right, view.front];
|
|
101
|
+
return corners.some((corner) => [0, 1, 2].some((turn) => want.every((w, k) => w === "?" || w === l[corner[(k + turn) % 3]])));
|
|
102
|
+
}
|
|
103
|
+
/** drawFlat draws one face of a die, flat, its top left at x, y, size across. */
|
|
104
|
+
function drawFlat(pen, value, x, y, size) {
|
|
105
|
+
pen.el("rect", {
|
|
106
|
+
x,
|
|
107
|
+
y,
|
|
108
|
+
width: size,
|
|
109
|
+
height: size,
|
|
110
|
+
rx: size * 0.17,
|
|
111
|
+
fill: "#ffffff",
|
|
112
|
+
stroke: ink,
|
|
113
|
+
"stroke-width": outline,
|
|
114
|
+
});
|
|
115
|
+
const sub = pen.sub();
|
|
116
|
+
facePrint(sub, value);
|
|
117
|
+
const k = size / box;
|
|
118
|
+
pen.add(`<g transform="translate(${n(x)} ${n(y)}) scale(${k.toFixed(4)})">${sub.markup()}</g>`);
|
|
119
|
+
}
|
|
120
|
+
/** facePrint draws the pips of a value, or a "?", on a box × box face. */
|
|
121
|
+
function facePrint(pen, value) {
|
|
122
|
+
if (value === "?") {
|
|
123
|
+
pen.text(box / 2, box / 2, "?", { size: 40 });
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const [x, y] of pips[value])
|
|
127
|
+
pen.el("circle", { cx: x, cy: y, r: spot, fill: ink });
|
|
128
|
+
}
|
|
129
|
+
/** rounded is the outline of a polygon whose corners are rounded r pixels back. */
|
|
130
|
+
function rounded(points, r) {
|
|
131
|
+
const at = (p) => `${n(p.x)} ${n(p.y)}`;
|
|
132
|
+
let d = "";
|
|
133
|
+
points.forEach((p, i) => {
|
|
134
|
+
const prev = points[(i + points.length - 1) % points.length];
|
|
135
|
+
const next = points[(i + 1) % points.length];
|
|
136
|
+
const cut = (q) => {
|
|
137
|
+
const len = Math.hypot(q.x - p.x, q.y - p.y);
|
|
138
|
+
const k = Math.min(0.45, r / len);
|
|
139
|
+
return { x: p.x + (q.x - p.x) * k, y: p.y + (q.y - p.y) * k };
|
|
140
|
+
};
|
|
141
|
+
d += `${i === 0 ? "M" : "L"}${at(cut(prev))}Q${at(p)} ${at(cut(next))}`;
|
|
142
|
+
});
|
|
143
|
+
return `${d}Z`;
|
|
144
|
+
}
|
|
145
|
+
const faceFill = {
|
|
146
|
+
top: "#ffffff",
|
|
147
|
+
front: "#eef1f6",
|
|
148
|
+
right: colors.white.dark,
|
|
149
|
+
};
|
|
150
|
+
/** drawView draws a die seen from above, the front and the right, edge s, its top left at x, y. */
|
|
151
|
+
function drawView(pen, view, x, y, s) {
|
|
152
|
+
const at = projector(s, x + across * s, y + s);
|
|
153
|
+
const outer = [at(0, 0, 1), at(1, 0, 1), at(1, 0, 0), at(1, 1, 0), at(0, 1, 0), at(0, 1, 1)];
|
|
154
|
+
pen.el("path", {
|
|
155
|
+
d: rounded(outer, s * 0.2),
|
|
156
|
+
fill: faceFill.right,
|
|
157
|
+
stroke: ink,
|
|
158
|
+
"stroke-width": outline,
|
|
159
|
+
"stroke-linejoin": "round",
|
|
160
|
+
});
|
|
161
|
+
for (const face of shown) {
|
|
162
|
+
const corners_ = cornersOf({ x: 0, y: 0, z: 0 }, face, at);
|
|
163
|
+
// the face sits a little inside the die's edges, its corners rounded,
|
|
164
|
+
// so the die reads as a rounded one
|
|
165
|
+
const mid = {
|
|
166
|
+
x: corners_.reduce((sum, p) => sum + p.x, 0) / 4,
|
|
167
|
+
y: corners_.reduce((sum, p) => sum + p.y, 0) / 4,
|
|
168
|
+
};
|
|
169
|
+
const inner = corners_.map((p) => ({
|
|
170
|
+
x: mid.x + (p.x - mid.x) * 0.9,
|
|
171
|
+
y: mid.y + (p.y - mid.y) * 0.9,
|
|
172
|
+
}));
|
|
173
|
+
pen.el("path", {
|
|
174
|
+
d: rounded(inner, s * 0.16),
|
|
175
|
+
fill: faceFill[face],
|
|
176
|
+
stroke: ink,
|
|
177
|
+
"stroke-width": outline * 0.6,
|
|
178
|
+
"stroke-linejoin": "round",
|
|
179
|
+
});
|
|
180
|
+
const sub = pen.sub();
|
|
181
|
+
facePrint(sub, view[face]);
|
|
182
|
+
pen.add(`<g transform="${onFace(corners_)}">${sub.markup()}</g>`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function sizeOf(dice, arrows) {
|
|
186
|
+
const gap = arrows ? 52 : 26;
|
|
187
|
+
const units = dice.reduce((sum, d) => sum + (isView(d) ? 2 * across : 1.15), 0);
|
|
188
|
+
return Math.min(biggest, (room - gap * (dice.length - 1)) / units);
|
|
189
|
+
}
|
|
190
|
+
const say = (v) => (v === "?" ? "a question mark" : `${v} pip${v === 1 ? "" : "s"}`);
|
|
191
|
+
export const die = {
|
|
192
|
+
kind: "die",
|
|
193
|
+
members: ["kind", "dice", "standard", "same", "arrows"],
|
|
194
|
+
check(scene, problems) {
|
|
195
|
+
only(scene, this.members, "scene", problems);
|
|
196
|
+
for (const flag of ["standard", "same", "arrows"])
|
|
197
|
+
if (scene[flag] !== undefined && typeof scene[flag] !== "boolean")
|
|
198
|
+
problems.push(`${flag}: must be true or false`);
|
|
199
|
+
const dice = list(scene.dice, "dice", problems, 1, 6);
|
|
200
|
+
dice.forEach((d, i) => {
|
|
201
|
+
const path = `dice[${i}]`;
|
|
202
|
+
if (!isObj(d)) {
|
|
203
|
+
problems.push(`${path}: must be a die: top, front and right, or one face`);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (d.label !== undefined)
|
|
207
|
+
text(d.label, `${path}.label`, problems, 10);
|
|
208
|
+
if ("face" in d) {
|
|
209
|
+
only(d, ["face", "label"], path, problems);
|
|
210
|
+
checkValue(d.face, `${path}.face`, problems);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
only(d, ["top", "front", "right", "label"], path, problems);
|
|
214
|
+
for (const f of shown)
|
|
215
|
+
checkValue(d[f], `${path}.${f}`, problems);
|
|
216
|
+
});
|
|
217
|
+
if (problems.length > 0)
|
|
218
|
+
return;
|
|
219
|
+
const typed = scene;
|
|
220
|
+
const views = typed.dice.map((d, i) => ({ d, i })).filter((v) => isView(v.d));
|
|
221
|
+
for (const { d, i } of views) {
|
|
222
|
+
shown.forEach((f, k) => {
|
|
223
|
+
for (const g of shown.slice(0, k)) {
|
|
224
|
+
const [a, b] = [d[g], d[f]];
|
|
225
|
+
if (a === "?" || b === "?")
|
|
226
|
+
continue;
|
|
227
|
+
if (a === b)
|
|
228
|
+
problems.push(`dice[${i}].${f}: ${b} shows on the ${g} too; a die has each of 1 to 6 once`);
|
|
229
|
+
else if (typed.standard && a + b === 7)
|
|
230
|
+
problems.push(`dice[${i}].${f}: ${a} and ${b} are opposite faces of a standard die, they never show together`);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (problems.length > 0 || !typed.same)
|
|
235
|
+
return;
|
|
236
|
+
let left = labellings(typed.standard === true);
|
|
237
|
+
for (const { d, i } of views) {
|
|
238
|
+
left = left.filter((l) => shows(l, d));
|
|
239
|
+
if (left.length === 0) {
|
|
240
|
+
problems.push(`dice[${i}]: no one die${typed.standard ? ", standard," : ""} shows this view and the views before it; with same, every view is of one die`);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
draw(scene, pen) {
|
|
246
|
+
const typed = scene;
|
|
247
|
+
const arrows = typed.arrows === true;
|
|
248
|
+
const gap = arrows ? 52 : 26;
|
|
249
|
+
const s = sizeOf(typed.dice, arrows);
|
|
250
|
+
const high = 2 * s;
|
|
251
|
+
const labelled = typed.dice.some((d) => d.label);
|
|
252
|
+
let x = margin;
|
|
253
|
+
typed.dice.forEach((d, i) => {
|
|
254
|
+
const w = isView(d) ? 2 * across * s : 1.15 * s;
|
|
255
|
+
const bw = Math.max(w, d.label ? textWidth(d.label, 18) : 0);
|
|
256
|
+
const left = x + (bw - w) / 2;
|
|
257
|
+
if (isView(d))
|
|
258
|
+
drawView(pen, d, left, margin, s);
|
|
259
|
+
else
|
|
260
|
+
drawFlat(pen, d.face, left, margin + (high - w) / 2, w);
|
|
261
|
+
if (d.label)
|
|
262
|
+
pen.text(x + bw / 2, margin + high + 22, d.label, { size: 18 });
|
|
263
|
+
x += bw;
|
|
264
|
+
if (arrows && i < typed.dice.length - 1) {
|
|
265
|
+
const y = margin + high / 2;
|
|
266
|
+
const [a, b] = [x + 10, x + gap - 10];
|
|
267
|
+
pen.el("path", {
|
|
268
|
+
d: `M${n(a)} ${n(y)}H${n(b - 6)}`,
|
|
269
|
+
stroke: ink,
|
|
270
|
+
"stroke-width": 3,
|
|
271
|
+
"stroke-linecap": "round",
|
|
272
|
+
});
|
|
273
|
+
pen.el("path", {
|
|
274
|
+
d: `M${n(b - 9)} ${n(y - 7)}L${n(b)} ${n(y)}L${n(b - 9)} ${n(y + 7)}Z`,
|
|
275
|
+
fill: ink,
|
|
276
|
+
stroke: ink,
|
|
277
|
+
"stroke-width": 2,
|
|
278
|
+
"stroke-linejoin": "round",
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
x += gap;
|
|
282
|
+
});
|
|
283
|
+
return { width: x - gap + margin, height: margin + high + (labelled ? 38 : 0) + margin };
|
|
284
|
+
},
|
|
285
|
+
describe(scene) {
|
|
286
|
+
const typed = scene;
|
|
287
|
+
const one = (d) => isView(d)
|
|
288
|
+
? `${say(d.top)} on top, ${say(d.front)} on the front and ${say(d.right)} on the right`
|
|
289
|
+
: `one face, flat, with ${say(d.face)}`;
|
|
290
|
+
const notes = [
|
|
291
|
+
typed.standard ? "Every die is a standard die: opposite faces add up to 7." : "",
|
|
292
|
+
typed.same && typed.dice.length > 1 ? "All the pictures show one and the same die." : "",
|
|
293
|
+
].filter(Boolean);
|
|
294
|
+
const tail = notes.length ? ` ${notes.join(" ")}` : "";
|
|
295
|
+
if (typed.dice.length === 1)
|
|
296
|
+
return `A die showing ${one(typed.dice[0])}.${tail}`;
|
|
297
|
+
return `${typed.dice.length} dice in a row${typed.arrows ? ", an arrow from each to the next" : ""}. ${typed.dice
|
|
298
|
+
.map((d, i) => `Die ${d.label ?? i + 1}: ${one(d)}.`)
|
|
299
|
+
.join(" ")}${tail}`;
|
|
300
|
+
},
|
|
301
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Kind } from "../kind.ts";
|
|
2
|
+
import { type ColorName } from "../style.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Domino: tiles of two halves, each half 0 to 9 pips, "?" where the question
|
|
5
|
+
* asks, or "cloud" for a half hidden under a cloud. layout lays them out:
|
|
6
|
+
*
|
|
7
|
+
* - row: apart, from left to right, standing upright with upright, else
|
|
8
|
+
* lying flat; a tile is [first, second] — top and bottom, or left and right.
|
|
9
|
+
* - chain: lying flat end to end, from left to right.
|
|
10
|
+
* - ring: end to end in a closed ring round the edge of a rectangle columns
|
|
11
|
+
* halves across (3 or more; as square as it can be unless given), clockwise
|
|
12
|
+
* from the top-left corner; a tile's halves go in that order, so that each
|
|
13
|
+
* tile's second half touches the next tile's first.
|
|
14
|
+
* - grid: each tile an object with its halves, at — [row, column] of its
|
|
15
|
+
* first half, its top or left one, counted from 1 at the top left of a board
|
|
16
|
+
* of halves — and upright; no two tiles share a place.
|
|
17
|
+
*
|
|
18
|
+
* color is the tiles' face, white unless given.
|
|
19
|
+
*/
|
|
20
|
+
export declare const dominoLayouts: readonly ["row", "chain", "ring", "grid"];
|
|
21
|
+
export type DominoLayout = (typeof dominoLayouts)[number];
|
|
22
|
+
export type Half = number | "?" | "cloud";
|
|
23
|
+
export type Tile = [Half, Half];
|
|
24
|
+
export type Placed = {
|
|
25
|
+
halves: Tile;
|
|
26
|
+
at: [number, number];
|
|
27
|
+
upright?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type DominoScene = {
|
|
30
|
+
kind: "domino";
|
|
31
|
+
layout: DominoLayout;
|
|
32
|
+
tiles: (Tile | Placed)[];
|
|
33
|
+
upright?: boolean;
|
|
34
|
+
columns?: number;
|
|
35
|
+
color?: ColorName;
|
|
36
|
+
};
|
|
37
|
+
export declare const domino: Kind;
|