@altnovatrail/picture-kit 0.1.1 → 0.2.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 +1 -1
- package/lib/index.d.ts +45 -1
- package/lib/index.js +34 -3
- package/lib/kinds/balance.js +2 -3
- package/lib/kinds/calendar.d.ts +5 -1
- package/lib/kinds/calendar.js +33 -11
- package/lib/kinds/chart.js +2 -4
- package/lib/kinds/clock.d.ts +5 -0
- package/lib/kinds/clock.js +45 -4
- package/lib/kinds/coins.js +3 -2
- package/lib/kinds/column.js +2 -3
- package/lib/kinds/commands.d.ts +8 -6
- package/lib/kinds/commands.js +57 -15
- package/lib/kinds/containers.js +2 -1
- package/lib/kinds/countfig.d.ts +2 -0
- package/lib/kinds/countfig.js +6 -1
- package/lib/kinds/cubes.d.ts +29 -5
- package/lib/kinds/cubes.js +82 -34
- package/lib/kinds/die.d.ts +8 -0
- package/lib/kinds/die.js +75 -14
- package/lib/kinds/domino.js +3 -3
- package/lib/kinds/dotgrid.d.ts +3 -0
- package/lib/kinds/dotgrid.js +6 -4
- package/lib/kinds/figure.js +5 -4
- package/lib/kinds/fold-parts.d.ts +0 -2
- package/lib/kinds/fold-parts.js +0 -4
- package/lib/kinds/fold.d.ts +20 -1
- package/lib/kinds/fold.js +15 -6
- package/lib/kinds/fraction.js +3 -2
- package/lib/kinds/gauges.js +2 -1
- package/lib/kinds/gears.d.ts +21 -2
- package/lib/kinds/gears.js +113 -62
- package/lib/kinds/grid.d.ts +5 -0
- package/lib/kinds/grid.js +30 -2
- package/lib/kinds/groups.d.ts +3 -1
- package/lib/kinds/groups.js +142 -28
- package/lib/kinds/lanes.js +3 -2
- package/lib/kinds/layers.d.ts +6 -0
- package/lib/kinds/layers.js +23 -4
- package/lib/kinds/line.d.ts +4 -0
- package/lib/kinds/line.js +117 -32
- package/lib/kinds/matchsticks.d.ts +4 -0
- package/lib/kinds/matchsticks.js +5 -3
- package/lib/kinds/net.js +4 -3
- package/lib/kinds/overlay.d.ts +23 -1
- package/lib/kinds/overlay.js +7 -3
- package/lib/kinds/pieces.js +3 -2
- package/lib/kinds/plane-parts.d.ts +0 -2
- package/lib/kinds/plane-parts.js +0 -6
- package/lib/kinds/plane.js +6 -6
- package/lib/kinds/ropes.js +1 -3
- package/lib/kinds/shapes.js +5 -7
- package/lib/kinds/solids.js +3 -2
- package/lib/kinds/tangram.js +2 -4
- package/lib/kinds/target.js +4 -6
- package/lib/kinds/tiles.js +5 -4
- package/lib/kinds/venn.js +3 -5
- package/lib/noto.js +1 -0
- package/lib/objects.js +2 -1
- package/lib/read.d.ts +2 -2
- package/lib/read.js +3 -3
- package/lib/solve/balance.d.ts +11 -0
- package/lib/solve/balance.js +116 -1
- package/lib/solve/calendar.d.ts +46 -0
- package/lib/solve/calendar.js +206 -0
- package/lib/solve/choice-scenes.d.ts +20 -0
- package/lib/solve/choice-scenes.js +51 -0
- package/lib/solve/clock.d.ts +54 -0
- package/lib/solve/clock.js +240 -0
- package/lib/solve/coins.d.ts +71 -0
- package/lib/solve/coins.js +222 -0
- package/lib/solve/commands.d.ts +36 -0
- package/lib/solve/commands.js +210 -0
- package/lib/solve/countfig.d.ts +41 -0
- package/lib/solve/countfig.js +199 -0
- package/lib/solve/cubes.d.ts +49 -0
- package/lib/solve/cubes.js +255 -0
- package/lib/solve/die.d.ts +39 -0
- package/lib/solve/die.js +93 -0
- package/lib/solve/domino.d.ts +57 -0
- package/lib/solve/domino.js +263 -0
- package/lib/solve/enumerate.d.ts +75 -0
- package/lib/solve/enumerate.js +323 -0
- package/lib/solve/figure.d.ts +26 -0
- package/lib/solve/figure.js +88 -0
- package/lib/solve/fold.d.ts +22 -0
- package/lib/solve/fold.js +68 -0
- package/lib/solve/gaps.d.ts +65 -0
- package/lib/solve/gaps.js +292 -0
- package/lib/solve/gears.d.ts +33 -0
- package/lib/solve/gears.js +130 -0
- package/lib/solve/grid.d.ts +35 -0
- package/lib/solve/grid.js +194 -0
- package/lib/solve/groups.d.ts +93 -0
- package/lib/solve/groups.js +346 -0
- package/lib/solve/index.d.ts +60 -0
- package/lib/solve/index.js +194 -0
- package/lib/solve/layers.d.ts +30 -0
- package/lib/solve/layers.js +72 -0
- package/lib/solve/magic.d.ts +32 -0
- package/lib/solve/magic.js +216 -0
- package/lib/solve/matchsticks.d.ts +37 -0
- package/lib/solve/matchsticks.js +214 -0
- package/lib/solve/order.d.ts +94 -0
- package/lib/solve/order.js +419 -0
- package/lib/solve/overlay.d.ts +22 -0
- package/lib/solve/overlay.js +56 -0
- package/lib/solve/parity.d.ts +22 -0
- package/lib/solve/parity.js +27 -0
- package/lib/solve/pattern.d.ts +62 -0
- package/lib/solve/pattern.js +533 -0
- package/lib/solve/pieces.d.ts +57 -0
- package/lib/solve/pieces.js +309 -0
- package/lib/solve/pigeonhole.d.ts +38 -0
- package/lib/solve/pigeonhole.js +95 -0
- package/lib/solve/proof.d.ts +115 -0
- package/lib/solve/proof.js +105 -0
- package/lib/solve/pyramid.d.ts +28 -0
- package/lib/solve/pyramid.js +161 -0
- package/lib/solve/question.d.ts +25 -0
- package/lib/solve/question.js +75 -0
- package/lib/solve/shapes.d.ts +30 -0
- package/lib/solve/shapes.js +182 -0
- package/lib/solve/target.d.ts +40 -0
- package/lib/solve/target.js +190 -0
- package/lib/style.d.ts +1 -1
- package/lib/style.js +1 -1
- package/lib/words.d.ts +15 -0
- package/lib/words.js +39 -0
- package/package.json +1 -1
package/lib/kinds/layers.js
CHANGED
|
@@ -3,6 +3,7 @@ import { textWidth } from "../pen.js";
|
|
|
3
3
|
import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
4
4
|
import { colorNames, colors, ink, isColor, outline, textOn } from "../style.js";
|
|
5
5
|
import { poly } from "../svg.js";
|
|
6
|
+
import { article } from "../words.js";
|
|
6
7
|
/**
|
|
7
8
|
* Layers: two to eight flat sheets of paper — rectangles, circles, triangles,
|
|
8
9
|
* diamonds, hexagons — put down on a table one after another, each opaque and
|
|
@@ -113,7 +114,8 @@ function boxOf(sheets) {
|
|
|
113
114
|
y1: Math.max(...sheets.map((s) => s.at[1] + s.size[1])),
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
+
/** sample looks at the picture every 2 pixels: which sheet is seen there, and which lie there. */
|
|
118
|
+
function sample(sheets) {
|
|
117
119
|
const box = boxOf(sheets);
|
|
118
120
|
const cols = (box.x1 - box.x0) * fine;
|
|
119
121
|
const rows = (box.y1 - box.y0) * fine;
|
|
@@ -131,6 +133,26 @@ function look(sheets) {
|
|
|
131
133
|
under[r * cols + c] = under[r * cols + c] | (1 << i);
|
|
132
134
|
});
|
|
133
135
|
}
|
|
136
|
+
return { cols, rows, top, under };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* overlaps tells, for every two sheets of a checked scene, whether they overlap: whether some
|
|
140
|
+
* sample of the picture, as the kind looks at it, lies in both. The check makes the picture show
|
|
141
|
+
* which of two that overlap lies on the other.
|
|
142
|
+
*/
|
|
143
|
+
export function overlaps(sheets) {
|
|
144
|
+
const { under } = sample(sheets);
|
|
145
|
+
const out = sheets.map(() => sheets.map(() => false));
|
|
146
|
+
for (const here of new Set(under))
|
|
147
|
+
for (let i = 0; i < sheets.length; i++)
|
|
148
|
+
for (let j = 0; j < sheets.length; j++)
|
|
149
|
+
if (i !== j && (here & (1 << i)) !== 0 && (here & (1 << j)) !== 0)
|
|
150
|
+
out[i][j] = true;
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
function look(sheets) {
|
|
154
|
+
const box = boxOf(sheets);
|
|
155
|
+
const { cols, rows, top, under } = sample(sheets);
|
|
134
156
|
const k = sheets.length;
|
|
135
157
|
const spots = sheets.map((_, i) => {
|
|
136
158
|
const dist = distances(cols, rows, (j) => top[j] === i);
|
|
@@ -411,9 +433,6 @@ export const layers = {
|
|
|
411
433
|
return out.join(" ");
|
|
412
434
|
},
|
|
413
435
|
};
|
|
414
|
-
function article(words) {
|
|
415
|
-
return `${/^[aeiou]/.test(words) ? "an" : "a"} ${words}`;
|
|
416
|
-
}
|
|
417
436
|
function cap(words) {
|
|
418
437
|
return `${words[0].toUpperCase()}${words.slice(1)}`;
|
|
419
438
|
}
|
package/lib/kinds/line.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ import { type Thing } from "../things.ts";
|
|
|
8
8
|
* picture draws exactly as many posts, things, cuts, ticks, steps or holes as
|
|
9
9
|
* the scene counts, each in a place of its own; labels go on the points, on
|
|
10
10
|
* the gaps between them and on the whole length, and "?" marks the asked one.
|
|
11
|
+
* A fence, a row or a strip may go on unseen in its middle: dots stand in one
|
|
12
|
+
* gap, so that a task asks how many posts or gaps there are and the picture
|
|
13
|
+
* does not count them for the learner.
|
|
11
14
|
*/
|
|
12
15
|
export declare const lineStyles: readonly ["fence", "row", "log", "numbers", "stairs", "belt"];
|
|
13
16
|
export type LineStyle = (typeof lineStyles)[number];
|
|
@@ -34,5 +37,6 @@ export type LineScene = {
|
|
|
34
37
|
jumps?: Jump[];
|
|
35
38
|
marks?: Mark[];
|
|
36
39
|
color?: ColorName;
|
|
40
|
+
unseen?: number;
|
|
37
41
|
};
|
|
38
42
|
export declare const line: Kind;
|
package/lib/kinds/line.js
CHANGED
|
@@ -4,6 +4,7 @@ import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
|
4
4
|
import { colors, faint, ink, isColor, outline, textOn } from "../style.js";
|
|
5
5
|
import { n, poly } from "../svg.js";
|
|
6
6
|
import { checkThing, drawThing, wordOf } from "../things.js";
|
|
7
|
+
import { article, capital } from "../words.js";
|
|
7
8
|
/**
|
|
8
9
|
* A line: points along a line and the gaps between them, in one of six
|
|
9
10
|
* styles — a fence of posts joined by rails, things in a row, a log with cut
|
|
@@ -11,16 +12,19 @@ import { checkThing, drawThing, wordOf } from "../things.js";
|
|
|
11
12
|
* picture draws exactly as many posts, things, cuts, ticks, steps or holes as
|
|
12
13
|
* the scene counts, each in a place of its own; labels go on the points, on
|
|
13
14
|
* the gaps between them and on the whole length, and "?" marks the asked one.
|
|
15
|
+
* A fence, a row or a strip may go on unseen in its middle: dots stand in one
|
|
16
|
+
* gap, so that a task asks how many posts or gaps there are and the picture
|
|
17
|
+
* does not count them for the learner.
|
|
14
18
|
*/
|
|
15
19
|
export const lineStyles = ["fence", "row", "log", "numbers", "stairs", "belt"];
|
|
16
20
|
/** The members each style takes besides kind and style. */
|
|
17
21
|
const styleMembers = {
|
|
18
|
-
fence: ["count", "labels", "gaps", "lengths", "total", "color"],
|
|
19
|
-
row: ["things", "labels", "gaps", "lengths", "total", "jumps"],
|
|
22
|
+
fence: ["count", "labels", "gaps", "lengths", "total", "color", "unseen"],
|
|
23
|
+
row: ["things", "labels", "gaps", "lengths", "total", "jumps", "unseen"],
|
|
20
24
|
log: ["count", "gaps", "lengths", "total", "color"],
|
|
21
25
|
numbers: ["count", "start", "by", "labels", "jumps", "marks"],
|
|
22
26
|
stairs: ["count", "labels", "marks", "color"],
|
|
23
|
-
belt: ["count", "labels", "gaps", "lengths", "total", "color"],
|
|
27
|
+
belt: ["count", "labels", "gaps", "lengths", "total", "color", "unseen"],
|
|
24
28
|
};
|
|
25
29
|
/** What count counts in each style, and its limits. */
|
|
26
30
|
const countOf = {
|
|
@@ -83,8 +87,18 @@ function spread(style, lengths, gaps = []) {
|
|
|
83
87
|
}
|
|
84
88
|
return xs;
|
|
85
89
|
}
|
|
90
|
+
/** The unseen middle of a line is this much wider than its other gaps: room for its dots. */
|
|
91
|
+
const unseenLength = 2.2;
|
|
86
92
|
function lengthsOf(scene) {
|
|
87
|
-
return scene.lengths ??
|
|
93
|
+
return (scene.lengths ??
|
|
94
|
+
Array.from({ length: gapCount(scene) }, (_, i) => (i + 1 === scene.unseen ? unseenLength : 1)));
|
|
95
|
+
}
|
|
96
|
+
/** dots draws the three dots of a line's unseen middle, centred at x, y. */
|
|
97
|
+
function dots(pen, x, y) {
|
|
98
|
+
pen.add('<g class="unseen">');
|
|
99
|
+
for (const dx of [-12, 0, 12])
|
|
100
|
+
pen.el("circle", { cx: x + dx, cy: y, r: 3.6, fill: ink });
|
|
101
|
+
pen.add("</g>");
|
|
88
102
|
}
|
|
89
103
|
/** valueAt is the number a tick of a number line stands for. */
|
|
90
104
|
function valueAt(scene, i) {
|
|
@@ -218,19 +232,28 @@ function drawFence(scene, pen) {
|
|
|
218
232
|
"stroke-linecap": "round",
|
|
219
233
|
});
|
|
220
234
|
for (let i = 0; i + 1 < xs.length; i++) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
235
|
+
// The unseen middle shows only the ends of its rails, as if they went on, and dots.
|
|
236
|
+
const pieces = i + 1 === scene.unseen
|
|
237
|
+
? [
|
|
238
|
+
[xs[i], xs[i] + 16],
|
|
239
|
+
[xs[i + 1] - 16, xs[i + 1]],
|
|
240
|
+
]
|
|
241
|
+
: [[xs[i], xs[i + 1]]];
|
|
242
|
+
for (const y of [top + 22, top + 52])
|
|
243
|
+
for (const [a, b] of pieces)
|
|
244
|
+
pen.el("rect", {
|
|
245
|
+
x: a,
|
|
246
|
+
y,
|
|
247
|
+
width: b - a,
|
|
248
|
+
height: 10,
|
|
249
|
+
fill: c.fill,
|
|
250
|
+
stroke: ink,
|
|
251
|
+
"stroke-width": outline,
|
|
252
|
+
class: pieces.length === 1 ? "rail" : "rail-end",
|
|
253
|
+
});
|
|
233
254
|
}
|
|
255
|
+
if (scene.unseen)
|
|
256
|
+
dots(pen, (xs[scene.unseen - 1] + xs[scene.unseen]) / 2, top + 42);
|
|
234
257
|
xs.forEach((x, i) => {
|
|
235
258
|
pen.el("path", {
|
|
236
259
|
d: poly([
|
|
@@ -272,6 +295,8 @@ function drawRow(scene, pen) {
|
|
|
272
295
|
scene.things.forEach((t, i) => {
|
|
273
296
|
drawThing(pen, t, xs[i], cy, thingSize);
|
|
274
297
|
});
|
|
298
|
+
if (scene.unseen)
|
|
299
|
+
dots(pen, (xs[scene.unseen - 1] + xs[scene.unseen]) / 2, cy);
|
|
275
300
|
for (const j of jumps) {
|
|
276
301
|
const x1 = xs[j.from - 1];
|
|
277
302
|
const x2 = xs[j.to - 1];
|
|
@@ -384,6 +409,27 @@ function drawBelt(scene, pen) {
|
|
|
384
409
|
"stroke-width": 2,
|
|
385
410
|
"stroke-dasharray": "6 5",
|
|
386
411
|
});
|
|
412
|
+
if (scene.unseen) {
|
|
413
|
+
// The unseen middle is torn out of the strip: two jagged edges, and dots between them.
|
|
414
|
+
const l = xs[scene.unseen - 1] + 15;
|
|
415
|
+
const r = xs[scene.unseen] - 15;
|
|
416
|
+
const zig = (x, dir) => Array.from({ length: 7 }, (_, j) => ({
|
|
417
|
+
x: x + (j % 2 === 0 ? 0 : dir * 6),
|
|
418
|
+
y: top - 3 + (j * (h + 6)) / 6,
|
|
419
|
+
}));
|
|
420
|
+
const left = zig(l, 1);
|
|
421
|
+
const right = zig(r, -1).reverse();
|
|
422
|
+
pen.el("path", { d: poly([...left, ...right]), fill: "#ffffff", stroke: "none" });
|
|
423
|
+
for (const edge of [left, right])
|
|
424
|
+
pen.el("path", {
|
|
425
|
+
d: poly(edge, false),
|
|
426
|
+
fill: "none",
|
|
427
|
+
stroke: ink,
|
|
428
|
+
"stroke-width": outline,
|
|
429
|
+
"stroke-linejoin": "round",
|
|
430
|
+
});
|
|
431
|
+
dots(pen, (l + r) / 2, top + h / 2);
|
|
432
|
+
}
|
|
387
433
|
xs.forEach((x, i) => {
|
|
388
434
|
pen.el("circle", {
|
|
389
435
|
cx: x,
|
|
@@ -518,19 +564,44 @@ function ordinal(i) {
|
|
|
518
564
|
const tail = i % 100 >= 11 && i % 100 <= 13 ? "th" : (["th", "st", "nd", "rd"][i % 10] ?? "th");
|
|
519
565
|
return `${i}${tail}`;
|
|
520
566
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
567
|
+
const a = (thing) => article(wordOf(thing));
|
|
568
|
+
/** dotted puts "…" where a line's unseen middle stands, after its unseen-th point. */
|
|
569
|
+
function dotted(words, unseen, gaps = false) {
|
|
570
|
+
if (!unseen)
|
|
571
|
+
return words;
|
|
572
|
+
return gaps
|
|
573
|
+
? words.map((w, i) => (i + 1 === unseen ? "…" : w))
|
|
574
|
+
: [...words.slice(0, unseen), "…", ...words.slice(unseen)];
|
|
524
575
|
}
|
|
525
|
-
function sayGaps(gaps, what) {
|
|
576
|
+
function sayGaps(gaps, what, unseen) {
|
|
526
577
|
if (!gaps?.some((g) => g !== ""))
|
|
527
578
|
return "";
|
|
528
|
-
return ` The ${what}, from left to right: ${gaps.map((g) => (g === "" ? "not marked" : g)).join(", ")}.`;
|
|
579
|
+
return ` The ${what}, from left to right: ${dotted(gaps.map((g) => (g === "" ? "not marked" : g)), unseen, true).join(", ")}.`;
|
|
529
580
|
}
|
|
530
|
-
function sayLabels(labels, what) {
|
|
581
|
+
function sayLabels(labels, what, unseen) {
|
|
531
582
|
if (!labels?.some((l) => l !== ""))
|
|
532
583
|
return "";
|
|
533
|
-
return ` The ${what} are marked, from left to right: ${labels.map((l) => (l === "" ? "no mark" : l)).join(", ")}.`;
|
|
584
|
+
return ` The ${what} are marked, from left to right: ${dotted(labels.map((l) => (l === "" ? "no mark" : l)), unseen).join(", ")}.`;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* sayUnseen says that a line goes on unseen in its middle, and never how many points it holds:
|
|
588
|
+
* the count is what a task asks.
|
|
589
|
+
*/
|
|
590
|
+
function sayUnseen(s, line, what) {
|
|
591
|
+
if (!s.unseen)
|
|
592
|
+
return "";
|
|
593
|
+
return ` The ${line} goes on; its middle is not shown: dots stand between the ${what} at its left end and those at its right end.`;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* sayTotal says the label of the whole line, a length or a time alike: "The whole, from the first
|
|
597
|
+
* post to the last, is marked 6 m."
|
|
598
|
+
*/
|
|
599
|
+
function sayTotal(s, whole) {
|
|
600
|
+
if (!s.total)
|
|
601
|
+
return "";
|
|
602
|
+
return s.total === "?"
|
|
603
|
+
? ` ${capital(whole)} is marked ?: it is asked.`
|
|
604
|
+
: ` ${capital(whole)} is marked ${s.total}.`;
|
|
534
605
|
}
|
|
535
606
|
// --- the kind ----------------------------------------------------------------
|
|
536
607
|
export const line = {
|
|
@@ -549,6 +620,7 @@ export const line = {
|
|
|
549
620
|
"jumps",
|
|
550
621
|
"marks",
|
|
551
622
|
"color",
|
|
623
|
+
"unseen",
|
|
552
624
|
],
|
|
553
625
|
check(scene, problems) {
|
|
554
626
|
only(scene, this.members, "scene", problems);
|
|
@@ -603,6 +675,22 @@ export const line = {
|
|
|
603
675
|
spread(style, lengths, Array.isArray(scene.gaps) ? scene.gaps.map(String) : []) === undefined)
|
|
604
676
|
problems.push(`lengths: too uneven to draw; the shortest gap would be under ${room[style].least} px beside the others, so make them closer or fewer`);
|
|
605
677
|
}
|
|
678
|
+
if (scene.unseen !== undefined && takes.includes("unseen")) {
|
|
679
|
+
const before = problems.length;
|
|
680
|
+
const u = int(scene.unseen, "unseen", problems, 1, p - 1);
|
|
681
|
+
if (problems.length === before) {
|
|
682
|
+
if (scene.lengths !== undefined)
|
|
683
|
+
problems.push("lengths: a line whose middle is not shown has its gaps equal; leave lengths out");
|
|
684
|
+
else if (spread(style, lengthsOf({ ...typed, unseen: u })) === undefined)
|
|
685
|
+
problems.push(`unseen: no room for the unseen middle beside ${p - 1} gaps; draw fewer ${style === "row" ? "things" : countOf[style].word}`);
|
|
686
|
+
if (Array.isArray(scene.gaps) &&
|
|
687
|
+
scene.gaps[u - 1] !== undefined &&
|
|
688
|
+
scene.gaps[u - 1] !== "")
|
|
689
|
+
problems.push(`gaps[${u - 1}]: the unseen middle is not one gap, so it carries no measure; write "" there`);
|
|
690
|
+
if (scene.jumps !== undefined)
|
|
691
|
+
problems.push("jumps: a row whose middle is not shown takes no jumps");
|
|
692
|
+
}
|
|
693
|
+
}
|
|
606
694
|
if (style === "numbers") {
|
|
607
695
|
const start = scene.start === undefined ? 0 : int(scene.start, "start", problems, 0, 999);
|
|
608
696
|
const by = scene.by === undefined ? 1 : int(scene.by, "by", problems, 1, 100);
|
|
@@ -680,34 +768,31 @@ export const line = {
|
|
|
680
768
|
const s = scene;
|
|
681
769
|
const p = points(s);
|
|
682
770
|
const color = (fallback) => colors[s.color ?? fallback].word;
|
|
683
|
-
const total = s.total
|
|
684
|
-
? ` ${s.total === "?" ? "The whole length is asked: ?" : `The whole length: ${s.total}`}.`
|
|
685
|
-
: "";
|
|
686
771
|
switch (s.style) {
|
|
687
772
|
case "fence":
|
|
688
|
-
return
|
|
773
|
+
return `${capital(article(color("brown")))} fence of ${s.unseen ? "" : `${p} `}posts in a row, every two neighbouring posts joined by rails.${sayUnseen(s, "fence", "posts")}${sayLabels(s.labels, "posts", s.unseen)}${sayGaps(s.gaps, "gaps between neighbouring posts", s.unseen)}${sayTotal(s, "the whole, from the first post to the last,")}`;
|
|
689
774
|
case "row": {
|
|
690
775
|
const things = s.things.map((t, i) => `${a(t)}${s.labels?.[i] ? ` (${s.labels[i]})` : ""}`);
|
|
691
776
|
const jumps = (s.jumps ?? [])
|
|
692
777
|
.map((j) => ` An arrow goes from the ${ordinal(j.from)} to the ${ordinal(j.to)}${j.label ? `, marked ${j.label}` : ""}.`)
|
|
693
778
|
.join("");
|
|
694
|
-
return `${p} things in a row, from left to right: ${things.join(", ")}.${sayGaps(s.gaps, "
|
|
779
|
+
return `${s.unseen ? "Things" : `${p} things`} in a row, from left to right: ${dotted(things, s.unseen).join(", ")}.${sayUnseen(s, "row", "things")}${sayGaps(s.gaps, "gaps between neighbours", s.unseen)}${sayTotal(s, "the whole, from the first to the last,")}${jumps}`;
|
|
695
780
|
}
|
|
696
781
|
case "log":
|
|
697
|
-
return
|
|
782
|
+
return `${capital(article(color("brown")))} log with ${p} cut line${p === 1 ? "" : "s"} across it, which make ${p + 1} pieces.${sayGaps(s.gaps, "pieces")}${sayTotal(s, "the whole log")}`;
|
|
698
783
|
case "belt":
|
|
699
|
-
return
|
|
784
|
+
return `${capital(article(color("yellow")))} strip with ${s.unseen ? "" : `${p} `}holes in a row.${sayUnseen(s, "strip", "holes")}${sayLabels(s.labels, "holes", s.unseen)}${sayGaps(s.gaps, "gaps between neighbouring holes", s.unseen)}${sayTotal(s, "the whole, from the first hole to the last,")}`;
|
|
700
785
|
case "numbers": {
|
|
701
786
|
const by = s.by ?? 1;
|
|
702
787
|
const changed = (s.labels ?? [])
|
|
703
788
|
.map((l, i) => ({ l, i }))
|
|
704
789
|
.filter(({ l, i }) => l !== String(valueAt(s, i)));
|
|
705
790
|
const hidden = changed.length
|
|
706
|
-
? ` ${changed
|
|
791
|
+
? ` ${capital(changed
|
|
707
792
|
.map(({ l, i }) => l === ""
|
|
708
793
|
? `the number at the ${ordinal(i + 1)} tick is not written`
|
|
709
794
|
: `the ${ordinal(i + 1)} tick shows ${l} instead of its number`)
|
|
710
|
-
.join("; ")}.`
|
|
795
|
+
.join("; "))}.`
|
|
711
796
|
: "";
|
|
712
797
|
const shown = changed.length
|
|
713
798
|
? ` Written: ${Array.from({ length: p }, (_, i) => s.labels?.[i] ?? String(valueAt(s, i)))
|
|
@@ -23,4 +23,8 @@ export type MatchsticksScene = {
|
|
|
23
23
|
mark?: Mark;
|
|
24
24
|
})[];
|
|
25
25
|
};
|
|
26
|
+
/** shapes are the places of the matches of each symbol a text may hold, "-" for the minus. */
|
|
27
|
+
export declare const shapes: Readonly<Record<string, readonly string[]>>;
|
|
28
|
+
/** placesOf is every place a symbol may have a mark at: a digit's seven, a sign's own. */
|
|
29
|
+
export declare function placesOf(c: string): readonly string[];
|
|
26
30
|
export declare const matchsticks: Kind;
|
package/lib/kinds/matchsticks.js
CHANGED
|
@@ -2,6 +2,7 @@ import { margin } from "../kind.js";
|
|
|
2
2
|
import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
3
3
|
import { colors, ink, outline } from "../style.js";
|
|
4
4
|
import { byCodeUnit, n } from "../svg.js";
|
|
5
|
+
import { article } from "../words.js";
|
|
5
6
|
const members = ["kind", "text", "marks", "grid", "sticks"];
|
|
6
7
|
const grids = ["square", "triangle"];
|
|
7
8
|
/** The colours a match may take: each stands out from a plain match and from an empty place. */
|
|
@@ -37,7 +38,8 @@ const digitPlaces = [
|
|
|
37
38
|
"lower-right",
|
|
38
39
|
"bottom",
|
|
39
40
|
];
|
|
40
|
-
|
|
41
|
+
/** shapes are the places of the matches of each symbol a text may hold, "-" for the minus. */
|
|
42
|
+
export const shapes = {
|
|
41
43
|
"0": ["top", "upper-left", "upper-right", "lower-left", "lower-right", "bottom"],
|
|
42
44
|
"1": ["upper-right", "lower-right"],
|
|
43
45
|
"2": ["top", "upper-right", "middle", "lower-left", "bottom"],
|
|
@@ -53,7 +55,7 @@ const shapes = {
|
|
|
53
55
|
"=": ["upper", "lower"],
|
|
54
56
|
};
|
|
55
57
|
/** placesOf is every place a symbol may have a mark at: a digit's seven, a sign's own. */
|
|
56
|
-
function placesOf(c) {
|
|
58
|
+
export function placesOf(c) {
|
|
57
59
|
if (/[0-9]/.test(c))
|
|
58
60
|
return digitPlaces;
|
|
59
61
|
return c === "=" ? ["upper", "lower"] : ["middle", "upright"];
|
|
@@ -354,7 +356,7 @@ function describeGrid(s) {
|
|
|
354
356
|
}
|
|
355
357
|
const coloured = ordered.filter((t) => t.mark !== undefined && t.mark !== "ghost");
|
|
356
358
|
if (coloured.length > 0)
|
|
357
|
-
out.push(`Coloured matches: ${coloured.map((t) =>
|
|
359
|
+
out.push(`Coloured matches: ${coloured.map((t) => `${article(colors[t.mark].word)} one from ${say([t.at[0], t.at[1]])} to ${say([t.at[2], t.at[3]])}`).join("; ")}.`);
|
|
358
360
|
const ghosts = ordered.filter((t) => t.mark === "ghost");
|
|
359
361
|
if (ghosts.length > 0)
|
|
360
362
|
out.push(`Empty places drawn dashed, with no match in them: ${ghosts.map((t) => `from ${say([t.at[0], t.at[1]])} to ${say([t.at[2], t.at[3]])}`).join("; ")}.`);
|
package/lib/kinds/net.js
CHANGED
|
@@ -3,7 +3,8 @@ import { textWidth } from "../pen.js";
|
|
|
3
3
|
import { int, isObj, list, only, text } from "../read.js";
|
|
4
4
|
import { colorNames, colors, ink, isColor, outline, textOn } from "../style.js";
|
|
5
5
|
import { checkThing, drawThing, wordOf } from "../things.js";
|
|
6
|
-
import { article
|
|
6
|
+
import { article } from "../words.js";
|
|
7
|
+
import { box } from "./cubes.js";
|
|
7
8
|
import { pips } from "./die.js";
|
|
8
9
|
const biggest = 64;
|
|
9
10
|
const smallest = 34;
|
|
@@ -170,7 +171,7 @@ function drawFace(pen, f, x, y, s) {
|
|
|
170
171
|
function sayFace(f) {
|
|
171
172
|
const color = f.color ? colors[f.color].word : "white";
|
|
172
173
|
if (f.pips !== undefined)
|
|
173
|
-
return `${color} with ${f.pips}
|
|
174
|
+
return `${color} with ${f.pips} dot${f.pips === 1 ? "" : "s"}`;
|
|
174
175
|
if (f.text !== undefined)
|
|
175
176
|
return `${color} with "${f.text}"`;
|
|
176
177
|
if (f.thing !== undefined)
|
|
@@ -188,7 +189,7 @@ function sayNet(net) {
|
|
|
188
189
|
return `row ${r - top + 1}: column${cols.length === 1 ? "" : "s"} ${cols.join(", ")}`;
|
|
189
190
|
});
|
|
190
191
|
const faces = net.faces.map((f, i) => `${i + 1}) ${sayFace(f)}`);
|
|
191
|
-
return `6 squares in ${rows.length} rows (${rows.join("; ")}). The squares in reading order, left to right and row by row: ${faces.join("; ")}.${net.standard ? " The
|
|
192
|
+
return `6 squares in ${rows.length} rows (${rows.join("; ")}). The squares in reading order, left to right and row by row: ${faces.join("; ")}.${net.standard ? " The dots are those of a standard die: opposite faces add up to 7." : ""}`;
|
|
192
193
|
}
|
|
193
194
|
export const net = {
|
|
194
195
|
kind: "net",
|
package/lib/kinds/overlay.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Kind } from "../kind.ts";
|
|
2
2
|
import { type ColorName } from "../style.ts";
|
|
3
|
-
import { type Part } from "./fold-parts.ts";
|
|
3
|
+
import { type Atom, type Part } from "./fold-parts.ts";
|
|
4
4
|
/**
|
|
5
5
|
* Overlay: two to four transparent cards of the same grid of squares, side by
|
|
6
6
|
* side, each with marks in its squares — a square or a part of one filled
|
|
@@ -47,4 +47,26 @@ export type OverlayScene = {
|
|
|
47
47
|
cards: Card[];
|
|
48
48
|
show?: Show;
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Laid is what a card holds, as laid down: the colour of each atom, by its key, and the shape in
|
|
52
|
+
* each square, by "row,column" from 0; mark is the index of the mark on its card that put it there.
|
|
53
|
+
*/
|
|
54
|
+
export type Laid = {
|
|
55
|
+
fills: Map<number, {
|
|
56
|
+
color: ColorName;
|
|
57
|
+
atom: Atom;
|
|
58
|
+
mark: number;
|
|
59
|
+
}>;
|
|
60
|
+
shapes: Map<string, {
|
|
61
|
+
shape: MarkShape;
|
|
62
|
+
color: ColorName;
|
|
63
|
+
turn: number;
|
|
64
|
+
mark: number;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* together lays every card of a checked scene on the ones before it, each flipped and turned as
|
|
69
|
+
* it says unless moved is false, and gives what is seen, as the kind draws and words the view.
|
|
70
|
+
*/
|
|
71
|
+
export declare function together(scene: OverlayScene, moved?: boolean): Laid;
|
|
50
72
|
export declare const overlay: Kind;
|
package/lib/kinds/overlay.js
CHANGED
|
@@ -3,7 +3,8 @@ import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
|
3
3
|
import { colorNames, colors, faint, ink, isColor, outline, soft, } from "../style.js";
|
|
4
4
|
import { n, poly } from "../svg.js";
|
|
5
5
|
import { drawThing } from "../things.js";
|
|
6
|
-
import {
|
|
6
|
+
import { article } from "../words.js";
|
|
7
|
+
import { andThen, atomsOf, cellWords, identity, key, loopsOf, mapAtom, parts, turnMat, turnOf, ways, } from "./fold-parts.js";
|
|
7
8
|
/**
|
|
8
9
|
* Overlay: two to four transparent cards of the same grid of squares, side by
|
|
9
10
|
* side, each with marks in its squares — a square or a part of one filled
|
|
@@ -94,8 +95,11 @@ function lay(card, m) {
|
|
|
94
95
|
});
|
|
95
96
|
return { fills, shapes };
|
|
96
97
|
}
|
|
97
|
-
/**
|
|
98
|
-
|
|
98
|
+
/**
|
|
99
|
+
* together lays every card of a checked scene on the ones before it, each flipped and turned as
|
|
100
|
+
* it says unless moved is false, and gives what is seen, as the kind draws and words the view.
|
|
101
|
+
*/
|
|
102
|
+
export function together(scene, moved = true) {
|
|
99
103
|
const out = { fills: new Map(), shapes: new Map() };
|
|
100
104
|
for (const card of scene.cards) {
|
|
101
105
|
const laid = lay(card, moved ? moveOf(card, scene.rows, scene.cols) : identity);
|
package/lib/kinds/pieces.js
CHANGED
|
@@ -2,6 +2,7 @@ import { margin } from "../kind.js";
|
|
|
2
2
|
import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
3
3
|
import { colorNames, colors, faint, ground, ink, isColor, outline, } from "../style.js";
|
|
4
4
|
import { poly } from "../svg.js";
|
|
5
|
+
import { article } from "../words.js";
|
|
5
6
|
/**
|
|
6
7
|
* Pieces: polyomino pieces cut from squared paper, drawn apart in a row, each
|
|
7
8
|
* a list of its squares, a colour and an optional label under it; and
|
|
@@ -287,7 +288,7 @@ export function sayShape(squares) {
|
|
|
287
288
|
return `${whole} squares in a row`;
|
|
288
289
|
if (cols === 1)
|
|
289
290
|
return `${whole} squares in a column`;
|
|
290
|
-
return
|
|
291
|
+
return `${article(String(rows))} by ${cols} rectangle of ${whole} squares (${rows} rows of ${cols})`;
|
|
291
292
|
}
|
|
292
293
|
const byRow = [];
|
|
293
294
|
for (let r = 0; r < rows; r++) {
|
|
@@ -413,7 +414,7 @@ export const pieces = {
|
|
|
413
414
|
: !b.cells && cols === 1
|
|
414
415
|
? `a strip of ${rows} squares in a column`
|
|
415
416
|
: sayShape(squares);
|
|
416
|
-
out.push(`Below them,
|
|
417
|
+
out.push(`Below them, ${article(`${b.color ? `${colors[b.color].word} ` : ""}board`)} to cover${b.label ? `, labelled "${b.label}"` : ""}: ${shape}.`);
|
|
417
418
|
}
|
|
418
419
|
return out.join(" ");
|
|
419
420
|
},
|
|
@@ -95,8 +95,6 @@ export declare function widest(angles: readonly number[], otherwise: number): nu
|
|
|
95
95
|
export declare function say(value: number): string;
|
|
96
96
|
/** many says a count with its noun: "1 side", "3 sides". */
|
|
97
97
|
export declare function many(k: number, one: string, more?: string): string;
|
|
98
|
-
/** listOf joins words as English does: "a", "a and b", "a, b and c". */
|
|
99
|
-
export declare function listOf(items: readonly string[]): string;
|
|
100
98
|
/** runs says a sequence of words by runs: "2 gray, then 1 white, then 3 gray". */
|
|
101
99
|
export declare function runs(items: readonly string[]): string;
|
|
102
100
|
/** ordinal says 1 as "first", up to "eighth", then "9th". */
|
package/lib/kinds/plane-parts.js
CHANGED
|
@@ -343,12 +343,6 @@ export function say(value) {
|
|
|
343
343
|
export function many(k, one, more = `${one}s`) {
|
|
344
344
|
return `${k} ${k === 1 ? one : more}`;
|
|
345
345
|
}
|
|
346
|
-
/** listOf joins words as English does: "a", "a and b", "a, b and c". */
|
|
347
|
-
export function listOf(items) {
|
|
348
|
-
if (items.length <= 1)
|
|
349
|
-
return items[0] ?? "";
|
|
350
|
-
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
351
|
-
}
|
|
352
346
|
/** runs says a sequence of words by runs: "2 gray, then 1 white, then 3 gray". */
|
|
353
347
|
export function runs(items) {
|
|
354
348
|
const out = [];
|
package/lib/kinds/plane.js
CHANGED
|
@@ -3,7 +3,8 @@ import { textWidth } from "../pen.js";
|
|
|
3
3
|
import { int, isObj, list, only, text } from "../read.js";
|
|
4
4
|
import { colorNames, colors, ink, isColor, outline, textOn } from "../style.js";
|
|
5
5
|
import { n, poly } from "../svg.js";
|
|
6
|
-
import {
|
|
6
|
+
import { article, listOf } from "../words.js";
|
|
7
|
+
import { area, around, boxAt, boxToSegment, capital, centroid, crossing, distance, label as drawLabel, edgesOf, gap, inside, labelSize, lerp, meet, overlap, pointOf, say, } from "./plane-parts.js";
|
|
7
8
|
const span = 40;
|
|
8
9
|
const sideSize = 18;
|
|
9
10
|
const angleSize = 16;
|
|
@@ -325,7 +326,6 @@ function kindOf(sh, p) {
|
|
|
325
326
|
}
|
|
326
327
|
const counts = ["no", "one", "two", "three"];
|
|
327
328
|
const countWord = (k) => counts[k] ?? String(k);
|
|
328
|
-
const article = (word) => (/^[aeiou]/.test(word) ? "an" : "a");
|
|
329
329
|
const placeWords = (at) => (at === "middle" ? "in the middle" : `at the ${at}`);
|
|
330
330
|
export const plane = {
|
|
331
331
|
kind: "plane",
|
|
@@ -642,8 +642,8 @@ export const plane = {
|
|
|
642
642
|
const color = colors[sh.color ?? "white"].word;
|
|
643
643
|
const what = kindOf(sh, p);
|
|
644
644
|
const head = several
|
|
645
|
-
? `Shape ${i + 1}, ${placeWords(where(centroid(p), whole))} of the figure, is ${article(color)} ${
|
|
646
|
-
: `${capital(article(color))} ${
|
|
645
|
+
? `Shape ${i + 1}, ${placeWords(where(centroid(p), whole))} of the figure, is ${article(color)} ${what}`
|
|
646
|
+
: `${capital(article(color))} ${what}`;
|
|
647
647
|
const square = p.every((a, k) => a.x === p[(k + 1) % K].x || a.y === p[(k + 1) % K].y);
|
|
648
648
|
let shape = head;
|
|
649
649
|
if (square && K > 4) {
|
|
@@ -678,7 +678,7 @@ export const plane = {
|
|
|
678
678
|
if (marked.length === 0)
|
|
679
679
|
out.push("Its sides carry no marks.");
|
|
680
680
|
else
|
|
681
|
-
out.push(`${capital(marked.map((x) => `its ${at(x.k)} side is ${x.words
|
|
681
|
+
out.push(`${capital(marked.map((x) => `its ${at(x.k)} side is ${listOf(x.words)}`).join("; "))}${marked.length < 4 ? "; the other sides carry no marks" : ""}.`);
|
|
682
682
|
}
|
|
683
683
|
else {
|
|
684
684
|
const marked = p.some((_, k) => sideWords(k).length > 0);
|
|
@@ -688,7 +688,7 @@ export const plane = {
|
|
|
688
688
|
const way = `${to} going ${heading(a, p[(k + 1) % K])}`;
|
|
689
689
|
if (!marked)
|
|
690
690
|
return way;
|
|
691
|
-
return `${way}, ${words.length ? words
|
|
691
|
+
return `${way}, ${words.length ? listOf(words) : "unlabelled"}`;
|
|
692
692
|
});
|
|
693
693
|
out.push(`Going round from ${name(0)} at the ${where(p[0], box)}: ${steps.join("; ")}.${marked ? "" : " Its sides carry no marks."}`);
|
|
694
694
|
}
|
package/lib/kinds/ropes.js
CHANGED
|
@@ -4,6 +4,7 @@ import { isObj, list, only, text } from "../read.js";
|
|
|
4
4
|
import { colorNames, colors, ground, ink, isColor, outline } from "../style.js";
|
|
5
5
|
import { n } from "../svg.js";
|
|
6
6
|
import { checkThing, drawThing, wordOf } from "../things.js";
|
|
7
|
+
import { article } from "../words.js";
|
|
7
8
|
const members = ["kind", "ropes", "pegs"];
|
|
8
9
|
/** One step of the grid, in pixels. */
|
|
9
10
|
const unit = 44;
|
|
@@ -20,9 +21,6 @@ const defaults = ["red", "blue", "green", "orange", "purple", "yellow"];
|
|
|
20
21
|
const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
21
22
|
const keyOf = (x, y) => `${x},${y}`;
|
|
22
23
|
const sayPoint = (x, y) => `(${x}, ${y})`;
|
|
23
|
-
function article(words) {
|
|
24
|
-
return /^[aeiou]/.test(words) ? `an ${words}` : `a ${words}`;
|
|
25
|
-
}
|
|
26
24
|
/** bezier is the smooth line through the points, a cubic piece between each two. */
|
|
27
25
|
function pieces(points, closed) {
|
|
28
26
|
const k = points.length;
|
package/lib/kinds/shapes.js
CHANGED
|
@@ -3,6 +3,7 @@ import { textWidth } from "../pen.js";
|
|
|
3
3
|
import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
4
4
|
import { colors, faint, isColor, soft } from "../style.js";
|
|
5
5
|
import { drawThing, shapeNames } from "../things.js";
|
|
6
|
+
import { article } from "../words.js";
|
|
6
7
|
/**
|
|
7
8
|
* Shapes: geometric shapes of the palette in rows — side by side, standing
|
|
8
9
|
* one on another in a tower, lying one over another in a pile with a clear
|
|
@@ -104,12 +105,9 @@ function sayPiece(p) {
|
|
|
104
105
|
const label = "label" in p && p.label ? ` marked ${p.label}` : "";
|
|
105
106
|
return `${size}${colors[p.color].word} ${p.shape}${label}`;
|
|
106
107
|
}
|
|
107
|
-
function a(words) {
|
|
108
|
-
return `${/^[aeiou]/.test(words) ? "an" : "a"} ${words}`;
|
|
109
|
-
}
|
|
110
108
|
function sayItem(item) {
|
|
111
109
|
if (isPiece(item))
|
|
112
|
-
return
|
|
110
|
+
return article(sayPiece(item));
|
|
113
111
|
if ("op" in item)
|
|
114
112
|
return opWords[item.op];
|
|
115
113
|
if ("number" in item)
|
|
@@ -117,8 +115,8 @@ function sayItem(item) {
|
|
|
117
115
|
if ("ask" in item)
|
|
118
116
|
return "a question mark";
|
|
119
117
|
if ("tower" in item)
|
|
120
|
-
return `a tower of ${item.tower.length} shapes standing one on another, from the bottom up: ${item.tower.map((p) =>
|
|
121
|
-
return `a pile of ${item.pile.length} shapes lying one over another, from the bottom one to the top one: ${item.pile.map((p) =>
|
|
118
|
+
return `a tower of ${item.tower.length} shapes standing one on another, from the bottom up: ${item.tower.map((p) => article(sayPiece(p))).join(", ")}`;
|
|
119
|
+
return `a pile of ${item.pile.length} shapes lying one over another, from the bottom one to the top one: ${item.pile.map((p) => article(sayPiece(p))).join(", ")}`;
|
|
122
120
|
}
|
|
123
121
|
function worth(values, p) {
|
|
124
122
|
return values.find((v) => v.shape === p.shape && v.color === p.color)?.value;
|
|
@@ -460,7 +458,7 @@ export const shapes = {
|
|
|
460
458
|
const cols = t.cells[0].length;
|
|
461
459
|
const lines = t.cells.map((row, r) => {
|
|
462
460
|
const total = t.right ? `; the total of the row is ${t.right[r]}` : "";
|
|
463
|
-
return `Row ${r + 1}: ${row.map((p) =>
|
|
461
|
+
return `Row ${r + 1}: ${row.map((p) => article(sayPiece(p))).join(", ")}${total}.`;
|
|
464
462
|
});
|
|
465
463
|
const below = t.below
|
|
466
464
|
? ` The totals of the columns, from left to right: ${t.below.join(", ")}.`
|
package/lib/kinds/solids.js
CHANGED
|
@@ -3,7 +3,8 @@ import { textWidth } from "../pen.js";
|
|
|
3
3
|
import { int, isObj, list, oneOf, only, text } from "../read.js";
|
|
4
4
|
import { colorNames, colors, faint, ink, isColor, outline } from "../style.js";
|
|
5
5
|
import { n, poly } from "../svg.js";
|
|
6
|
-
import { article
|
|
6
|
+
import { article } from "../words.js";
|
|
7
|
+
import { mix, tones } from "./cubes.js";
|
|
7
8
|
/**
|
|
8
9
|
* Solids: one to five solids on a table — cubes, cuboids, cylinders, cones,
|
|
9
10
|
* pyramids, prisms and spheres — in oblique projection: the front true to
|
|
@@ -863,7 +864,7 @@ function sayPanel(pl, shadows) {
|
|
|
863
864
|
const content = v.shape
|
|
864
865
|
? shadows
|
|
865
866
|
? `a shadow shaped like ${article(shapeOf(v.shape).words)}`
|
|
866
|
-
: article(
|
|
867
|
+
: article(`${colors.gray.word} ${shapeOf(v.shape).words}`)
|
|
867
868
|
: shadows
|
|
868
869
|
? `a shadow shaped like ${sayView(pl.pieces, v.from, false)}`
|
|
869
870
|
: sayView(pl.pieces, v.from, true);
|