@altnovatrail/canvas 0.3.39 → 0.3.40

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.
Files changed (74) hide show
  1. package/lib/core/boxes.d.ts +7 -7
  2. package/lib/core/boxes.js +10 -10
  3. package/lib/core/clock.d.ts +5 -5
  4. package/lib/core/clock.js +5 -5
  5. package/lib/core/crop.d.ts +13 -13
  6. package/lib/core/crop.js +10 -10
  7. package/lib/core/eraser.d.ts +6 -6
  8. package/lib/core/eraser.js +6 -6
  9. package/lib/core/example.d.ts +6 -6
  10. package/lib/core/example.js +9 -9
  11. package/lib/core/fields.d.ts +1 -1
  12. package/lib/core/fields.js +1 -1
  13. package/lib/core/geometry.d.ts +6 -5
  14. package/lib/core/geometry.js +8 -6
  15. package/lib/core/grid.d.ts +3 -3
  16. package/lib/core/grid.js +3 -3
  17. package/lib/core/groups.d.ts +14 -14
  18. package/lib/core/groups.js +6 -6
  19. package/lib/core/hands.d.ts +19 -18
  20. package/lib/core/hands.js +16 -15
  21. package/lib/core/history.d.ts +9 -9
  22. package/lib/core/history.js +6 -6
  23. package/lib/core/index.js +8 -9
  24. package/lib/core/ink.js +3 -3
  25. package/lib/core/manifest.d.ts +3 -3
  26. package/lib/core/manifest.js +6 -6
  27. package/lib/core/marks.d.ts +39 -39
  28. package/lib/core/marks.js +34 -34
  29. package/lib/core/notation.d.ts +5 -5
  30. package/lib/core/outline.d.ts +3 -3
  31. package/lib/core/outline.js +6 -6
  32. package/lib/core/page.d.ts +7 -7
  33. package/lib/core/page.js +10 -10
  34. package/lib/core/png.d.ts +3 -3
  35. package/lib/core/png.js +3 -3
  36. package/lib/core/raster.d.ts +3 -3
  37. package/lib/core/raster.js +3 -3
  38. package/lib/core/recorder.d.ts +7 -7
  39. package/lib/core/recorder.js +7 -7
  40. package/lib/core/screen.d.ts +2 -2
  41. package/lib/core/screen.js +1 -1
  42. package/lib/core/sets.d.ts +1 -1
  43. package/lib/core/sets.js +1 -1
  44. package/lib/core/sheet.d.ts +3 -3
  45. package/lib/core/sheet.js +3 -3
  46. package/lib/core/submission.d.ts +24 -24
  47. package/lib/core/submission.js +21 -21
  48. package/lib/core/task.d.ts +17 -16
  49. package/lib/core/task.js +14 -13
  50. package/lib/core/tracing.d.ts +20 -20
  51. package/lib/core/tracing.js +20 -20
  52. package/lib/core/widths.d.ts +2 -2
  53. package/lib/core/widths.js +5 -5
  54. package/lib/core/work.d.ts +18 -18
  55. package/lib/core/work.js +21 -21
  56. package/lib/core/zoom.d.ts +4 -4
  57. package/lib/core/zoom.js +4 -4
  58. package/lib/element/index.d.ts +87 -87
  59. package/lib/element/index.js +284 -281
  60. package/lib/element/labels.d.ts +17 -17
  61. package/lib/element/labels.js +7 -8
  62. package/lib/element/notation.js +1 -1
  63. package/lib/element/parts.d.ts +2 -2
  64. package/lib/element/parts.js +6 -6
  65. package/lib/element/pictures.js +1 -1
  66. package/lib/element/probe.d.ts +2 -2
  67. package/lib/element/probe.js +3 -3
  68. package/lib/element/session.js +2 -2
  69. package/lib/element/statement.d.ts +2 -2
  70. package/lib/element/statement.js +6 -6
  71. package/lib/element/tools.d.ts +17 -18
  72. package/lib/element/tools.js +30 -29
  73. package/lib/element/tracing.js +8 -8
  74. package/package.json +3 -3
@@ -8,7 +8,7 @@ export interface Cell {
8
8
  readonly box: PageBox;
9
9
  }
10
10
  /**
11
- * The rule of boxes (R37), in thousandths of a box's width across and of its height down: how far
11
+ * The rule of boxes, in thousandths of a box's width across and of its height down: how far
12
12
  * the box is widened for the middle of a stroke's points, and how wide and how tall the box of its
13
13
  * points may be.
14
14
  */
@@ -16,16 +16,16 @@ export interface BoxRule {
16
16
  readonly margin: number;
17
17
  readonly limit: number;
18
18
  }
19
- /** The rule the workbook has (R37). */
19
+ /** The rule the workbook has. */
20
20
  export declare const BOX_RULE: BoxRule;
21
21
  /**
22
22
  * Which answer slots the learner's strokes fill, per item, per slot, in the task's order: a
23
- * workbook's boxes, each whether it holds a stroke (R34, R37), or a sheet's one answer anywhere on
24
- * it or the whole sheet, whether the sheet holds one (R42). spec's type (R74 spec; R07).
23
+ * workbook's boxes, each whether it holds a stroke, or a sheet's one answer anywhere on
24
+ * it or the whole sheet, whether the sheet holds one. spec's type.
25
25
  */
26
26
  export type { Filled };
27
27
  /**
28
- * What a sheet's one answer slot — anywhere on it, or the whole sheet — is filled with (R42): a
28
+ * What a sheet's one answer slot — anywhere on it, or the whole sheet — is filled with: a
29
29
  * stroke on the sheet, or none. The same array each time, as a workbook's filling stays the same
30
30
  * until a box changes.
31
31
  */
