@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { margin } from "../kind.js";
|
|
2
|
+
import { isObj, list, only } from "../read.js";
|
|
3
|
+
import { check, describe, drawScene } from "../render.js";
|
|
4
|
+
import { checkThing, drawThing, wordOf } from "../things.js";
|
|
5
|
+
const cellW = 150;
|
|
6
|
+
const cellH = 120;
|
|
7
|
+
const letters = "ABCDEF";
|
|
8
|
+
function isScene(option) {
|
|
9
|
+
return isObj(option) && "kind" in option;
|
|
10
|
+
}
|
|
11
|
+
export const choices = {
|
|
12
|
+
kind: "choices",
|
|
13
|
+
members: ["kind", "options"],
|
|
14
|
+
check(scene, problems) {
|
|
15
|
+
only(scene, this.members, "scene", problems);
|
|
16
|
+
list(scene.options, "options", problems, 2, 6).forEach((option, i) => {
|
|
17
|
+
if (isScene(option)) {
|
|
18
|
+
if (option.kind === "choices")
|
|
19
|
+
problems.push(`options[${i}]: a choice cannot hold choices`);
|
|
20
|
+
else
|
|
21
|
+
for (const p of check(option))
|
|
22
|
+
problems.push(`options[${i}].${p}`);
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
checkThing(option, `options[${i}]`, problems);
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
draw(scene, pen) {
|
|
29
|
+
const options = scene.options;
|
|
30
|
+
let x = margin;
|
|
31
|
+
const top = margin + 30;
|
|
32
|
+
options.forEach((option, i) => {
|
|
33
|
+
const cx = x + cellW / 2;
|
|
34
|
+
pen.text(cx, margin + 12, `(${letters[i]})`, { size: 18 });
|
|
35
|
+
if (isScene(option)) {
|
|
36
|
+
const sub = pen.sub();
|
|
37
|
+
const drawn = drawScene(option, sub);
|
|
38
|
+
const scale = Math.min(1, cellW / drawn.width, cellH / drawn.height);
|
|
39
|
+
pen.place(sub, cx - (drawn.width * scale) / 2, top + (cellH - drawn.height * scale) / 2, scale);
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
drawThing(pen, option, cx, top + cellH / 2, 76);
|
|
43
|
+
x += cellW + 10;
|
|
44
|
+
});
|
|
45
|
+
return { width: x - 10 + margin, height: top + cellH + margin };
|
|
46
|
+
},
|
|
47
|
+
describe(scene) {
|
|
48
|
+
const options = scene.options;
|
|
49
|
+
return options
|
|
50
|
+
.map((option, i) => `(${letters[i]}) ${isScene(option) ? describe(option) : wordOf(option)}`)
|
|
51
|
+
.join(" ");
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Kind } from "../kind.ts";
|
|
2
|
+
import { type ColorName } from "../style.ts";
|
|
3
|
+
/**
|
|
4
|
+
* A clock: one to six analog clock faces, up to four in a row, each showing a time with
|
|
5
|
+
* an hour hand and a minute hand, or a "?" where the time is asked. The
|
|
6
|
+
* minute hand turns 6 degrees a minute and the hour hand 30 degrees an hour
|
|
7
|
+
* and half a degree a minute, so the hour hand stands between the hours as
|
|
8
|
+
* on a real clock. A clock may show its time in digits below, and a label.
|
|
9
|
+
*/
|
|
10
|
+
export declare const faces: readonly ["numbers", "quarters", "ticks"];
|
|
11
|
+
export type Face = (typeof faces)[number];
|
|
12
|
+
export type Clock = {
|
|
13
|
+
time?: string;
|
|
14
|
+
ask?: boolean;
|
|
15
|
+
digital?: boolean;
|
|
16
|
+
label?: string;
|
|
17
|
+
color?: ColorName;
|
|
18
|
+
};
|
|
19
|
+
export type ClockScene = {
|
|
20
|
+
kind: "clock";
|
|
21
|
+
clocks: Clock[];
|
|
22
|
+
face?: Face;
|
|
23
|
+
};
|
|
24
|
+
/** parse reads "H:MM", H from 0 to 23 and MM from 00 to 59. */
|
|
25
|
+
export declare function parse(time: string): {
|
|
26
|
+
h: number;
|
|
27
|
+
m: number;
|
|
28
|
+
} | undefined;
|
|
29
|
+
/** angles are the turns of the hands from 12, clockwise, in degrees. */
|
|
30
|
+
export declare function angles(time: string): {
|
|
31
|
+
hour: number;
|
|
32
|
+
minute: number;
|
|
33
|
+
};
|
|
34
|
+
/** handsOf says where the hands of a time point, as a learner reads them. */
|
|
35
|
+
export declare function handsOf(time: string): string;
|
|
36
|
+
export declare const clock: Kind;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { margin } from "../kind.js";
|
|
2
|
+
import { isObj, list, oneOf, only, text } from "../read.js";
|
|
3
|
+
import { colors, font, ink, isColor, outline } from "../style.js";
|
|
4
|
+
import { esc, n } from "../svg.js";
|
|
5
|
+
/**
|
|
6
|
+
* A clock: one to six analog clock faces, up to four in a row, each showing a time with
|
|
7
|
+
* an hour hand and a minute hand, or a "?" where the time is asked. The
|
|
8
|
+
* minute hand turns 6 degrees a minute and the hour hand 30 degrees an hour
|
|
9
|
+
* and half a degree a minute, so the hour hand stands between the hours as
|
|
10
|
+
* on a real clock. A clock may show its time in digits below, and a label.
|
|
11
|
+
*/
|
|
12
|
+
export const faces = ["numbers", "quarters", "ticks"];
|
|
13
|
+
const most = 6;
|
|
14
|
+
const perRow = 4;
|
|
15
|
+
const gap = 22;
|
|
16
|
+
/** parse reads "H:MM", H from 0 to 23 and MM from 00 to 59. */
|
|
17
|
+
export function parse(time) {
|
|
18
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(time);
|
|
19
|
+
if (!match)
|
|
20
|
+
return undefined;
|
|
21
|
+
const h = Number(match[1]);
|
|
22
|
+
const m = Number(match[2]);
|
|
23
|
+
return h <= 23 && m <= 59 ? { h, m } : undefined;
|
|
24
|
+
}
|
|
25
|
+
/** angles are the turns of the hands from 12, clockwise, in degrees. */
|
|
26
|
+
export function angles(time) {
|
|
27
|
+
const { h, m } = parse(time);
|
|
28
|
+
return { hour: (h % 12) * 30 + m * 0.5, minute: m * 6 };
|
|
29
|
+
}
|
|
30
|
+
/** across is how many clocks stand in a row: up to four, the rows as even as can be. */
|
|
31
|
+
function across(k) {
|
|
32
|
+
return Math.ceil(k / Math.ceil(k / perRow));
|
|
33
|
+
}
|
|
34
|
+
function radiusOf(k) {
|
|
35
|
+
const a = across(k);
|
|
36
|
+
return Math.min(84, Math.floor((616 - (a - 1) * gap) / a / 2) - 2);
|
|
37
|
+
}
|
|
38
|
+
function hand(pen, cx, cy, length, width, turn, name) {
|
|
39
|
+
const w = width / 2;
|
|
40
|
+
const tail = length * 0.16;
|
|
41
|
+
pen.el("path", {
|
|
42
|
+
d: `M${n(cx - w)} ${n(cy + tail)}L${n(cx - w * 0.7)} ${n(cy - length + w)}Q${n(cx)} ${n(cy - length - w * 0.6)} ${n(cx + w * 0.7)} ${n(cy - length + w)}L${n(cx + w)} ${n(cy + tail)}Z`,
|
|
43
|
+
fill: ink,
|
|
44
|
+
stroke: ink,
|
|
45
|
+
"stroke-width": 1.5,
|
|
46
|
+
"stroke-linejoin": "round",
|
|
47
|
+
transform: `rotate(${n(turn)} ${n(cx)} ${n(cy)})`,
|
|
48
|
+
class: name,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function drawClock(pen, clock, face, cx, cy, r) {
|
|
52
|
+
const c = colors[clock.color ?? "blue"];
|
|
53
|
+
const rim = Math.max(6, r * 0.09);
|
|
54
|
+
const inner = r - rim;
|
|
55
|
+
pen.el("circle", { cx, cy, r, fill: c.fill, stroke: ink, "stroke-width": outline });
|
|
56
|
+
pen.el("circle", { cx, cy, r: inner, fill: "#ffffff", stroke: ink, "stroke-width": outline });
|
|
57
|
+
for (let i = 0; i < 60; i++) {
|
|
58
|
+
const big = i % 5 === 0;
|
|
59
|
+
const a = (i * Math.PI) / 30;
|
|
60
|
+
const r1 = inner - 3;
|
|
61
|
+
const r2 = r1 - (big ? Math.max(6, r * 0.11) : Math.max(3, r * 0.05));
|
|
62
|
+
pen.el("path", {
|
|
63
|
+
d: `M${n(cx + r1 * Math.sin(a))} ${n(cy - r1 * Math.cos(a))}L${n(cx + r2 * Math.sin(a))} ${n(cy - r2 * Math.cos(a))}`,
|
|
64
|
+
stroke: ink,
|
|
65
|
+
"stroke-width": big ? 3 : 1.5,
|
|
66
|
+
"stroke-linecap": "round",
|
|
67
|
+
class: "tick",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (face !== "ticks") {
|
|
71
|
+
const size = Math.max(14, r * 0.2);
|
|
72
|
+
const rn = inner - Math.max(6, r * 0.11) - 6 - size * 0.7;
|
|
73
|
+
const shown = face === "numbers" ? [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] : [12, 3, 6, 9];
|
|
74
|
+
let numbers = "";
|
|
75
|
+
for (const h of shown) {
|
|
76
|
+
const a = (h * Math.PI) / 6;
|
|
77
|
+
const x = cx + rn * Math.sin(a);
|
|
78
|
+
const y = cy - rn * Math.cos(a) + size * 0.36;
|
|
79
|
+
numbers += `<text x="${n(x)}" y="${n(y)}" font-size="${n(size)}" font-weight="700" text-anchor="middle" fill="${ink}" font-family="${esc(font)}">${h}</text>`;
|
|
80
|
+
}
|
|
81
|
+
pen.add(`<g class="numbers">${numbers}</g>`);
|
|
82
|
+
}
|
|
83
|
+
if (clock.ask) {
|
|
84
|
+
const q = r * 0.3;
|
|
85
|
+
pen.el("circle", {
|
|
86
|
+
cx,
|
|
87
|
+
cy,
|
|
88
|
+
r: q,
|
|
89
|
+
fill: "#ffffff",
|
|
90
|
+
stroke: ink,
|
|
91
|
+
"stroke-width": 2,
|
|
92
|
+
"stroke-dasharray": "5 4",
|
|
93
|
+
});
|
|
94
|
+
pen.text(cx, cy, "?", { size: q * 1.3 });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const turn = angles(clock.time);
|
|
98
|
+
hand(pen, cx, cy, r * 0.5, Math.max(6, r * 0.09), turn.hour, "hour");
|
|
99
|
+
hand(pen, cx, cy, inner * 0.86, Math.max(4, r * 0.055), turn.minute, "minute");
|
|
100
|
+
pen.el("circle", {
|
|
101
|
+
cx,
|
|
102
|
+
cy,
|
|
103
|
+
r: Math.max(4, r * 0.06),
|
|
104
|
+
fill: colors.red.fill,
|
|
105
|
+
stroke: ink,
|
|
106
|
+
"stroke-width": 2,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// --- words -------------------------------------------------------------------
|
|
110
|
+
function hourWord(h) {
|
|
111
|
+
return h % 12 === 0 ? 12 : h % 12;
|
|
112
|
+
}
|
|
113
|
+
/** handsOf says where the hands of a time point, as a learner reads them. */
|
|
114
|
+
export function handsOf(time) {
|
|
115
|
+
const { h, m } = parse(time);
|
|
116
|
+
const at = hourWord(h);
|
|
117
|
+
const next = hourWord(h + 1);
|
|
118
|
+
const hour = m === 0
|
|
119
|
+
? `the hour hand points at ${at}`
|
|
120
|
+
: `the hour hand is ${m === 30 ? "halfway " : ""}between ${at} and ${next}`;
|
|
121
|
+
const mark = m / 5;
|
|
122
|
+
const minute = m % 5 === 0
|
|
123
|
+
? `the minute hand points at ${mark === 0 ? 12 : mark}`
|
|
124
|
+
: `the minute hand points between ${Math.floor(mark) === 0 ? 12 : Math.floor(mark)} and ${Math.ceil(mark) === 12 ? 12 : Math.ceil(mark)}, at minute ${m}`;
|
|
125
|
+
return `${minute}, ${hour}`;
|
|
126
|
+
}
|
|
127
|
+
export const clock = {
|
|
128
|
+
kind: "clock",
|
|
129
|
+
members: ["kind", "clocks", "face"],
|
|
130
|
+
check(scene, problems) {
|
|
131
|
+
only(scene, this.members, "scene", problems);
|
|
132
|
+
if (scene.face !== undefined)
|
|
133
|
+
oneOf(scene.face, faces, "face", problems);
|
|
134
|
+
list(scene.clocks, "clocks", problems, 1, most).forEach((c, i) => {
|
|
135
|
+
const path = `clocks[${i}]`;
|
|
136
|
+
if (!isObj(c)) {
|
|
137
|
+
problems.push(`${path}: must be a clock with a time`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
only(c, ["time", "ask", "digital", "label", "color"], path, problems);
|
|
141
|
+
if (c.ask !== undefined && c.ask !== true)
|
|
142
|
+
problems.push(`${path}.ask: must be true, or left out`);
|
|
143
|
+
if (c.ask === true) {
|
|
144
|
+
if (c.time !== undefined)
|
|
145
|
+
problems.push(`${path}.time: an asked clock shows no time`);
|
|
146
|
+
}
|
|
147
|
+
else if (typeof c.time !== "string" || parse(c.time) === undefined)
|
|
148
|
+
problems.push(`${path}.time: must be a time "H:MM", hours 0 to 23, minutes 00 to 59, or ask: true`);
|
|
149
|
+
if (c.digital !== undefined && typeof c.digital !== "boolean")
|
|
150
|
+
problems.push(`${path}.digital: must be true or false`);
|
|
151
|
+
if (c.label !== undefined)
|
|
152
|
+
text(c.label, `${path}.label`, problems, 8);
|
|
153
|
+
if (c.color !== undefined && !isColor(c.color))
|
|
154
|
+
problems.push(`${path}.color: must be a colour: ${Object.keys(colors).join(", ")}`);
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
draw(scene, pen) {
|
|
158
|
+
const s = scene;
|
|
159
|
+
const k = s.clocks.length;
|
|
160
|
+
const a = across(k);
|
|
161
|
+
const r = radiusOf(k);
|
|
162
|
+
const digital = s.clocks.some((c) => c.digital);
|
|
163
|
+
const labelled = s.clocks.some((c) => c.label);
|
|
164
|
+
// One row: the clock, its digits below, its label below them.
|
|
165
|
+
const digitsAt = 2 * r + 2 + 8 + 20;
|
|
166
|
+
const labelAt = 2 * r + 2 + 8 + (digital ? 46 : 0) + 16;
|
|
167
|
+
const rowH = 2 * r + 2 + 8 + (digital ? 46 : 0) + (labelled ? 34 : 0) + 6;
|
|
168
|
+
const rowsOf = Math.ceil(k / a);
|
|
169
|
+
s.clocks.forEach((c, i) => {
|
|
170
|
+
const row = Math.floor(i / a);
|
|
171
|
+
const inRow = Math.min(a, k - row * a);
|
|
172
|
+
const shift = ((a - inRow) * (2 * r + gap)) / 2;
|
|
173
|
+
const cx = margin + 2 + r + (i % a) * (2 * r + gap) + shift;
|
|
174
|
+
const top = margin + row * rowH;
|
|
175
|
+
drawClock(pen, c, s.face ?? "numbers", cx, top + r + 2, r);
|
|
176
|
+
if (c.digital) {
|
|
177
|
+
const words = c.ask ? "?" : c.time;
|
|
178
|
+
const w = Math.max(64, words.length * 15 + 22);
|
|
179
|
+
pen.el("rect", {
|
|
180
|
+
x: cx - w / 2,
|
|
181
|
+
y: top + digitsAt - 18,
|
|
182
|
+
width: w,
|
|
183
|
+
height: 36,
|
|
184
|
+
rx: 8,
|
|
185
|
+
fill: colors.black.fill,
|
|
186
|
+
stroke: ink,
|
|
187
|
+
"stroke-width": outline,
|
|
188
|
+
});
|
|
189
|
+
pen.text(cx, top + digitsAt, words, { size: 22, fill: colors.yellow.fill });
|
|
190
|
+
}
|
|
191
|
+
if (c.label)
|
|
192
|
+
pen.text(cx, top + labelAt, c.label, { size: 18 });
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
width: margin * 2 + 4 + a * 2 * r + (a - 1) * gap,
|
|
196
|
+
height: margin * 2 + rowsOf * rowH - 6,
|
|
197
|
+
};
|
|
198
|
+
},
|
|
199
|
+
describe(scene) {
|
|
200
|
+
const s = scene;
|
|
201
|
+
const face = (s.face ?? "numbers") === "numbers"
|
|
202
|
+
? "with the numbers 1 to 12"
|
|
203
|
+
: s.face === "quarters"
|
|
204
|
+
? "with only the numbers 12, 3, 6 and 9"
|
|
205
|
+
: "with marks but no numbers";
|
|
206
|
+
const one = (c) => {
|
|
207
|
+
if (c.ask)
|
|
208
|
+
return `no hands, a question mark in the middle${c.digital ? ", and ? in digits below" : ""}`;
|
|
209
|
+
return `${c.time}: ${handsOf(c.time)}${c.digital ? `; below it the time in digits, ${c.time}` : ""}`;
|
|
210
|
+
};
|
|
211
|
+
if (s.clocks.length === 1) {
|
|
212
|
+
const c = s.clocks[0];
|
|
213
|
+
return `A clock ${face}${c.label ? `, labelled ${c.label}` : ""}, showing ${one(c)}.`;
|
|
214
|
+
}
|
|
215
|
+
return `${s.clocks.length} clocks in a row, each ${face}. ${s.clocks
|
|
216
|
+
.map((c, i) => `Clock ${c.label ?? i + 1}: ${one(c)}.`)
|
|
217
|
+
.join(" ")}`;
|
|
218
|
+
},
|
|
219
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Kind } from "../kind.ts";
|
|
2
|
+
import { type ColorName } from "../style.ts";
|
|
3
|
+
import { type Thing } from "../things.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Coins: money and goods. Groups of coins and banknotes, each in a holder the
|
|
6
|
+
* picture draws itself — a purse, a piggy bank, an open hand — or in none;
|
|
7
|
+
* and goods on a shop shelf, each with its price tag on the shelf's edge. A
|
|
8
|
+
* coin is a round disc with its value, a note an oblong with its value: both
|
|
9
|
+
* generic, the design of no real currency. Every coin and note is drawn in a
|
|
10
|
+
* place of its own, whole, so a group shows exactly the money the scene says.
|
|
11
|
+
*/
|
|
12
|
+
export declare const holders: readonly ["none", "purse", "piggy", "hand"];
|
|
13
|
+
export type Holder = (typeof holders)[number];
|
|
14
|
+
export type Money = {
|
|
15
|
+
coin?: number | "?";
|
|
16
|
+
note?: number | "?";
|
|
17
|
+
count?: number;
|
|
18
|
+
color?: ColorName;
|
|
19
|
+
};
|
|
20
|
+
export type Purse = {
|
|
21
|
+
holder?: Holder;
|
|
22
|
+
items: Money[];
|
|
23
|
+
label?: string;
|
|
24
|
+
color?: ColorName;
|
|
25
|
+
};
|
|
26
|
+
export type Good = {
|
|
27
|
+
thing: Thing;
|
|
28
|
+
count?: number;
|
|
29
|
+
price: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
};
|
|
32
|
+
export type CoinsScene = {
|
|
33
|
+
kind: "coins";
|
|
34
|
+
goods?: Good[];
|
|
35
|
+
groups?: Purse[];
|
|
36
|
+
};
|
|
37
|
+
export declare const coins: Kind;
|