@openbooknetwork/hesap 0.3.2 → 0.3.3
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/package.json +1 -1
- package/src/client.css +108 -1
- package/src/families/counters/add-figures.js +66 -0
- package/src/families/counters/add-goals.js +30 -2
- package/src/families/counters/add-model.js +60 -10
- package/src/families/counters/add.js +269 -33
- package/src/families/counters/add.mjs +85 -11
- package/src/families/counters/bar-goals.js +107 -0
- package/src/families/counters/bar-model.js +38 -0
- package/src/families/counters/bar.js +412 -0
- package/src/families/counters/bar.mjs +79 -0
- package/src/families/counters/client.css +99 -0
- package/src/families/counters/client.js +2 -1
- package/src/families/counters/counter.js +13 -0
- package/src/families/counters/facts.js +73 -0
- package/src/families/counters/i18n/en.yaml +64 -0
- package/src/families/counters/i18n/tr.yaml +64 -0
- package/src/families/counters/index.mjs +9 -7
- package/src/families/line/i18n/en.yaml +2 -0
- package/src/families/line/i18n/tr.yaml +3 -0
- package/src/families/line/index.mjs +34 -5
- package/src/families/line/line.js +34 -12
- package/src/families/line/model.js +50 -16
- package/src/i18n/en.yaml +67 -0
- package/src/i18n/tr.yaml +68 -0
- package/src/kit/goal.js +8 -1
- package/src/kit/i18n/en.yaml +1 -0
- package/src/kit/i18n/tr.yaml +1 -0
- package/src/kit/kit.css +9 -1
- package/src/kit/written.js +35 -2
|
@@ -29,6 +29,8 @@ const OBJECTS = {
|
|
|
29
29
|
chair: r => [el('path', { class: 'counters-legs', d: `M ${-r * 0.55} ${r * 0.15} L ${-r * 0.55} ${r} M ${r * 0.6} ${r * 0.15} L ${r * 0.6} ${r}` }),
|
|
30
30
|
el('rect', { class: 'counters-body', x: -r * 0.75, y: -r, width: r * 0.4, height: r * 1.3, rx: r * 0.15 }),
|
|
31
31
|
el('rect', { class: 'counters-body', x: -r * 0.75, y: -r * 0.05, width: r * 1.55, height: r * 0.4, rx: r * 0.15 })],
|
|
32
|
+
// A football shirt seen from the front, with room for its number.
|
|
33
|
+
shirt: r => [el('path', { class: 'counters-body', d: `M ${-r * 0.42} ${-r * 0.95} L ${-r * 1.05} ${-r * 0.62} L ${-r * 1.15} ${-r * 0.05} L ${-r * 0.72} ${r * 0.02} L ${-r * 0.72} ${r * 0.98} L ${r * 0.72} ${r * 0.98} L ${r * 0.72} ${r * 0.02} L ${r * 1.15} ${-r * 0.05} L ${r * 1.05} ${-r * 0.62} L ${r * 0.42} ${-r * 0.95} Q 0 ${-r * 0.55} ${-r * 0.42} ${-r * 0.95} Z` })],
|
|
32
34
|
// A football: a ball in its team's colour with a patch.
|
|
33
35
|
ball: r => [el('circle', { class: 'counters-body', r }), el('path', { class: 'counters-patch', d: `M 0 ${-r * 0.5} L ${r * 0.48} ${-r * 0.15} L ${r * 0.3} ${r * 0.42} L ${-r * 0.3} ${r * 0.42} L ${-r * 0.48} ${-r * 0.15} Z` })],
|
|
34
36
|
saucer: r => [el('ellipse', { class: 'counters-body', rx: r * 1.5, ry: r * 0.5 }), el('ellipse', { class: 'counters-well', rx: r * 0.8, ry: r * 0.24 })],
|
|
@@ -50,6 +52,10 @@ function glyph(kind, r) {
|
|
|
50
52
|
el('rect', { class: 'counters-jar-lid', x: -r * 0.86, y: -r * 1.08, width: r * 1.72, height: r * 0.46, rx: r * 0.12 })];
|
|
51
53
|
// A square counter tells the second group of counters/add from the round first group by its shape.
|
|
52
54
|
if (kind === 'square') return [el('rect', { class: 'counters-body', x: -r * 0.9, y: -r * 0.9, width: r * 1.8, height: r * 1.8, rx: r * 0.22 }), el('rect', { class: 'counters-ring', x: -r * 0.52, y: -r * 0.52, width: r * 1.04, height: r * 1.04, rx: r * 0.1 })];
|
|
55
|
+
// An egg stands upright in its cup. A brown egg has speckles, so the two sorts of the egg box differ by more than
|
|
56
|
+
// their colour.
|
|
57
|
+
if (kind === 'egg-brown' || kind === 'egg-white') return [el('ellipse', { class: 'counters-body', rx: r * 0.8, ry: r * 1.02 }),
|
|
58
|
+
...(kind === 'egg-brown' ? [[-0.35, -0.45], [0.3, -0.2], [-0.15, 0.25], [0.35, 0.5], [-0.42, 0.62], [0.05, -0.75]].map(([cx, cy]) => el('circle', { class: 'counters-speck', cx: cx * r, cy: cy * r, r: r * 0.09 })) : [])];
|
|
53
59
|
if (kind === 'bead') return [el('circle', { class: 'counters-body', r }), el('circle', { class: 'counters-shine', r: r * 0.32, cx: -r * 0.35, cy: -r * 0.35 })];
|
|
54
60
|
if (kind === 'car') {
|
|
55
61
|
const w = r * 1.5, l = r * 2.5;
|
|
@@ -72,6 +78,13 @@ export function counter(kind, colour, r = R, n = 0) {
|
|
|
72
78
|
return { g, pop, at: { x: 0, y: 0 }, colour };
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
// gone draws the dashed outline a counter of this kind leaves when it is taken away.
|
|
82
|
+
export function gone(kind, r = R) {
|
|
83
|
+
if (kind === 'square') return el('rect', { class: 'counters-void counters-gone', x: -r * 0.86, y: -r * 0.86, width: r * 1.72, height: r * 1.72, rx: r * 0.22 });
|
|
84
|
+
if (kind.startsWith('egg')) return el('ellipse', { class: 'counters-void counters-gone', rx: r * 0.76, ry: r * 0.98 });
|
|
85
|
+
return el('circle', { class: 'counters-void counters-gone', r: r - 2 });
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
// show draws a counter where its at says, and put moves it there.
|
|
76
89
|
export const show = c => c.g.setAttribute('transform', `translate(${c.at.x} ${c.at.y})`);
|
|
77
90
|
export const put = (c, p) => { c.at.x = p.x; c.at.y = p.y; show(c); };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// The facts of a family under a figure: the two additions above and the two subtractions under them. Each fact is a button named by its reading, and a tap picks it. A fact the page leaves out, or the second
|
|
2
|
+
// of two equal facts, keeps its place empty, so the block does not move when the numbers change.
|
|
3
|
+
import { svg as el } from '../../kit/dom.js';
|
|
4
|
+
import { writtenLine, widthOf, reading, FACTS, FACT_IDS, factsOf, shownFacts, sameFact } from '../../kit/written.js';
|
|
5
|
+
import { press } from './move.js';
|
|
6
|
+
|
|
7
|
+
// A fact's box is this much wider than its widest line, and the boxes stand GAP apart.
|
|
8
|
+
const FACT_W = widthOf('00 + 00 = 00') + 20, GAP = 10;
|
|
9
|
+
|
|
10
|
+
// factsBlock makes the block. tint gives a line the classes of its numbers, and pick runs on a tap on a fact.
|
|
11
|
+
export function factsBlock({ tint, pick }) {
|
|
12
|
+
const slots = FACTS.map(id => {
|
|
13
|
+
const line = writtenLine(), box = el('rect', { class: 'counters-fact-box', rx: 8 });
|
|
14
|
+
const g = el('g', { class: 'counters-fact', role: 'button', 'data-fact': id }, [box, line.el]);
|
|
15
|
+
press(g, () => { if (g.getAttribute('display') !== 'none' && !g.classList.contains('counters-fact-empty')) pick(id); });
|
|
16
|
+
return { id, g, box, line };
|
|
17
|
+
});
|
|
18
|
+
const group = el('g', { class: 'counters-facts', role: 'group' }, slots.map(s => s.g));
|
|
19
|
+
let parts = [0, 0], lit = new Set();
|
|
20
|
+
// mine gives the links that light a slot. With two equal parts the swap lights the first addition, and the whole
|
|
21
|
+
// minus the first part lights the whole minus the second. lights gives those the reader points at.
|
|
22
|
+
const mine = slot => FACT_IDS.filter(id => sameFact(id, ...parts) === slot.id), lights = slot => mine(slot).filter(id => lit.has(id));
|
|
23
|
+
return {
|
|
24
|
+
el: group,
|
|
25
|
+
// ways gives the block's size for a row of this height: two rows of two, so each fact keeps its place, such as
|
|
26
|
+
// the empty place beside an addition or the first column of a family of two facts.
|
|
27
|
+
ways: row => [{ cols: 2, w: 2 * FACT_W + GAP, h: 2 * row + GAP }],
|
|
28
|
+
// at puts the block's top left corner at x, y in the way of cols columns.
|
|
29
|
+
at(x, y, cols, row) {
|
|
30
|
+
slots.forEach((s, k) => {
|
|
31
|
+
const c = cols === 2 ? k % 2 : 0, r = cols === 2 ? Math.floor(k / 2) : k, bx = x + c * (FACT_W + GAP), by = y + r * (row + GAP);
|
|
32
|
+
for (const [a, v] of Object.entries({ x: bx, y: by, width: FACT_W, height: row })) s.box.setAttribute(a, v);
|
|
33
|
+
s.line.at(bx + FACT_W / 2, by + row / 2);
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
// set writes the facts of the two parts that the page lists, names each by its reading and marks the picked one.
|
|
37
|
+
// lines puts another line in a place, such as a challenge's drawn fact in the first place. It gives the lines
|
|
38
|
+
// whose words changed, for a flash.
|
|
39
|
+
set({ first, second, listed, int, T, picked, lines: over = {} }) {
|
|
40
|
+
parts = [first, second];
|
|
41
|
+
const shown = shownFacts(first, second, listed), lines = { ...factsOf(first, second), ...over }, changed = [];
|
|
42
|
+
group.setAttribute('aria-label', T('facts'));
|
|
43
|
+
// A place the page leaves out shows as an empty dashed box, so the reader sees a place there. The second of two
|
|
44
|
+
// equal facts has no place.
|
|
45
|
+
const own = shownFacts(first, second);
|
|
46
|
+
for (const s of slots) {
|
|
47
|
+
const on = shown.includes(s.id), empty = !on && own.includes(s.id);
|
|
48
|
+
s.g.setAttribute('display', on || empty ? 'inline' : 'none');
|
|
49
|
+
s.g.classList.toggle('counters-fact-empty', empty);
|
|
50
|
+
if (!on) {
|
|
51
|
+
for (const a of ['tabindex', 'role', 'aria-label', 'aria-pressed']) s.g.removeAttribute(a);
|
|
52
|
+
s.g.classList.remove('counters-fact-on'); s.line.set(null, int);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
s.g.setAttribute('tabindex', 0); s.g.setAttribute('role', 'button');
|
|
56
|
+
if (s.line.set(tint(lines[s.id]), int)) changed.push(s.line.el);
|
|
57
|
+
s.g.setAttribute('aria-label', reading(lines[s.id], int, T));
|
|
58
|
+
s.g.setAttribute('aria-pressed', String(picked === s.id));
|
|
59
|
+
s.g.classList.toggle('counters-fact-on', picked === s.id || lights(s).length > 0);
|
|
60
|
+
s.line.light('', false, mine(s));
|
|
61
|
+
}
|
|
62
|
+
return changed;
|
|
63
|
+
},
|
|
64
|
+
// light marks the numbers a link points to in every fact, and a whole fact for a link to a fact.
|
|
65
|
+
light(id, on) {
|
|
66
|
+
if (on) lit.add(id); else lit.delete(id);
|
|
67
|
+
for (const s of slots) {
|
|
68
|
+
s.line.light(id, on, mine(s));
|
|
69
|
+
if (FACT_IDS.includes(id)) s.g.classList.toggle('counters-fact-on', s.g.getAttribute('aria-pressed') === 'true' || lights(s).length > 0);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -196,3 +196,67 @@ counters_hint-steps-to-ten-minus: "First work out how many to take away to bring
|
|
|
196
196
|
counters_add-take-to-ten: Down to ten
|
|
197
197
|
counters_goal-steps-to-ten-minus: "Split the {second} in {calc} into the part that takes {first} down to ten and the rest, then press Check."
|
|
198
198
|
counters_add-shelf-left: Left
|
|
199
|
+
counters_add-family-first: First part
|
|
200
|
+
counters_add-family-second: Second part
|
|
201
|
+
counters_add-family-whole: Whole
|
|
202
|
+
counters_add-domino-first: First half
|
|
203
|
+
counters_add-domino-second: Second half
|
|
204
|
+
counters_add-domino-whole: Whole
|
|
205
|
+
counters_add-domino-cover: "Cover the half that shows {x}"
|
|
206
|
+
counters_add-domino-lift: Lift the card
|
|
207
|
+
counters_add-whole-whole: Whole
|
|
208
|
+
counters_add-whole-first: Known part
|
|
209
|
+
counters_add-whole-missing: Missing part
|
|
210
|
+
counters_add-whole-second: Counters put in
|
|
211
|
+
counters_add-claim: Sum
|
|
212
|
+
counters_add-claim-right: "The check gives back {first}, so the sum is right."
|
|
213
|
+
counters_add-claim-wrong: "{back} is not {first}, so the sum is wrong."
|
|
214
|
+
counters_add-squad-whole: Squad
|
|
215
|
+
counters_add-squad-first: On the pitch
|
|
216
|
+
counters_add-squad-missing: Bench seats
|
|
217
|
+
counters_add-squad-second: On the bench
|
|
218
|
+
counters_add-undo-back: Taken back
|
|
219
|
+
counters_add-undo-left: Left
|
|
220
|
+
counters_add-whole-put: Put a counter in the next place
|
|
221
|
+
counters_add-put: Put in a counter
|
|
222
|
+
counters_add-squad-put: Seat the next player on the bench
|
|
223
|
+
counters_add-squad-player: "Player {x} on the pitch"
|
|
224
|
+
counters_add-squad-bench: "Player {x} on the bench"
|
|
225
|
+
counters_add-whole-out: "Counter {x}. Take out the last counter."
|
|
226
|
+
counters_add-out: Take out the last counter
|
|
227
|
+
counters_goal-missing-part: "Put in the part that {calc} asks for, then press Check."
|
|
228
|
+
counters_goal-missing-part-done: "{line}, since {part} and {missing} make {whole}."
|
|
229
|
+
counters_note-missing-part-more: "{part} and {put} make {made}, more than {whole}."
|
|
230
|
+
counters_note-missing-part-less: "{part} and {put} make {made}, less than {whole}."
|
|
231
|
+
counters_hint-missing-part: "{calc} asks: {part} and what make {whole}? Count on from {part} to {whole} and put in a counter for each number you say."
|
|
232
|
+
counters_bar-first: First part
|
|
233
|
+
counters_bar-second: Second part
|
|
234
|
+
counters_bar-whole: Whole
|
|
235
|
+
counters_bar-chocolate-first: First piece
|
|
236
|
+
counters_bar-chocolate-second: Second piece
|
|
237
|
+
counters_bar-chocolate-whole: Squares
|
|
238
|
+
counters_bar-split: Split
|
|
239
|
+
counters_bar-end: End
|
|
240
|
+
counters_bar-cover-whole: Cover the whole
|
|
241
|
+
counters_bar-cover-first: Cover the first part
|
|
242
|
+
counters_bar-cover-second: Cover the second part
|
|
243
|
+
counters_bar-lift: Lift the card
|
|
244
|
+
counters_goal-bar-for-fact: "Set the bar model of the family of {fact}, then press Check."
|
|
245
|
+
counters_goal-bar-for-fact-done: "{whole} is the whole, and {first} and {second} are its parts."
|
|
246
|
+
counters_note-bar-for-fact-longer: "The bar is longer than the whole of {fact}."
|
|
247
|
+
counters_note-bar-for-fact-shorter: "The bar is shorter than the whole of {fact}."
|
|
248
|
+
counters_bar-use: Use them as
|
|
249
|
+
counters_bar-use-parts: the two parts
|
|
250
|
+
counters_bar-use-whole: the whole and a part
|
|
251
|
+
counters_bar-third: Third number
|
|
252
|
+
counters_note-bar-for-fact-right: "The whole is right, and the split is too far to the left for the parts of {fact}. Drag it to the right."
|
|
253
|
+
counters_note-bar-for-fact-left: "The whole is right, and the split is too far to the right for the parts of {fact}. Drag it to the left."
|
|
254
|
+
counters_hint-bar-for-fact-plus: "In {fact}, the whole comes after the = sign. Drag the end to the whole, then split it into the two parts."
|
|
255
|
+
counters_hint-bar-for-fact-minus: "In {fact}, the whole comes first. Drag the end to the whole, then split it into the other two numbers."
|
|
256
|
+
counters_goal-bar-for-two: "Find a third number that makes a family with {greater} and {less}, then press Check."
|
|
257
|
+
counters_goal-bar-for-two-done: "The family of {greater}, {less} and {mine} holds both numbers. So does the family of {greater}, {less} and {other}."
|
|
258
|
+
counters_note-bar-for-two-parts-over: "{greater} and {less} make less than {n}."
|
|
259
|
+
counters_note-bar-for-two-parts-under: "{greater} and {less} make more than {n}."
|
|
260
|
+
counters_note-bar-for-two-whole-over: "{less} and {n} make more than {greater}."
|
|
261
|
+
counters_note-bar-for-two-whole-under: "{less} and {n} make less than {greater}."
|
|
262
|
+
counters_hint-bar-for-two: "A family holds a whole and two parts. Use {greater} and {less} as the two parts and add them, or use {greater} as the whole and {less} as a part and find the missing part."
|
|
@@ -196,3 +196,67 @@ counters_hint-steps-to-ten-minus: "Ona kadar, {first} sayısının dolu onluğun
|
|
|
196
196
|
counters_add-take-to-ten: Ona kadar
|
|
197
197
|
counters_goal-steps-to-ten-minus: "{calc} için Ona kadar ve Diğer parça düğmelerini ayarlayın, sonra Kontrol et düğmesine basın."
|
|
198
198
|
counters_add-shelf-left: Kalan
|
|
199
|
+
counters_add-family-first: Birinci parça
|
|
200
|
+
counters_add-family-second: İkinci parça
|
|
201
|
+
counters_add-family-whole: Bütün
|
|
202
|
+
counters_add-domino-first: Birinci yarı
|
|
203
|
+
counters_add-domino-second: İkinci yarı
|
|
204
|
+
counters_add-domino-whole: Bütün
|
|
205
|
+
counters_add-domino-cover: "{x} gösteren yarıyı kapat"
|
|
206
|
+
counters_add-domino-lift: Kartı kaldır
|
|
207
|
+
counters_add-whole-whole: Bütün
|
|
208
|
+
counters_add-whole-first: Bilinen parça
|
|
209
|
+
counters_add-whole-missing: Bilinmeyen parça
|
|
210
|
+
counters_add-whole-second: Konan sayaçlar
|
|
211
|
+
counters_add-claim: Toplam
|
|
212
|
+
counters_add-claim-right: "Çıkarma işlemi {first} sayısını geri veriyor, yani toplam doğru."
|
|
213
|
+
counters_add-claim-wrong: "{back}, {first} sayısına eşit değil, yani toplam yanlış."
|
|
214
|
+
counters_add-squad-whole: Kadro
|
|
215
|
+
counters_add-squad-first: Sahada
|
|
216
|
+
counters_add-squad-missing: Kulübedeki yerler
|
|
217
|
+
counters_add-squad-second: Kulübede
|
|
218
|
+
counters_add-undo-back: Geri alınan
|
|
219
|
+
counters_add-undo-left: Kalan
|
|
220
|
+
counters_add-whole-put: Sonraki yere bir sayaç koy
|
|
221
|
+
counters_add-put: Bir sayaç koy
|
|
222
|
+
counters_add-squad-put: Sıradaki oyuncuyu kulübeye oturt
|
|
223
|
+
counters_add-squad-player: "Sahadaki {x} numaralı oyuncu"
|
|
224
|
+
counters_add-squad-bench: "Kulübedeki {x} numaralı oyuncu"
|
|
225
|
+
counters_add-whole-out: "{x} numaralı sayaç. Son sayacı geri al."
|
|
226
|
+
counters_add-out: Son sayacı geri al
|
|
227
|
+
counters_goal-missing-part: "{calc} işleminin sorduğu parçayı koyun, sonra Kontrol et düğmesine basın."
|
|
228
|
+
counters_goal-missing-part-done: "{line}, çünkü {part} ile {missing}, {whole} eder."
|
|
229
|
+
counters_note-missing-part-more: "{part} ile {put}, {made} eder. Bu, {whole} sayısından büyük."
|
|
230
|
+
counters_note-missing-part-less: "{part} ile {put}, {made} eder. Bu, {whole} sayısından küçük."
|
|
231
|
+
counters_hint-missing-part: "{calc} şunu sorar: {part} ile kaç, {whole} eder? {part} sayısından {whole} sayısına kadar ileri sayın ve söylediğiniz her sayı için bir sayaç koyun."
|
|
232
|
+
counters_bar-first: Birinci parça
|
|
233
|
+
counters_bar-second: İkinci parça
|
|
234
|
+
counters_bar-whole: Bütün
|
|
235
|
+
counters_bar-chocolate-first: Birinci parça
|
|
236
|
+
counters_bar-chocolate-second: İkinci parça
|
|
237
|
+
counters_bar-chocolate-whole: Kareler
|
|
238
|
+
counters_bar-cover-whole: Bütünü kapat
|
|
239
|
+
counters_bar-cover-first: Birinci parçayı kapat
|
|
240
|
+
counters_bar-cover-second: İkinci parçayı kapat
|
|
241
|
+
counters_bar-lift: Kartı kaldır
|
|
242
|
+
counters_goal-bar-for-fact-done: "Bütün {whole}, parçaları {first} ve {second}."
|
|
243
|
+
# waits: counters_bar-split, for "split (bar model)" in the book's i18n/terms/tr.yaml
|
|
244
|
+
# waits: counters_bar-end, for "end (bar model)"
|
|
245
|
+
# waits: counters_goal-bar-for-fact, for "bar model (figure)" and "fact family (calculations)"
|
|
246
|
+
# waits: counters_note-bar-for-fact-longer, for "bar model (figure)"
|
|
247
|
+
# waits: counters_note-bar-for-fact-shorter, for "bar model (figure)"
|
|
248
|
+
counters_bar-use: Sayılar
|
|
249
|
+
counters_bar-use-parts: iki parça
|
|
250
|
+
counters_bar-use-whole: bütün ve bir parça
|
|
251
|
+
counters_bar-third: Üçüncü sayı
|
|
252
|
+
# waits: counters_note-bar-for-fact-right, for "split (bar model)"
|
|
253
|
+
# waits: counters_note-bar-for-fact-left, for "split (bar model)"
|
|
254
|
+
# waits: counters_hint-bar-for-fact-plus, for "end (bar model)" and "split (bar model)"
|
|
255
|
+
# waits: counters_hint-bar-for-fact-minus, for "end (bar model)" and "split (bar model)"
|
|
256
|
+
counters_note-bar-for-two-parts-over: "{greater} ile {less}, {n} sayısından küçük bir sayı eder."
|
|
257
|
+
counters_note-bar-for-two-parts-under: "{greater} ile {less}, {n} sayısından büyük bir sayı eder."
|
|
258
|
+
counters_note-bar-for-two-whole-over: "{less} ile {n}, {greater} sayısından büyük bir sayı eder."
|
|
259
|
+
counters_note-bar-for-two-whole-under: "{less} ile {n}, {greater} sayısından küçük bir sayı eder."
|
|
260
|
+
# waits: counters_goal-bar-for-two, for "fact family (calculations)"
|
|
261
|
+
# waits: counters_goal-bar-for-two-done, for "fact family (calculations)"
|
|
262
|
+
# waits: counters_hint-bar-for-two, for "fact family (calculations)"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The Node half of the counters family. The bonds scene moves counters between parts and fills ten frames, the
|
|
2
|
-
// count scene counts objects one by one, the match scene pairs two rows, the order scene compares numbers,
|
|
3
|
-
//
|
|
4
|
-
// link shows when the page opens.
|
|
2
|
+
// count scene counts objects one by one, the match scene pairs two rows, the order scene compares numbers, the add
|
|
3
|
+
// scene joins two groups and writes their sum, and the bar scene draws a whole and its parts as a bar model. It
|
|
4
|
+
// checks a page's fields against its scene and says what each link shows when the page opens.
|
|
5
5
|
import { schema } from '@openbooknetwork/kitap';
|
|
6
6
|
import { LOOKS, modeOf, capOf, opening, counts, measuresOf } from './model.js';
|
|
7
7
|
import { GOALS, challengeStart } from './goals.js';
|
|
@@ -9,6 +9,7 @@ import count from './count.mjs';
|
|
|
9
9
|
import match from './match.mjs';
|
|
10
10
|
import order from './order.mjs';
|
|
11
11
|
import add from './add.mjs';
|
|
12
|
+
import bar from './bar.mjs';
|
|
12
13
|
import { numbers } from '../../kit/format.js';
|
|
13
14
|
import { list, challenge, drawn, value } from '../../node.mjs';
|
|
14
15
|
|
|
@@ -98,12 +99,13 @@ function startBonds(spec, lang, id) {
|
|
|
98
99
|
|
|
99
100
|
// Each scene checks its own fields, so the family's schema lets every field through to the scene.
|
|
100
101
|
const Fields = z.object({}).passthrough();
|
|
101
|
-
const SCENES = { bonds: { read: readBonds, start: startBonds }, count, match, order, add };
|
|
102
|
+
const SCENES = { bonds: { read: readBonds, start: startBonds }, count, match, order, add, bar };
|
|
102
103
|
const read = ({ scene, ...fields }, info, ctx) => SCENES[scene].read(fields, info, ctx);
|
|
103
104
|
const start = (spec, lang, id) => SCENES[spec.scene].start(spec, lang, id);
|
|
104
105
|
|
|
105
|
-
// The two colours of the counters, a red and a blue that readers with any colour vision tell apart,
|
|
106
|
-
// for the dark themes.
|
|
107
|
-
const bundle = () => ({ families: { 'counters-red': { color: '#d1453b', color_dark: '#f0776d' }, 'counters-blue': { color: '#2a6bd1', color_dark: '#6fa4f5' }
|
|
106
|
+
// The two colours of the counters, a red and a blue that readers with any colour vision tell apart, and the brown and
|
|
107
|
+
// the shell of the egg box, each with a step for the dark themes.
|
|
108
|
+
const bundle = () => ({ families: { 'counters-red': { color: '#d1453b', color_dark: '#f0776d' }, 'counters-blue': { color: '#2a6bd1', color_dark: '#6fa4f5' },
|
|
109
|
+
'counters-brown': { color: '#a0602c', color_dark: '#d9a273' }, 'counters-shell': { color: '#7f7462', color_dark: '#cdc3b2' } } });
|
|
108
110
|
|
|
109
111
|
export default { id: 'counters', scenes: Object.keys(SCENES), schema: Fields, read, start, bundle };
|
|
@@ -59,3 +59,5 @@ line_hint-jump-minus-one: "Start at {start}. Press Jump left once and say the nu
|
|
|
59
59
|
line_note-jump-way-plus: "{calc} is an addition, so the jumps go to the right from {start}."
|
|
60
60
|
line_note-jump-way-minus: "{calc} is a subtraction, so the jumps go to the left from {start}."
|
|
61
61
|
line_note-jump-few-none: "The point is still on {start}. Make the jumps for {calc} from there."
|
|
62
|
+
line_size: Size of a jump
|
|
63
|
+
line_size-short: Size
|
|
@@ -59,3 +59,6 @@ line_hint-jump-minus-one: "Başlangıçtaki sayıyı söyleyin, sonra her zıpla
|
|
|
59
59
|
line_note-jump-way-plus: Nokta yanlış yöne zıpladı.
|
|
60
60
|
line_note-jump-way-minus: Nokta yanlış yöne zıpladı.
|
|
61
61
|
line_note-jump-few-none: Zıplamalar az.
|
|
62
|
+
# The Turkish words wait for the term "jump (number line)", which the book's i18n/terms/tr.yaml has not sourced yet.
|
|
63
|
+
line_size: Size of a jump
|
|
64
|
+
line_size-short: Size
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The Node half of the line family. Its one scene draws a number line with marks at equal gaps and a point the
|
|
2
2
|
// reader drags or jumps. It checks a page's fields and says what each link shows when the page opens.
|
|
3
3
|
import { schema } from '@openbooknetwork/kitap';
|
|
4
|
-
import { LOOKS, isFree, gapsKey, writtenOf, labelKeep, posOf, gapOn, LABELS_APART, PHONE, STONES_TO, GAPS, isStones, isMark, gapsOf, labelled, cardsOf, middleOf, findsOf, opening, counts, measuresOf, readoutsOf, readingOf } from './model.js';
|
|
4
|
+
import { LOOKS, isFree, gapsKey, writtenOf, backOf, labelKeep, posOf, gapOn, LABELS_APART, PHONE, STONES_TO, GAPS, isStones, isMark, gapsOf, labelled, cardsOf, middleOf, findsOf, opening, counts, measuresOf, readoutsOf, readingOf } from './model.js';
|
|
5
5
|
import { GOALS, challengeStart } from './goals.js';
|
|
6
6
|
import { numbers } from '../../kit/format.js';
|
|
7
7
|
import { words, reading, DASH } from '../../kit/written.js';
|
|
@@ -30,7 +30,10 @@ const Fields = z.object({
|
|
|
30
30
|
second: Int.optional(), // A second point, of another shape and colour.
|
|
31
31
|
flag: z.boolean().default(false), // Each point carries its number in a flag above it.
|
|
32
32
|
reading: z.boolean().default(false), // A line of words says which point's number comes later in the count.
|
|
33
|
-
|
|
33
|
+
// Jump left and Jump right move the point one jump and draw an arc over it: one gap with true, or a size of a jump
|
|
34
|
+
// in gaps, fixed or on a stepper.
|
|
35
|
+
jump: z.union([z.boolean(), Int.min(1), z.object({ stepper: z.tuple([Int, Int]), start: Int.optional() }).strict()]).default(false),
|
|
36
|
+
undo: z.boolean().default(false), // A jump and the same jump back, with the line of each.
|
|
34
37
|
bracket: z.literal(10).optional(), // A bracket from the ten before the point to the ten after it.
|
|
35
38
|
open: z.boolean().default(false), // A tap on a gap opens it under the line, with a mark for every number in it.
|
|
36
39
|
middle: z.union([z.boolean(), z.literal('button')]).default(false), // The middle's long mark, or a button that draws it.
|
|
@@ -50,11 +53,13 @@ function read({ scene, ...fields }, { at }, ctx) {
|
|
|
50
53
|
const pg = check(Fields, fields, at), fail = words => ctx.fail(at, words), step = value(pg.step), est = value(pg.estimate);
|
|
51
54
|
// The book is an unmarked line. An unmarked line labels its ends unless the page says otherwise.
|
|
52
55
|
const marks = pg.look === 'book' ? 'ends' : pg.marks;
|
|
53
|
-
|
|
56
|
+
// A jump of true is one gap, and a number or a stepper gives the size of a jump, which the page then links as size.
|
|
57
|
+
const sized = typeof pg.jump === 'number' || typeof pg.jump === 'object', size = sized ? value(pg.jump) : { n: pg.jump ? 1 : null, ctl: null };
|
|
58
|
+
const spec = { ...pg, scene, marks, labels: pg.labels ?? (marks === 'ends' ? 'ends' : 'all'), step: step.n, stepCtl: step.ctl, estimate: est.n, estimateCtl: est.ctl, sized, size: size.n, sizeCtl: size.ctl };
|
|
54
59
|
const done = () => { const ids = measuresOf(spec); return { data: spec, has: id => ids.includes(id), offers: ids.length ? `one of ${list(ids)}` : 'nothing, a challenge page draws its numbers as it opens' }; };
|
|
55
60
|
// A page that draws its line of cards takes no field of the line, and the browser draws it as the page opens.
|
|
56
61
|
if (pg.draw) {
|
|
57
|
-
for (const f of ['from', 'to', 'step', 'labels', 'blank', 'cards', 'point', 'marks', 'second', 'flag', 'reading', 'jump', 'bracket', 'open', 'middle', 'find', 'estimate', 'challenge', 'start', 'written', 'moved']) if (fields[f] !== undefined) fail(`${f} is drawn with the line on a page with draw, leave it out`);
|
|
62
|
+
for (const f of ['from', 'to', 'step', 'labels', 'blank', 'cards', 'point', 'marks', 'second', 'flag', 'reading', 'jump', 'undo', 'bracket', 'open', 'middle', 'find', 'estimate', 'challenge', 'start', 'written', 'moved']) if (fields[f] !== undefined) fail(`${f} is drawn with the line on a page with draw, leave it out`);
|
|
58
63
|
if (pg.look !== 'line') fail(`look is ${pg.look}, a page with draw shows the line look, leave look out`);
|
|
59
64
|
const outs = readoutsOf(spec);
|
|
60
65
|
for (const id of pg.readout) if (!outs.includes(id)) fail(`readout names "${id}", this page reads out ${list(outs)}`);
|
|
@@ -167,6 +172,8 @@ function read({ scene, ...fields }, { at }, ctx) {
|
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
}
|
|
175
|
+
if (sized) readSize(pg, spec, fail);
|
|
176
|
+
if (pg.undo && !sized) fail(`undo jumps a size and back, write jump as a size, such as jump: 5`);
|
|
170
177
|
if (pg.open && spec.step === 1) fail('open shows the numbers inside a gap, and a line in ones has none, write a step above 1');
|
|
171
178
|
if (pg.challenge) readChallenge(pg, spec, at, ctx);
|
|
172
179
|
const outs = readoutsOf(spec);
|
|
@@ -174,6 +181,26 @@ function read({ scene, ...fields }, { at }, ctx) {
|
|
|
174
181
|
return done();
|
|
175
182
|
}
|
|
176
183
|
|
|
184
|
+
// A jump of a size takes a marked line in the line look, and fits it. An undo page jumps from its start and back,
|
|
185
|
+
// writing both lines, so it takes start, a size and written: true, and none of the fields that move or read the point
|
|
186
|
+
// another way.
|
|
187
|
+
function readSize(pg, spec, fail) {
|
|
188
|
+
const n = gapsOf(spec), { size, sizeCtl: c } = spec;
|
|
189
|
+
if (spec.look !== 'line' || isFree(spec)) fail(`jump has a size, which takes a marked line in the line look, write jump: true`);
|
|
190
|
+
if (pg.challenge) fail('jump has a size, and a challenge jumps one gap at a time, write jump: true');
|
|
191
|
+
if (c && (c.lo < 1 || c.lo >= c.hi || size < c.lo || size > c.hi)) fail(`jump.stepper is [${c.lo}, ${c.hi}] with start ${size}, write [low, high] from 1 with low under high and a start between them`);
|
|
192
|
+
else if ((c?.hi ?? size) > n) fail(`jump reaches a size of ${c?.hi ?? size}, and the line has ${n} gaps, write a size of ${n} at most`);
|
|
193
|
+
else if (pg.start !== undefined && isMark(spec, pg.start) && (pg.start - spec.from) / spec.step - size < 0 && (pg.start - spec.from) / spec.step + size > n) fail(`jump is ${size}, and a jump of ${size} either way from the start ${pg.start} leaves the line, write a smaller size or another start`);
|
|
194
|
+
if (!pg.undo) return;
|
|
195
|
+
// The start of an undo page moves, and from the middle of the line a size over half its gaps rests both buttons.
|
|
196
|
+
if ((c?.hi ?? size) > n / 2) fail(`jump reaches a size of ${c?.hi ?? size}, and from the middle of the line of ${n} gaps a jump over ${n / 2} leaves it either way, write a size of ${Math.floor(n / 2)} at most`);
|
|
197
|
+
if (pg.start === undefined) fail('undo jumps from the start and back to it, write start');
|
|
198
|
+
if (pg.written !== true) fail('undo writes the line of each jump, write written: true');
|
|
199
|
+
for (const f of ['point', 'second', 'bracket', 'find', 'estimate', 'moved']) if (pg[f] !== undefined) fail(`${f} belongs to pages without undo, an undo page takes start, jump, written and readout`);
|
|
200
|
+
for (const f of ['flag', 'open', 'reading']) if (pg[f]) fail(`${f} belongs to pages without undo, an undo page takes start, jump, written and readout`);
|
|
201
|
+
if (spec.stepCtl) fail('undo takes a line of one step, write step as a number');
|
|
202
|
+
}
|
|
203
|
+
|
|
177
204
|
// A challenge page names its goal and the range it draws from. The reader finds the target with the drag and the
|
|
178
205
|
// jumps, so the page shows no number that gives it away. Every target it can draw must be open as the page starts.
|
|
179
206
|
function readChallenge(pg, spec, at, ctx) {
|
|
@@ -215,7 +242,9 @@ function start(spec, lang, id) {
|
|
|
215
242
|
if (!measuresOf(spec).includes(id)) return null;
|
|
216
243
|
const s = opening(spec), int = numbers(lang).int;
|
|
217
244
|
if (id === 'gaps') return string(lang, `line_${gapsKey(s)}`);
|
|
218
|
-
|
|
245
|
+
const say = (w, wording) => !w ? DASH : wording ? reading(w, int, (key, vars) => string(lang, `hesap_${key}`, vars)) : words(w, int);
|
|
246
|
+
if (id === 'written' || id === 'reading' && spec.written) return say(writtenOf(spec, s), id === 'reading');
|
|
247
|
+
if (id === 'written-back' || id === 'reading-back') return say(backOf(spec, s), id === 'reading-back');
|
|
219
248
|
if (id === 'reading') { const r = readingOf(spec, s); return string(lang, `line_${r.key}`, { a: int(r.a), b: int(r.b) }); }
|
|
220
249
|
const v = counts(spec, s)[id];
|
|
221
250
|
return v === null ? DASH : int(v);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// round the point, gaps that open into lines of their own, and label cards for blank marks. The looks stones and
|
|
4
4
|
// stones-on-line draw the frog's stepping stones of the opening pages. A challenge page asks the reader to put the
|
|
5
5
|
// point on a number.
|
|
6
|
-
import { opening, jump, place, pick, open, lay, show as reveal, next, toggleMiddle, estimate as setEstimate, moveStart, writtenOf, isFree, numbered, standing, posOf, slide, labelKeep, settle as settleMarks, gapsKey, sides, SETTLE, arcsOf, jumpsOf, counts, readoutsOf, measuresOf, readingOf, tensOf, gapsOf, numberAt, markOf, labelled, findsOf, shuffled, isStones, gapOn, labelRows, secondTo, drawLine } from './model.js';
|
|
6
|
+
import { opening, jump, place, pick, open, lay, show as reveal, next, toggleMiddle, estimate as setEstimate, moveStart, resize, writtenOf, backOf, isFree, numbered, standing, posOf, slide, labelKeep, settle as settleMarks, gapsKey, sides, SETTLE, arcsOf, jumpsOf, counts, readoutsOf, measuresOf, readingOf, tensOf, gapsOf, numberAt, markOf, labelled, findsOf, shuffled, isStones, gapOn, labelRows, secondTo, drawLine } from './model.js';
|
|
7
7
|
import { GOALS } from './goals.js';
|
|
8
8
|
import { pointShape, flag, arc, frog, stone, pond, bracket as makeBracket, blankBox, card, house, plaque, van, book, bookmark, BOX, CARD } from './figures.js';
|
|
9
9
|
import { lens as makeLens, LENS_H } from './lens.js';
|
|
@@ -25,6 +25,7 @@ const STILL = 4; // A press that moves less than this many pixels leaves the poi
|
|
|
25
25
|
const POLE = 16, FLAG = 24, STACK = 30; // A flag's pole, its box, and how far a second flag over the same place rises.
|
|
26
26
|
const LONG = 11, SHORT = 6; // Half the height of a long mark and of a short mark.
|
|
27
27
|
const BOOK_TOP = 34; // The bookmark stands this far above the edge of the book.
|
|
28
|
+
const ARC_Y = -6; // The arcs over the line start this far above it.
|
|
28
29
|
const WHO = ['point', 'second'];
|
|
29
30
|
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
30
31
|
|
|
@@ -65,8 +66,10 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
65
66
|
// A blank box at an end of the line keeps its whole width on the stage.
|
|
66
67
|
const gap = gapOn(W - (spec.blank.length ? BOX.w : 0) - (street() ? 8 : 0), n, stones), x0 = (W - n * gap) / 2;
|
|
67
68
|
const big = gap >= 34, r = big ? 11 : 9, arcH = clamp(gap * 0.42, Math.min(10, gap * 1.5), 26);
|
|
69
|
+
// A jump over several gaps rises higher than a jump over one, so its arc does not lie flat along the line.
|
|
70
|
+
const rise = len => len <= 1 ? arcH : Math.min(arcH * (1 + 0.35 * (len - 1)), arcH * 2.5, 48);
|
|
68
71
|
const sw = Math.min(gap * 0.86, 58), fs = Math.min(Math.max(gap * 0.9, 26), 46);
|
|
69
|
-
let top, bottom, g = { gap, x0, r, arcH, sw, fs, n, x: k => x0 + k * gap, narrow: gap < (spec.look === 'street' ? NARROW_STREET : NARROW) && onLine && !isFree(spec), font: big ? 16 : 14, rows: 1 };
|
|
72
|
+
let top, bottom, g = { gap, x0, r, arcH, rise, sw, fs, n, x: k => x0 + k * gap, narrow: gap < (spec.look === 'street' ? NARROW_STREET : NARROW) && onLine && !isFree(spec), font: big ? 16 : 14, rows: 1 };
|
|
70
73
|
// A house of the street is about as wide as its gap, and a flag stands over its door number.
|
|
71
74
|
g.houseH = clamp(gap * 1.1, 12, 36); g.flagFrom = street() ? -(g.houseH + 30) : spec.look === 'book' ? -BOOK_TOP : -r;
|
|
72
75
|
if (!onLine) {
|
|
@@ -79,12 +82,18 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
79
82
|
const spacing = gap * Math.min(n, ...ks.slice(1).map((k, i) => k - ks[i]));
|
|
80
83
|
Object.assign(g, labelRows(wide(ks.map(k => int(num(k)))), spacing, { base: g.font, least: FONT, apart: APART }));
|
|
81
84
|
g.row = new Map(ks.map((k, i) => [k, g.rows === 2 ? i % 2 : 0]));
|
|
82
|
-
g.labelY = 26 + g.font / 2;
|
|
85
|
+
g.labelY = 26 + g.font / 2;
|
|
86
|
+
// Every jump of an undo page starts or ends at the start, so its arcs over the line stand on the top of the
|
|
87
|
+
// start's ring, which reaches r + 7 above the line, where a short arc would hide inside the ring.
|
|
88
|
+
g.arcY = spec.undo ? -(r + 7 + 2) : ARC_Y;
|
|
83
89
|
if (street()) g.labelY = -(g.houseH + 16);
|
|
84
90
|
let y = street() ? 34 : Math.max(g.labelY + g.font / 2 + (g.rows === 2 ? g.font + 3 : 0), spec.blank.length ? g.labelY + BOX.h / 2 : 0) + 6;
|
|
85
|
-
|
|
91
|
+
const most = rise(spec.sizeCtl?.hi ?? spec.size ?? 1);
|
|
92
|
+
if (spec.jump) { g.downY = y + 6; y = g.downY + most + 6; }
|
|
86
93
|
if (spec.reading || spec.moved) { g.readingY = y + 22; y += 46; }
|
|
87
94
|
if (spec.written) { g.writtenY = y + 32; y += 64; }
|
|
95
|
+
// The line of the jump back stands under the line of the first jump.
|
|
96
|
+
if (spec.undo) { g.backY = y + 12; y += 44; }
|
|
88
97
|
if (spec.open) { g.openTop = y; g.openY = y + 56; y = g.openY + 40; }
|
|
89
98
|
if (spec.cards) {
|
|
90
99
|
const per = Math.max(1, Math.floor((W - 20) / (CARD.w + 8))), all = s.cards.length, row0 = y + 30 + CARD.h / 2;
|
|
@@ -96,7 +105,7 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
96
105
|
// the flag of the number to find over it.
|
|
97
106
|
const flags = spec.flag || spec.challenge || spec.find != null || spec.estimate != null ? -g.flagFrom + POLE + FLAG + (spec.second != null || spec.find != null || spec.challenge ? STACK : 0) : r;
|
|
98
107
|
g.lensY = street() ? g.labelY - 14 : -r - 6;
|
|
99
|
-
top = -Math.max(flags, spec.jump ?
|
|
108
|
+
top = -Math.max(flags, spec.jump ? -(g.arcY ?? ARC_Y) + most + 4 : 0, g.narrow ? -g.lensY + LENS_H : 0, spec.bracket ? 30 : 0) - 8;
|
|
100
109
|
if (stones) {
|
|
101
110
|
// The stones stand over the line, each over the mark of its number, with the frog on the stone over the point.
|
|
102
111
|
g.water = [0, -(spec.jump ? arcH + 18 : 20)];
|
|
@@ -179,7 +188,11 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
179
188
|
nodes.push(...['find', 'second', 'point'].filter(w => parts.flags[w]).map(w => parts.flags[w].el));
|
|
180
189
|
if (spec.start != null) nodes.push(ring());
|
|
181
190
|
nodes.push(layer);
|
|
182
|
-
if (spec.written) { parts.written = null; parts.writtenAt = el('g', { class: 'line-written' }); nodes.push(parts.writtenAt); }
|
|
191
|
+
if (spec.written) { parts.written = null; parts.writtenOrder = null; parts.writtenAt = el('g', { class: 'line-written' }); nodes.push(parts.writtenAt); }
|
|
192
|
+
if (spec.undo) {
|
|
193
|
+
parts.back = writtenLine({ refs: { b: 'size', c: 'start' }, cls: { c: 'line-c-point' } });
|
|
194
|
+
parts.back.at(area.w / 2, y0 + g.backY); nodes.push(parts.back.el);
|
|
195
|
+
} else parts.back = null;
|
|
183
196
|
if (parts.keys) nodes.push(...parts.keys);
|
|
184
197
|
if (spec.cards) nodes.push(cards());
|
|
185
198
|
if (g.narrow) { parts.lens = makeLens(); nodes.push(parts.lens.el); }
|
|
@@ -400,7 +413,8 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
400
413
|
settle();
|
|
401
414
|
const next = jump(spec, s, dir);
|
|
402
415
|
if (!next) return;
|
|
403
|
-
|
|
416
|
+
// Each press of an undo page draws a new arc, the jump back or a new first jump.
|
|
417
|
+
const from = geo ? xm(s.at) : null, adds = spec.undo || jumpsOf(next) > jumpsOf(s);
|
|
404
418
|
s = next; look(false);
|
|
405
419
|
if (geo) go({ who: 'point', from, to: xm(s.at), hop: isStones(spec), adds }, 320);
|
|
406
420
|
else refresh();
|
|
@@ -435,7 +449,7 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
435
449
|
const g = geo, y0 = g.y0, st = now();
|
|
436
450
|
// The arcs run over the gaps the point has jumped. The newest one draws itself while the point is on its way.
|
|
437
451
|
const arcs = arcsOf(st).flatMap((a, i, all) => {
|
|
438
|
-
const down = a.dir < 0, y = y0 + (down ? g.downY : g.arcY), part = arc(xm(a.from, st), xm(a.to, st), y, g.
|
|
452
|
+
const down = a.dir < 0, y = y0 + (down ? g.downY : g.arcY), part = arc(xm(a.from, st), xm(a.to, st), y, g.rise(Math.abs(a.to - a.from)), down);
|
|
439
453
|
if (glide?.adds && i === all.length - 1) { part.path.setAttribute('stroke-dasharray', '1 1'); part.path.setAttribute('stroke-dashoffset', 1 - glide.o.t); part.head.setAttribute('opacity', glide.o.t > 0.9 ? 1 : 0); }
|
|
440
454
|
return g.narrow ? [part.path] : [part.path, part.head];
|
|
441
455
|
});
|
|
@@ -496,14 +510,16 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
496
510
|
// its goal holds. Its numbers take the colour of the point or the second point they write.
|
|
497
511
|
if (parts.ring) { parts.ring.setAttribute('transform', `translate(${xm(st.base, st)} ${y0})`); parts.ring.setAttribute('aria-valuenow', num(st.base, st)); }
|
|
498
512
|
if (parts.writtenAt) {
|
|
499
|
-
|
|
513
|
+
// An undo page has no line before its first jump, and its line keeps the ids of its first jump.
|
|
514
|
+
const w = writtenOf(spec, st), ids = w?.ids ?? { a: 'start', b: 'size' }, order = `${ids.a}|${ids.b}`;
|
|
500
515
|
if (parts.writtenOrder !== order) {
|
|
501
|
-
const cls = Object.fromEntries(Object.entries(
|
|
502
|
-
parts.written = writtenLine({ refs:
|
|
516
|
+
const cls = Object.fromEntries(Object.entries(ids).filter(([, id]) => id === 'start' || id === 'second').map(([role, id]) => [role, id === 'start' ? 'line-c-point' : 'line-c-second']));
|
|
517
|
+
parts.written = writtenLine({ refs: ids, cls }); parts.writtenOrder = order;
|
|
503
518
|
parts.writtenAt.replaceChildren(parts.written.el); parts.written.at(area.w / 2, y0 + g.writtenY);
|
|
504
519
|
}
|
|
505
520
|
parts.written.set(spec.challenge && !solved ? null : w, int);
|
|
506
521
|
}
|
|
522
|
+
parts.back?.set(backOf(spec, st), int);
|
|
507
523
|
if (parts.reading) fit(parts.reading, spec.moved ? T(gapsKey(st)) : words(st), area.w - 24);
|
|
508
524
|
// The marks, their labels and their touch bands stand where the marks stand.
|
|
509
525
|
if (spec.moved) {
|
|
@@ -538,7 +554,10 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
538
554
|
// refresh writes every value that follows the figure, in the readouts, the challenge's line and the text. Every
|
|
539
555
|
// goal speaks with the line and the notes of place.
|
|
540
556
|
function refresh() {
|
|
541
|
-
const st = now(), c = counts(spec, st), ids = measuresOf(spec), w = writtenOf(spec, st),
|
|
557
|
+
const st = now(), c = counts(spec, st), ids = measuresOf(spec), w = writtenOf(spec, st), back = backOf(spec, st);
|
|
558
|
+
// A line not yet made, such as the first jump of an undo page before a press, reads a dash.
|
|
559
|
+
const line = (l, wording) => !l ? DASH : wording ? writeReading(l, int, T) : writeWords(l, int);
|
|
560
|
+
const value = id => id === 'gaps' ? T(gapsKey(st)) : id === 'written' ? line(w) : id === 'reading' ? (spec.written ? line(w, true) : words(st)) : id === 'written-back' ? line(back) : id === 'reading-back' ? line(back, true) : c[id] === null ? DASH : int(c[id]);
|
|
542
561
|
const shows = id => id === 'placed' ? T('placed-of', { n: int(c.placed), all: int(spec.blank.length) }) : value(id);
|
|
543
562
|
for (const k of chips) if (k.set(shows(k.id)) && moving() && !held) motion.flash(k.el);
|
|
544
563
|
if (goal) {
|
|
@@ -565,6 +584,8 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
565
584
|
const ctls = [];
|
|
566
585
|
// A pick of the step keeps the gaps, the point's mark and its jumps, and writes every label again.
|
|
567
586
|
if (spec.stepCtl) ctls.push(segment({ id: 'step', label: T('step'), items: spec.stepCtl.items.map(v => [v, int(v)]), value: s.step, pick: v => { s = pick(s, Number(v)); build(); } }));
|
|
587
|
+
// The size of a jump steps, which clears the jumps and puts the point on the start.
|
|
588
|
+
if (spec.sizeCtl) ctls.push(stepper({ id: 'size', label: T('size'), min: spec.sizeCtl.lo, max: spec.sizeCtl.hi, value: s.size, write: int, change: v => { settle(); s = resize(s, v); paint(); } }));
|
|
568
589
|
if (jumps) ctls.push(h('div', { class: 'line-jumps' }, [jumps.left, jumps.right]));
|
|
569
590
|
// Middle draws the middle's mark and takes it away. Show reveals where the number to find is, and Next asks for
|
|
570
591
|
// the next number of the list once the reader has seen this one.
|
|
@@ -612,6 +633,7 @@ export default function line({ host, stage, panel, T, lang, moving, motion }) {
|
|
|
612
633
|
if (!spec) return;
|
|
613
634
|
for (const part of svg.querySelectorAll(`[data-ref="${id}"]`)) part.classList.toggle('line-hot', on);
|
|
614
635
|
parts?.written?.light(id, on, ['written', 'reading']);
|
|
636
|
+
parts?.back?.light(id, on, ['written-back', 'reading-back']);
|
|
615
637
|
for (const part of panel.querySelectorAll('[data-ref]')) part.classList.toggle('hot', on && part.dataset.ref === id);
|
|
616
638
|
}
|
|
617
639
|
|