@@ -39,10 +39,10 @@ export declare function cellsOf(page: Page): readonly Cell[];
39
39
  * one with a point off the sheet a RangeError, as the crop has them.
40
40
  */
41
41
  export declare function cellOf(stroke: Stroke, cells: readonly Cell[], rule?: BoxRule): number;
42
- /** A filled box and the IDs of its strokes, in ascending order: spec's type (R74 spec; R07). */
42
+ /** A filled box and the IDs of its strokes, in ascending order: spec's type. */
43
43
  export type { Filling };
44
44
  /**
45
- * The table of the boxes the strokes fill (R34): each box that holds a stroke, in the order of
45
+ * The table of the boxes the strokes fill: each box that holds a stroke, in the order of
46
46
  * `cells`, with the IDs of its strokes. A stroke ID twice is a TypeError.
47
47
  */
48
48
  export declare function tableOf(strokes: readonly Stroke[], cells: readonly Cell[], rule?: BoxRule): readonly Filling[];
package/lib/core/boxes.js CHANGED
@@ -1,19 +1,19 @@
1
- // The boxes of a workbook's page and the strokes in them (R34, R37). Each visible stroke is in one
2
- // box or in none: the rule takes it alone, in whole numbers, with no DOM and no time, and what is in
3
- // no box is the draft. A stroke is a box's if the middle of the box of its points lies in the box
4
- // widened by 120 thousandths of its size — 12 units of a box of 100, short of the 16 to halfway to
5
- // the next box — and it is no wider and no taller than the box and 30 units on each side: a
1
+ // The boxes of a workbook's page and the strokes in them (R37). Each visible stroke is in one
2
+ // box or in none: the rule takes it alone, in whole numbers, with no DOM and no time, and what is
3
+ // in no box is the draft. A stroke is a box's if the middle of the box of its points lies in the
4
+ // box widened by 120 thousandths of its size — 12 units of a box of 100, short of the 16 to halfway
5
+ // to the next box — and it is no wider and no taller than the box and 30 units on each side: a
6
6
  // fraction's bar wider than the box is its own, and a line through the whole line is not. The
7
7
  // core's entry point does not give the rule. It is the eval protocol's too, and spec's test vectors
8
- // pin it (R94 spec).
8
+ // pin it.
9
9
  import { extentOf, tenths } from "./geometry.js";
10
- /** The rule the workbook has (R37). */
10
+ /** The rule the workbook has. */
11
11
  export const BOX_RULE = Object.freeze({ margin: 120, limit: 1600 });
12
- /** A sheet's one answer slot, filled and not: the same frozen arrays for every sheet (R42). */
12
+ /** A sheet's one answer slot, filled and not: the same frozen arrays for every sheet. */
13
13
  const STROKED = Object.freeze([Object.freeze([true])]);
14
14
  const BLANK = Object.freeze([Object.freeze([false])]);
15
15
  /**
16
- * What a sheet's one answer slot — anywhere on it, or the whole sheet — is filled with (R42): a
16
+ * What a sheet's one answer slot — anywhere on it, or the whole sheet — is filled with: a
17
17
  * stroke on the sheet, or none. The same array each time, as a workbook's filling stays the same
18
18
  * until a box changes.
19
19
  */
@@ -69,7 +69,7 @@ export function cellOf(stroke, cells, rule = BOX_RULE) {
69
69
  return chosen;
70
70
  }
71
71
  /**
72
- * The table of the boxes the strokes fill (R34): each box that holds a stroke, in the order of
72
+ * The table of the boxes the strokes fill: each box that holds a stroke, in the order of
73
73
  * `cells`, with the IDs of its strokes. A stroke ID twice is a TypeError.
74
74
  */
75
75
  export function tableOf(strokes, cells, rule = BOX_RULE) {
@@ -1,10 +1,10 @@
1
1
  /**
2
- * The sheet's clock: milliseconds of the sheet, never going back (R09, R18). The page's time it is
2
+ * The sheet's clock: milliseconds of the sheet, never going back. The page's time it is
3
3
  * given — a pointer event's `timeStamp`, or `performance.now()` for a method the consumer calls —
4
4
  * both count from the page's time origin (DOM Standard; High Resolution Time), so one clock serves
5
- * the strokes, the eraser and the actions of the sheet alike (R22). A new sheet's time starts at
6
- * its first event; a sheet given a history of writing goes on from where that history leaves off
7
- * (R27): the sheet's time is its history's.
5
+ * the strokes, the eraser and the actions of the sheet alike. A new sheet's time starts at
6
+ * its first event; a sheet given a history of writing goes on from where that history leaves off:
7
+ * the sheet's time is its history's.
8
8
  */
9
9
  export declare class Clock {
10
10
  #private;
@@ -18,7 +18,7 @@ export declare class Clock {
18
18
  get latest(): number;
19
19
  /**
20
20
  * The clock goes on at `t`: the next moment asked about is the sheet's `t`, whatever the page's
21
- * time, and the clock counts on from there (R27). It may go back, when the sheet takes a history
21
+ * time, and the clock counts on from there. It may go back, when the sheet takes a history
22
22
  * shorter than the one it had; `resume(0)` makes it a new sheet's clock.
23
23
  */
24
24
  resume(t: number): void;
package/lib/core/clock.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * The sheet's clock: milliseconds of the sheet, never going back (R09, R18). The page's time it is
2
+ * The sheet's clock: milliseconds of the sheet, never going back. The page's time it is
3
3
  * given — a pointer event's `timeStamp`, or `performance.now()` for a method the consumer calls —
4
4
  * both count from the page's time origin (DOM Standard; High Resolution Time), so one clock serves
5
- * the strokes, the eraser and the actions of the sheet alike (R22). A new sheet's time starts at
6
- * its first event; a sheet given a history of writing goes on from where that history leaves off
7
- * (R27): the sheet's time is its history's.
5
+ * the strokes, the eraser and the actions of the sheet alike. A new sheet's time starts at
6
+ * its first event; a sheet given a history of writing goes on from where that history leaves off:
7
+ * the sheet's time is its history's.
8
8
  */
9
9
  export class Clock {
10
10
  #origin;
@@ -28,7 +28,7 @@ export class Clock {
28
28
  }
29
29
  /**
30
30
  * The clock goes on at `t`: the next moment asked about is the sheet's `t`, whatever the page's
31
- * time, and the clock counts on from there (R27). It may go back, when the sheet takes a history
31
+ * time, and the clock counts on from there. It may go back, when the sheet takes a history
32
32
  * shorter than the one it had; `resume(0)` makes it a new sheet's clock.
33
33
  */
34
34
  resume(t) {
@@ -3,13 +3,13 @@ import { type Box } from "./geometry.js";
3
3
  import type { Group } from "./groups.js";
4
4
  import type { Stroke } from "./ink.js";
5
5
  /**
6
- * The crop's rule in its numbers (R25): sizes on the crop in pixels, heights on the sheet in units.
7
- * The rule counts in whole numbers — places in tenths of a unit, as the groups do (R24) — and each
6
+ * The crop's rule in its numbers: sizes on the crop in pixels, heights on the sheet in units (R25).
7
+ * The rule counts in whole numbers — places in tenths of a unit, as the groups do — and each
8
8
  * number it hands out that is not whole is one division of two whole numbers, so that tutor's
9
9
  * runner, which crops by the same rule, gets the same numbers to the bit.
10
10
  */
11
11
  export declare const CROP: Readonly<{
12
- /** The margin around the work, px (R06). */
12
+ /** The margin around the work, px. */
13
13
  margin: 12;
14
14
  /**
15
15
  * A stroke lower than this, in units, is a line, not writing — a dot, a minus, a bar, an
@@ -31,7 +31,7 @@ export declare const CROP: Readonly<{
31
31
  digit: 24;
32
32
  /**
33
33
  * The heights of digits a sample's crops are drawn at, px, as the eval protocol names them,
34
- * beside the module's own (R09; R93 spec).
34
+ * beside the module's own.
35
35
  */
36
36
  heights: readonly [16, 24, 32, 48];
37
37
  /** The tallest digit a crop takes, px: its ink then still stays within the margin. */
@@ -39,13 +39,13 @@ export declare const CROP: Readonly<{
39
39
  }>;
40
40
  /**
41
41
  * A group's frame on a crop: its label, and its ink in fractions 0–1000 of the crop, [ymin, xmin,
42
- * ymax, xmax] — every pixel the ink of its strokes touches lies within it. spec's type (R74 spec).
42
+ * ymax, xmax] — every pixel the ink of its strokes touches lies within it. spec's type.
43
43
  */
44
44
  export type { Frame };
45
45
  /**
46
- * The crop of a sheet for checking (R25), all but its pixels: what lies where, at what scale. Its
46
+ * The crop of a sheet for checking, all but its pixels: what lies where, at what scale. Its
47
47
  * numbers the marks are placed by — D′, the size, the margins, `sheet_box`, the frames and the
48
- * whole numbers they come from — are spec's CropNumbers (R74 spec), and the rest the crop's own.
48
+ * whole numbers they come from — are spec's CropNumbers, and the rest the crop's own.
49
49
  */
50
50
  export interface Crop extends CropNumbers {
51
51
  /** D, the height of a digit asked for, px. */
@@ -58,24 +58,24 @@ export interface Crop extends CropNumbers {
58
58
  readonly line: number;
59
59
  }
60
60
  /**
61
- * The bundles of the strokes on a sheet (R25): strokes no lower than `CROP.flat`, joined by a chain
61
+ * The bundles of the strokes on a sheet: strokes no lower than `CROP.flat`, joined by a chain
62
62
  * of boxes that touch or overlap, whenever each was written. Each bundle by its IDs ascending, the
63
63
  * bundles by their smallest ID.
64
64
  */
65
65
  export declare function bundlesOf(strokes: readonly Stroke[]): number[][];
66
- /** h_med (R25): the lower median of the heights of the bundles, in units; `CROP.flat` if none. */
66
+ /** h_med: the lower median of the heights of the bundles, in units; `CROP.flat` if none. */
67
67
  export declare function medianOf(strokes: readonly Stroke[]): number;
68
68
  /**
69
69
  * The crop of the strokes on a sheet with its digits `digit` px high, and the frames of their
70
- * groups (R25): the strokes the sheet shows, and their groups by the sheet's rule (R24). A sheet
70
+ * groups: the strokes the sheet shows, and their groups by the sheet's rule. A sheet
71
71
  * without strokes has no crop: it goes to no check (H3). On a task from paper the crop takes in
72
- * `also` too, the tracing paper's rectangle in whole tenths, at the same scale (R87).
72
+ * `also` too, the tracing paper's rectangle in whole tenths, at the same scale.
73
73
  */
74
74
  export declare function cropOf(strokes: readonly Stroke[], groups: readonly Group[], digit?: number, also?: Box): Crop | null;
75
75
  /**
76
- * Where a crop with its margins lies on the sheet, its `sheet_box` (R25): [ymin, xmin, ymax, xmax]
76
+ * Where a crop with its margins lies on the sheet, its `sheet_box`: [ymin, xmin, ymax, xmax]
77
77
  * in units, each one division of two whole numbers, from the whole numbers of the crop. A
78
- * submission's `sheet_box` is checked by it when the tutor's marks come back with it (R26).
78
+ * submission's `sheet_box` is checked by it when the tutor's marks come back with it.
79
79
  */
80
80
  export declare function sheetBoxOf(crop: Pick<Crop, "drawn" | "width" | "height" | "margins" | "exact">): readonly [number, number, number, number];
81
81
  /** What Claude counts an image as: ⌈w / 28⌉ × ⌈h / 28⌉ visual tokens, each a patch 28 px square. */
package/lib/core/crop.js CHANGED
@@ -2,13 +2,13 @@ import RBush from "rbush";
2
2
  import { around, extentOf } from "./geometry.js";
3
3
  import { Sets } from "./sets.js";
4
4
  /**
5
- * The crop's rule in its numbers (R25): sizes on the crop in pixels, heights on the sheet in units.
6
- * The rule counts in whole numbers — places in tenths of a unit, as the groups do (R24) — and each
5
+ * The crop's rule in its numbers: sizes on the crop in pixels, heights on the sheet in units (R25).
6
+ * The rule counts in whole numbers — places in tenths of a unit, as the groups do — and each
7
7
  * number it hands out that is not whole is one division of two whole numbers, so that tutor's
8
8
  * runner, which crops by the same rule, gets the same numbers to the bit.
9
9
  */
10
10
  export const CROP = Object.freeze({
11
- /** The margin around the work, px (R06). */
11
+ /** The margin around the work, px. */
12
12
  margin: 12,
13
13
  /**
14
14
  * A stroke lower than this, in units, is a line, not writing — a dot, a minus, a bar, an
@@ -30,14 +30,14 @@ export const CROP = Object.freeze({
30
30
  digit: 24,
31
31
  /**
32
32
  * The heights of digits a sample's crops are drawn at, px, as the eval protocol names them,
33
- * beside the module's own (R09; R93 spec).
33
+ * beside the module's own.
34
34
  */
35
35
  heights: Object.freeze([16, 24, 32, 48]),
36
36
  /** The tallest digit a crop takes, px: its ink then still stays within the margin. */
37
37
  tallest: 256,
38
38
  });
39
39
  /**
40
- * The bundles of the strokes on a sheet (R25): strokes no lower than `CROP.flat`, joined by a chain
40
+ * The bundles of the strokes on a sheet: strokes no lower than `CROP.flat`, joined by a chain
41
41
  * of boxes that touch or overlap, whenever each was written. Each bundle by its IDs ascending, the
42
42
  * bundles by their smallest ID.
43
43
  */
@@ -46,15 +46,15 @@ export function bundlesOf(strokes) {
46
46
  .map((bundle) => bundle.map(({ id }) => id).sort(byNumber))
47
47
  .sort((a, b) => (a[0] ?? 0) - (b[0] ?? 0));
48
48
  }
49
- /** h_med (R25): the lower median of the heights of the bundles, in units; `CROP.flat` if none. */
49
+ /** h_med: the lower median of the heights of the bundles, in units; `CROP.flat` if none. */
50
50
  export function medianOf(strokes) {
51
51
  return medianTenths(extentsOf(strokes)) / 10;
52
52
  }
53
53
  /**
54
54
  * The crop of the strokes on a sheet with its digits `digit` px high, and the frames of their
55
- * groups (R25): the strokes the sheet shows, and their groups by the sheet's rule (R24). A sheet
55
+ * groups: the strokes the sheet shows, and their groups by the sheet's rule. A sheet
56
56
  * without strokes has no crop: it goes to no check (H3). On a task from paper the crop takes in
57
- * `also` too, the tracing paper's rectangle in whole tenths, at the same scale (R87).
57
+ * `also` too, the tracing paper's rectangle in whole tenths, at the same scale.
58
58
  */
59
59
  export function cropOf(strokes, groups, digit = CROP.digit, also) {
60
60
  if (!Number.isInteger(digit) || digit < 1 || digit > CROP.tallest) {
@@ -108,9 +108,9 @@ export function cropOf(strokes, groups, digit = CROP.digit, also) {
108
108
  };
109
109
  }
110
110
  /**
111
- * Where a crop with its margins lies on the sheet, its `sheet_box` (R25): [ymin, xmin, ymax, xmax]
111
+ * Where a crop with its margins lies on the sheet, its `sheet_box`: [ymin, xmin, ymax, xmax]
112
112
  * in units, each one division of two whole numbers, from the whole numbers of the crop. A
113
- * submission's `sheet_box` is checked by it when the tutor's marks come back with it (R26).
113
+ * submission's `sheet_box` is checked by it when the tutor's marks come back with it.
114
114
  */
115
115
  export function sheetBoxOf(crop) {
116
116
  const { drawn, width, height, margins: [top, left], exact: { box, median: unit }, } = crop;
@@ -4,11 +4,11 @@ import type { Point } from "./screen.js";
4
4
  /** `button` of a pen's eraser, its other end (Pointer Events Level 3). */
5
5
  export declare const ERASER_BUTTON = 5;
6
6
  /**
7
- * The eraser (R22): one press of a pointer takes off the sheet, whole, every stroke its path comes
8
- * near — a tap is a path of one point. The strokes it comes near are pending while it is down, and
9
- * when it lifts they go to the handler the eraser is made with, in one action, with the page's
10
- * time of the lift: one undo brings them all back. `pointercancel` drops the press and erases
11
- * nothing. One pointer erases at a time, with the primary button or a pen's eraser.
7
+ * The eraser: one press of a pointer takes off the sheet, whole, every stroke its path comes
8
+ * near — a tap is a path of one point (R22). The strokes it comes near are pending while it is
9
+ * down, and when it lifts they go to the handler the eraser is made with, in one action, with the
10
+ * page's time of the lift: one undo brings them all back. `pointercancel` drops the press and
11
+ * erases nothing. One pointer erases at a time, with the primary button or a pen's eraser.
12
12
  */
13
13
  export declare class Eraser {
14
14
  #private;
@@ -32,7 +32,7 @@ export declare class Eraser {
32
32
  move(sample: PointerSample, inSight?: boolean): boolean;
33
33
  /** `pointerup`: the eraser goes on to where the pointer left, if in sight, and the press lands. */
34
34
  up(sample: PointerSample, inSight?: boolean): boolean;
35
- /** `pointercancel`: the device took the touch for an accident, and nothing is erased (R05). */
35
+ /** `pointercancel`: the device took the touch for an accident, and nothing is erased. */
36
36
  cancel(pointerId: number): boolean;
37
37
  /**
38
38
  * The press ends where the pointer last was, its `pointerup` never to come: the pointer's capture
@@ -5,11 +5,11 @@ export const ERASER_BUTTON = 5;
5
5
  const ERASER_HELD = 32;
6
6
  const NONE = new Set();
7
7
  /**
8
- * The eraser (R22): one press of a pointer takes off the sheet, whole, every stroke its path comes
9
- * near — a tap is a path of one point. The strokes it comes near are pending while it is down, and
10
- * when it lifts they go to the handler the eraser is made with, in one action, with the page's
11
- * time of the lift: one undo brings them all back. `pointercancel` drops the press and erases
12
- * nothing. One pointer erases at a time, with the primary button or a pen's eraser.
8
+ * The eraser: one press of a pointer takes off the sheet, whole, every stroke its path comes
9
+ * near — a tap is a path of one point (R22). The strokes it comes near are pending while it is
10
+ * down, and when it lifts they go to the handler the eraser is made with, in one action, with the
11
+ * page's time of the lift: one undo brings them all back. `pointercancel` drops the press and
12
+ * erases nothing. One pointer erases at a time, with the primary button or a pen's eraser.
13
13
  */
14
14
  export class Eraser {
15
15
  #near;
@@ -84,7 +84,7 @@ export class Eraser {
84
84
  this.#take(press, { x: sample.x, y: sample.y });
85
85
  return this.#finish(sample.time);
86
86
  }
87
- /** `pointercancel`: the device took the touch for an accident, and nothing is erased (R05). */
87
+ /** `pointercancel`: the device took the touch for an accident, and nothing is erased. */
88
88
  cancel(pointerId) {
89
89
  if (this.#press?.pointerId !== pointerId)
90
90
  return false;
@@ -2,7 +2,7 @@ import type { DemoState } from "@altnovatrail/spec/canvas";
2
2
  import type * as open from "@altnovatrail/spec/formatv0/open";
3
3
  import type { GridKind } from "./grid.js";
4
4
  import { type PicturePart, SHEET_KIND, type StatementPart, type Template, type TextPart, WORKBOOK_KIND, type Zone } from "./task.js";
5
- /** A lesson's worked example as a consumer gives it: spec's type (R73 spec). */
5
+ /** A lesson's worked example as a consumer gives it: spec's type. */
6
6
  export type WorkedExample = open.WorkedExample;
7
7
  /**
8
8
  * What a worked example is shown on, as the element checked it: a handwriting sheet and its grid,
@@ -61,9 +61,9 @@ export interface CheckedExample {
61
61
  readonly demo: readonly ExamplePart[];
62
62
  }
63
63
  /**
64
- * How far the learner has gone through the author's demo (R42): how many of its parts are open,
64
+ * How far the learner has gone through the author's demo: how many of its parts are open,
65
65
  * from the first, and whether the whole demo is hidden. app keeps it and may give it back. spec's
66
- * type (R74 spec).
66
+ * type.
67
67
  */
68
68
  export type { DemoState };
69
69
  /** Where every demo starts: no part open, and nothing hidden. One for every element. */
@@ -76,7 +76,7 @@ export declare const DEMO_START: DemoState;
76
76
  */
77
77
  export declare function exampleOf(value: unknown): CheckedExample;
78
78
  /**
79
- * What the canvas makes of a worked example, as of a task (R42): the grid on the sheet, or the
79
+ * What the canvas makes of a worked example, as of a task: the grid on the sheet, or the
80
80
  * example's lines laid out on the workbook's page as a task's are, its boxes empty till the demo
81
81
  * fills them; the statement above it, and the pen alone, for the learner does not write on it.
82
82
  */
@@ -91,7 +91,7 @@ export declare function filledBy(example: CheckedExample, { opened, hidden }: De
91
91
  /** What a fill of the demo writes: the value of its box, which the check found among the lines. */
92
92
  export declare function fillValue(example: CheckedExample, { fill }: FillPart): string;
93
93
  /**
94
- * The state of a demo of `parts` parts, checked (R42): an object of `opened`, a whole number from 0
94
+ * The state of a demo of `parts` parts, checked: an object of `opened`, a whole number from 0
95
95
  * to `parts`, and `hidden`, true or false, both of them and nothing else. What it refuses is a
96
96
  * TypeError that names the field by its path. It gives a frozen copy of its own.
97
97
  */
@@ -99,7 +99,7 @@ export declare function demoStateOf(value: unknown, parts: number): DemoState;
99
99
  /** Whether a part of the demo stands on the sheet, in an area of it. */
100
100
  export declare function onSheet(part: ExamplePart): part is AreaPicture;
101
101
  /**
102
- * Whether two worked examples show the same (R42): the same statement, the same grid — its kind and
102
+ * Whether two worked examples show the same: the same statement, the same grid — its kind and
103
103
  * step as drawn, the defaults filled in — and the same parts of the demo in the same order.
104
104
  */
105
105
  export declare function sameExample(a: CheckedExample, b: CheckedExample): boolean;
@@ -1,8 +1,8 @@
1
- // A lesson's worked example (R58 spec; R42): the open view of a segment `worked_example`, of spec's
2
- // type WorkedExample (R73 spec; R41) — its statement, the handwriting sheet or the workbook the
1
+ // A lesson's worked example: the open view of a segment `worked_example`, of spec's
2
+ // type WorkedExample — its statement, the handwriting sheet or the workbook the
3
3
  // author's demo is shown on, and the demo's parts in order: paragraphs, pictures beside the sheet,
4
- // pictures on areas of a sheet, and on a workbook the boxes it fills (format 0.4; R61). The
5
- // element checks it as the schema does, every object closed (R32), and by the format's rules
4
+ // pictures on areas of a sheet, and on a workbook the boxes it fills (R42). The
5
+ // element checks it as the schema does, every object closed, and by the format's rules
6
6
  // lesson.areas, lesson.example-fills and lesson.workbook-page too: an area lies on the sheet, the
7
7
  // demo fills each box of the lines once, and the lines fit the page, each value its box. What the
8
8
  // check gives is the element's own shape of the same example, the kinds of its parts apart, which
@@ -19,7 +19,7 @@ export const DEMO_START = Object.freeze({ opened: 0, hidden: false });
19
19
  const ROOT = "workedExample";
20
20
  /** The path the element names the state of a demo's fields by: its property's name. */
21
21
  const STATE = "demoState";
22
- /** A worked example's tools: the pen alone, which writes nothing on its sheet (R42). */
22
+ /** A worked example's tools: the pen alone, which writes nothing on its sheet. */
23
23
  const PEN_ALONE = Object.freeze(["pen"]);
24
24
  /**
25
25
  * A worked example's open view, checked as the format's schema and its rule lesson.areas check it,
@@ -57,7 +57,7 @@ export function exampleOf(value) {
57
57
  return { statement, canvas, lines, demo: fillsOf(parts, lines) };
58
58
  }
59
59
  /**
60
- * What the canvas makes of a worked example, as of a task (R42): the grid on the sheet, or the
60
+ * What the canvas makes of a worked example, as of a task: the grid on the sheet, or the
61
61
  * example's lines laid out on the workbook's page as a task's are, its boxes empty till the demo
62
62
  * fills them; the statement above it, and the pen alone, for the learner does not write on it.
63
63
  */
@@ -95,7 +95,7 @@ function boxesOf(line) {
95
95
  return (line?.line ?? []).filter((piece) => "value" in piece);
96
96
  }
97
97
  /**
98
- * The state of a demo of `parts` parts, checked (R42): an object of `opened`, a whole number from 0
98
+ * The state of a demo of `parts` parts, checked: an object of `opened`, a whole number from 0
99
99
  * to `parts`, and `hidden`, true or false, both of them and nothing else. What it refuses is a
100
100
  * TypeError that names the field by its path. It gives a frozen copy of its own.
101
101
  */
@@ -112,7 +112,7 @@ export function onSheet(part) {
112
112
  return "area" in part;
113
113
  }
114
114
  /**
115
- * Whether two worked examples show the same (R42): the same statement, the same grid — its kind and
115
+ * Whether two worked examples show the same: the same statement, the same grid — its kind and
116
116
  * step as drawn, the defaults filled in — and the same parts of the demo in the same order.
117
117
  */
118
118
  export function sameExample(a, b) {
@@ -137,7 +137,7 @@ function sameLine(a, b) {
137
137
  }
138
138
  /**
139
139
  * What a worked example is shown on: a handwriting sheet and its grid, or a workbook, and no tools,
140
- * for the learner does not write on it (R42).
140
+ * for the learner does not write on it.
141
141
  */
142
142
  function exampleCanvasOf(value, path) {
143
143
  const canvas = closed(value, path, ["kind", "grid", "grid_step"], "a worked example's canvas");
@@ -6,7 +6,7 @@
6
6
  /** The fields of an object; anything else is a TypeError at `path`. */
7
7
  export declare function record(value: unknown, path: string): Record<string, unknown>;
8
8
  /**
9
- * The fields of an object closed as the module format closes its objects (R32), read once into a
9
+ * The fields of an object closed as the module format closes its objects, read once into a
10
10
  * record of their own: a field it does not name is a TypeError at that field's path. A field left
11
11
  * out by `undefined` is no field, and is not in the record.
12
12
  */
@@ -11,7 +11,7 @@ export function record(value, path) {
11
11
  return value;
12
12
  }
13
13
  /**
14
- * The fields of an object closed as the module format closes its objects (R32), read once into a
14
+ * The fields of an object closed as the module format closes its objects, read once into a
15
15
  * record of their own: a field it does not name is a TypeError at that field's path. A field left
16
16
  * out by `undefined` is no field, and is not in the record.
17
17
  */
@@ -1,7 +1,7 @@
1
1
  import type { Stroke } from "./ink.js";
2
2
  import type { Point } from "./screen.js";
3
3
  /**
4
- * A rectangle on the sheet, as rbush takes one (R05): in units, or in tenths of a unit where the
4
+ * A rectangle on the sheet, as rbush takes one: in units, or in tenths of a unit where the
5
5
  * rules count in whole numbers. The contract's Box, spec's, is one in tenths: of a crop's numbers.
6
6
  */
7
7
  export interface Box {
@@ -11,8 +11,8 @@ export interface Box {
11
11
  readonly maxY: number;
12
12
  }
13
13
  /**
14
- * A length or a place in whole tenths of a unit, as a sample file keeps them (R09), rounded half
15
- * up: 100.05 units, 1000.5 tenths, are 1001. The groups and the crop count in them (R24, R25).
14
+ * A length or a place in whole tenths of a unit, as a sample file keeps them, rounded half
15
+ * up: 100.05 units, 1000.5 tenths, are 1001. The groups and the crop count in them.
16
16
  */
17
17
  export declare function tenths(value: number): number;
18
18
  /** A stroke's box in whole tenths, with its ID: what the crop and the boxes' rule count by. */
@@ -20,9 +20,10 @@ export interface Extent extends Box {
20
20
  readonly id: number;
21
21
  }
22
22
  /**
23
- * The box of a stroke's points in whole tenths (R25, R37): rounding keeps order, so its edges are
23
+ * The box of a stroke's points in whole tenths: rounding keeps order, so its edges are
24
24
  * the rounded least and most of the points. A stroke with no points is a TypeError, and one with a
25
- * point off the sheet, or no number, a RangeError: the rules' whole numbers hold on the sheet alone.
25
+ * point off the sheet, or no number, a RangeError: the rules' whole numbers hold on the sheet
26
+ * alone.
26
27
  */
27
28
  export declare function extentOf({ id, points }: Stroke): Extent;
28
29
  /** The box around a stroke's points, the raw points rather than the ink's outline. */
@@ -1,15 +1,16 @@
1
1
  import { REACH } from "./sheet.js";
2
2
  /**
3
- * A length or a place in whole tenths of a unit, as a sample file keeps them (R09), rounded half
4
- * up: 100.05 units, 1000.5 tenths, are 1001. The groups and the crop count in them (R24, R25).
3
+ * A length or a place in whole tenths of a unit, as a sample file keeps them, rounded half
4
+ * up: 100.05 units, 1000.5 tenths, are 1001. The groups and the crop count in them.
5
5
  */
6
6
  export function tenths(value) {
7
7
  return Math.round(value * 10);
8
8
  }
9
9
  /**
10
- * The box of a stroke's points in whole tenths (R25, R37): rounding keeps order, so its edges are
10
+ * The box of a stroke's points in whole tenths: rounding keeps order, so its edges are
11
11
  * the rounded least and most of the points. A stroke with no points is a TypeError, and one with a
12
- * point off the sheet, or no number, a RangeError: the rules' whole numbers hold on the sheet alone.
12
+ * point off the sheet, or no number, a RangeError: the rules' whole numbers hold on the sheet
13
+ * alone.
13
14
  */
14
15
  export function extentOf({ id, points }) {
15
16
  if (points.length === 0)
@@ -88,8 +89,9 @@ function pointDistance(p, a, b) {
88
89
  return Math.hypot(p.x - (a.x + along * dx), p.y - (a.y + along * dy));
89
90
  }
90
91
  /**
91
- * Whether ab and cd cross: each segment's ends lie on either side of the other's line. Segments that
92
- * only touch, or lie along one line, are left to the distances of their ends, which are 0 then.
92
+ * Whether ab and cd cross: each segment's ends lie on either side of the other's line. Segments
93
+ * that only touch, or lie along one line, are left to the distances of their ends, which are 0
94
+ * then.
93
95
  */
94
96
  function crosses(a, b, c, d) {
95
97
  const abc = turn(a, b, c);
@@ -7,7 +7,7 @@ export interface Grid {
7
7
  readonly step: number;
8
8
  }
9
9
  export declare const GRID_KINDS: readonly GridKind[];
10
- /** The step of a grid whose task gives none, in units: canvas-api's square (R06). */
10
+ /** The step of a grid whose task gives none, in units: canvas-api's square. */
11
11
  export declare const GRID_STEP = 50;
12
12
  /**
13
13
  * The steps a task may give, in units. A finer grid would be thousands of dots, and one wider than
@@ -17,7 +17,7 @@ export declare const GRID_STEP_MIN = 20;
17
17
  export declare const GRID_STEP_MAX = 500;
18
18
  /**
19
19
  * The grid of a sheet whose task gives none, or that has no task: squares of 50 units. spec knows
20
- * no sheet without a grid (R23).
20
+ * no sheet without a grid.
21
21
  */
22
22
  export declare const DEFAULT_GRID: Grid;
23
23
  /**
@@ -29,6 +29,6 @@ export declare function gridPath(grid: Grid, size?: Size): string;
29
29
  /**
30
30
  * A grid's path on a band of the sheet across its whole width, from `top` to `bottom` in units,
31
31
  * either of them past the sheet: its rulings at the step's multiples within the band, both ends
32
- * taken, so that they go on from the sheet's own above or below it (R73).
32
+ * taken, so that they go on from the sheet's own above or below it.
33
33
  */
34
34
  export declare function gridBand(grid: Grid, width: number, top: number, bottom: number): string;
package/lib/core/grid.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SHEET } from "./sheet.js";
2
2
  export const GRID_KINDS = ["squares", "lines", "dots"];
3
- /** The step of a grid whose task gives none, in units: canvas-api's square (R06). */
3
+ /** The step of a grid whose task gives none, in units: canvas-api's square. */
4
4
  export const GRID_STEP = 50;
5
5
  /**
6
6
  * The steps a task may give, in units. A finer grid would be thousands of dots, and one wider than
@@ -10,7 +10,7 @@ export const GRID_STEP_MIN = 20;
10
10
  export const GRID_STEP_MAX = 500;
11
11
  /**
12
12
  * The grid of a sheet whose task gives none, or that has no task: squares of 50 units. spec knows
13
- * no sheet without a grid (R23).
13
+ * no sheet without a grid.
14
14
  */
15
15
  export const DEFAULT_GRID = Object.freeze({ kind: "squares", step: GRID_STEP });
16
16
  /**
@@ -48,7 +48,7 @@ function rulings(step, length) {
48
48
  /**
49
49
  * A grid's path on a band of the sheet across its whole width, from `top` to `bottom` in units,
50
50
  * either of them past the sheet: its rulings at the step's multiples within the band, both ends
51
- * taken, so that they go on from the sheet's own above or below it (R73).
51
+ * taken, so that they go on from the sheet's own above or below it.
52
52
  */
53
53
  export function gridBand(grid, width, top, bottom) {
54
54
  const xs = rulings(grid.step, width);
@@ -2,13 +2,13 @@ import type { Group } from "@altnovatrail/spec/canvas";
2
2
  import { type Box } from "./geometry.js";
3
3
  import type { Stroke } from "./ink.js";
4
4
  /**
5
- * The rule of the groups of strokes (R24): two strokes are neighbours if no more than `pause`
5
+ * The rule of the groups of strokes: two strokes are neighbours if no more than `pause`
6
6
  * milliseconds lie between them and their boxes come within `across` sheet units of each other
7
- * across the sheet and within `down` units down it. A group is the strokes a chain of neighbours
8
- * joins. The rule counts in whole numbers — tenths of a unit and milliseconds, the precision of a
9
- * sample file (R09), rounded half up as `Math.round` rounds: 1000.5 tenths are 1001 — and only
10
- * subtracts and compares them, so that tutor's runner, which groups by the same rule, gets the same
11
- * groups to the bit.
7
+ * across the sheet and within `down` units down it (R24). A group is the strokes a chain of
8
+ * neighbours joins. The rule counts in whole numbers — tenths of a unit and milliseconds, the
9
+ * precision of a sample file, rounded half up as `Math.round` rounds: 1000.5 tenths are 1001 — and
10
+ * only subtracts and compares them, so that tutor's runner, which groups by the same rule, gets the
11
+ * same groups to the bit.
12
12
  */
13
13
  export interface GroupRule {
14
14
  /** The longest pause between two neighbours, in milliseconds. */
@@ -19,32 +19,32 @@ export interface GroupRule {
19
19
  readonly down: number;
20
20
  }
21
21
  /**
22
- * The rule the sheet groups by (R24): 2 seconds, the threshold by which studies of writing tell a
22
+ * The rule the sheet groups by: 2 seconds, the threshold by which studies of writing tell a
23
23
  * pause of writing from one of thinking, and a cell of the default grid, across and down.
24
24
  */
25
25
  export declare const GROUP_RULE: GroupRule;
26
26
  /**
27
27
  * A group of the strokes on a sheet: its label, by place, and the IDs of its strokes, in ascending
28
- * order. The labels and the IDs are the table «label → stroke IDs» of one submission (R06). spec's
29
- * type (R74 spec).
28
+ * order. The labels and the IDs are the table «label → stroke IDs» of one submission. spec's
29
+ * type.
30
30
  */
31
31
  export type { Group };
32
32
  /**
33
- * The groups of the strokes on a sheet (R24): the strokes it shows, with the times of their points
33
+ * The groups of the strokes on a sheet: the strokes it shows, with the times of their points
34
34
  * as they were written, in any order. Erased strokes are none of it: whoever groups a history
35
35
  * replays it first, and the groups come from what the sheet shows. Labelled by place, from the top
36
- * down (R09): A, B, … Z, then AA, AB, … — by the top of a group's rectangle, then its left edge.
36
+ * down: A, B, … Z, then AA, AB, … — by the top of a group's rectangle, then its left edge.
37
37
  */
38
38
  export declare function groupsOf(strokes: readonly Stroke[], rule?: GroupRule): Group[];
39
39
  /**
40
- * The pairs of neighbours among the strokes on a sheet, by ID (R24): each pair once, the smaller
40
+ * The pairs of neighbours among the strokes on a sheet, by ID: each pair once, the smaller
41
41
  * ID first, in ascending order. Its groups join these pairs; spec's test vectors give them too, for
42
- * a runner to see where its grouping parts from the sheet's (R94 spec).
42
+ * a runner to see where its grouping parts from the sheet's.
43
43
  */
44
44
  export declare function neighboursOf(strokes: readonly Stroke[], rule?: GroupRule): [number, number][];
45
45
  /**
46
46
  * The rectangle of a group on the sheet: the box around the points of its strokes, in sheet units,
47
- * of the geometry it is given — the raw strokes on the device, the recorded ones in a sample (R09).
47
+ * of the geometry it is given — the raw strokes on the device, the recorded ones in a sample.
48
48
  * Its box in the fractions of a cut-out is the cut-out's.
49
49
  */
50
50
  export declare function rectOf(ids: readonly number[], strokes: readonly Stroke[]): Box;