@altnovatrail/canvas 0.3.39 → 0.3.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/core/boxes.d.ts +7 -7
- package/lib/core/boxes.js +10 -10
- package/lib/core/clock.d.ts +5 -5
- package/lib/core/clock.js +5 -5
- package/lib/core/crop.d.ts +13 -13
- package/lib/core/crop.js +10 -10
- package/lib/core/eraser.d.ts +6 -6
- package/lib/core/eraser.js +6 -6
- package/lib/core/example.d.ts +6 -6
- package/lib/core/example.js +9 -9
- package/lib/core/fields.d.ts +1 -1
- package/lib/core/fields.js +1 -1
- package/lib/core/geometry.d.ts +6 -5
- package/lib/core/geometry.js +8 -6
- package/lib/core/grid.d.ts +3 -3
- package/lib/core/grid.js +3 -3
- package/lib/core/groups.d.ts +14 -14
- package/lib/core/groups.js +6 -6
- package/lib/core/hands.d.ts +19 -18
- package/lib/core/hands.js +16 -15
- package/lib/core/history.d.ts +10 -10
- package/lib/core/history.js +6 -6
- package/lib/core/index.js +8 -9
- package/lib/core/ink.js +3 -3
- package/lib/core/manifest.d.ts +3 -3
- package/lib/core/manifest.js +6 -6
- package/lib/core/marks.d.ts +39 -39
- package/lib/core/marks.js +35 -35
- package/lib/core/notation.d.ts +5 -5
- package/lib/core/outline.d.ts +3 -3
- package/lib/core/outline.js +6 -6
- package/lib/core/page.d.ts +7 -7
- package/lib/core/page.js +10 -10
- package/lib/core/png.d.ts +3 -3
- package/lib/core/png.js +3 -3
- package/lib/core/raster.d.ts +3 -3
- package/lib/core/raster.js +3 -3
- package/lib/core/recorder.d.ts +8 -8
- package/lib/core/recorder.js +8 -8
- package/lib/core/screen.d.ts +2 -2
- package/lib/core/screen.js +1 -1
- package/lib/core/sets.d.ts +1 -1
- package/lib/core/sets.js +1 -1
- package/lib/core/sheet.d.ts +5 -5
- package/lib/core/sheet.js +5 -5
- package/lib/core/submission.d.ts +24 -24
- package/lib/core/submission.js +21 -21
- package/lib/core/task.d.ts +17 -16
- package/lib/core/task.js +14 -13
- package/lib/core/tracing.d.ts +19 -19
- package/lib/core/tracing.js +19 -19
- package/lib/core/widths.d.ts +2 -2
- package/lib/core/widths.js +5 -5
- package/lib/core/work.d.ts +19 -19
- package/lib/core/work.js +22 -22
- package/lib/core/zoom.d.ts +5 -5
- package/lib/core/zoom.js +5 -5
- package/lib/element/icons.d.ts +1 -1
- package/lib/element/icons.js +2 -2
- package/lib/element/index.d.ts +87 -87
- package/lib/element/index.js +286 -283
- package/lib/element/labels.d.ts +17 -17
- package/lib/element/labels.js +7 -8
- package/lib/element/notation.js +1 -1
- package/lib/element/parts.d.ts +2 -2
- package/lib/element/parts.js +6 -6
- package/lib/element/pictures.js +1 -1
- package/lib/element/probe.d.ts +2 -2
- package/lib/element/probe.js +3 -3
- package/lib/element/session.js +2 -2
- package/lib/element/statement.d.ts +2 -2
- package/lib/element/statement.js +6 -6
- package/lib/element/tools.d.ts +17 -18
- package/lib/element/tools.js +30 -29
- package/lib/element/tracing.js +8 -8
- package/package.json +3 -3
package/lib/core/tracing.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import type { Grid } from "./grid.js";
|
|
|
4
4
|
import type { Stroke } from "./ink.js";
|
|
5
5
|
import type { Point } from "./screen.js";
|
|
6
6
|
/**
|
|
7
|
-
* Where the tracing paper of a task from paper lies on the sheet, and whether it is hidden
|
|
8
|
-
* spec's type, of the contract of canvas and app
|
|
7
|
+
* Where the tracing paper of a task from paper lies on the sheet, and whether it is hidden:
|
|
8
|
+
* spec's type, of the contract of canvas and app.
|
|
9
9
|
*/
|
|
10
10
|
export type { TracingState };
|
|
11
11
|
/**
|
|
12
|
-
* The tracing paper's rule
|
|
12
|
+
* The tracing paper's rule, in sheet units: the crop is drawn as large as fits within
|
|
13
13
|
* `width` × `height`, in its own proportions; it starts at `at`, right of the bar of buttons, which
|
|
14
14
|
* stands over the sheet's left edge; the keyboard moves it by `step`, or by `leap` with Shift. The
|
|
15
15
|
* dots of its sheet stand `dots` apart.
|
|
@@ -23,7 +23,7 @@ export declare const TRACING: Readonly<{
|
|
|
23
23
|
dots: 25;
|
|
24
24
|
}>;
|
|
25
25
|
/**
|
|
26
|
-
* The tracing paper's scale
|
|
26
|
+
* The tracing paper's scale: from `min` to `max` times its own size, as the mockup's
|
|
27
27
|
* `Zadacha-masshtab` has it; a button's press multiplies it by `button`, a notch of the wheel by
|
|
28
28
|
* `wheel`, and a scale is kept in hundredths, as the percentage shows it.
|
|
29
29
|
*/
|
|
@@ -33,22 +33,22 @@ export declare const SCALE: Readonly<{
|
|
|
33
33
|
button: 1.2;
|
|
34
34
|
wheel: 1.08;
|
|
35
35
|
}>;
|
|
36
|
-
/** A scale kept to the rule's bounds, in hundredths
|
|
36
|
+
/** A scale kept to the rule's bounds, in hundredths. */
|
|
37
37
|
export declare function scaleOf(scale: number): number;
|
|
38
|
-
/** The scale of a tracing state: 1 where it has none
|
|
38
|
+
/** The scale of a tracing state: 1 where it has none. */
|
|
39
39
|
export declare function scaleIn(state: TracingState): number;
|
|
40
40
|
/** A size as large as `scale` makes it. */
|
|
41
41
|
export declare function scaled(size: Size, scale: number): Size;
|
|
42
42
|
/**
|
|
43
43
|
* The grids of a task from paper's sheet in the order its button turns them, round, the first as
|
|
44
|
-
* the task comes
|
|
44
|
+
* the task comes.
|
|
45
45
|
*/
|
|
46
46
|
export declare const PAPER_GRIDS: readonly PaperGrid[];
|
|
47
47
|
/** Whether a value is a grid of a task from paper's sheet. */
|
|
48
48
|
export declare function isPaperGrid(value: unknown): value is PaperGrid;
|
|
49
|
-
/** The rulings of a task from paper's grid, or none for a blank sheet
|
|
49
|
+
/** The rulings of a task from paper's grid, or none for a blank sheet. */
|
|
50
50
|
export declare function rulingsOf(grid: PaperGrid): Grid | undefined;
|
|
51
|
-
/** The grid the button turns a task from paper's grid to: the next, round
|
|
51
|
+
/** The grid the button turns a task from paper's grid to: the next, round. */
|
|
52
52
|
export declare function nextGrid(grid: PaperGrid): PaperGrid;
|
|
53
53
|
/** The tracing paper's size on the sheet, in units. */
|
|
54
54
|
export interface Size {
|
|
@@ -58,14 +58,14 @@ export interface Size {
|
|
|
58
58
|
/** The size before the crop's picture is read: the largest the tracing paper may be. */
|
|
59
59
|
export declare const LARGEST: Size;
|
|
60
60
|
/**
|
|
61
|
-
* The tracing paper's size for a crop `width` × `height` px
|
|
61
|
+
* The tracing paper's size for a crop `width` × `height` px: as large as fits within the
|
|
62
62
|
* rule's box, in the crop's proportions. A picture of no size has the largest.
|
|
63
63
|
*/
|
|
64
64
|
export declare function sizeOf(width: number, height: number): Size;
|
|
65
65
|
/** Where a task from paper starts its tracing paper: at the rule's place, shown. */
|
|
66
66
|
export declare const TRACING_START: TracingState;
|
|
67
67
|
/**
|
|
68
|
-
* A tracing state a consumer gives
|
|
68
|
+
* A tracing state a consumer gives, checked and frozen: an object of `at`, [x, y] in
|
|
69
69
|
* units, finite numbers, `hidden`, true or false, and `scale`, if any, from 0.4 to 4; other fields
|
|
70
70
|
* are passed over. A state that puts the tracing paper of `size` at its scale wholly off the sheet
|
|
71
71
|
* is a TypeError, as is anything else that is not such a state.
|
|
@@ -81,7 +81,7 @@ export declare function tracingFieldsOf(value: unknown, path: string): TracingSt
|
|
|
81
81
|
/** Whether the tracing paper of `size` at `at` lies wholly off the sheet, touching it at most. */
|
|
82
82
|
export declare function whollyOff(at: readonly [number, number], size: Size): boolean;
|
|
83
83
|
/**
|
|
84
|
-
* A reading of the statement a consumer gives
|
|
84
|
+
* A reading of the statement a consumer gives, checked and frozen: `state` "ready" or
|
|
85
85
|
* "busy", or "done" with `statements`, from none to 20 strings; other fields are passed over.
|
|
86
86
|
* Anything else is a TypeError.
|
|
87
87
|
*/
|
|
@@ -92,20 +92,20 @@ export declare function sameTracing(a: TracingState, b: TracingState): boolean;
|
|
|
92
92
|
export declare function rectOf(at: readonly [number, number], size: Size): Box;
|
|
93
93
|
/**
|
|
94
94
|
* The place nearest `at` where the tracing paper of `size` lies wholly on the sheet: where the
|
|
95
|
-
* learner's grip and keys leave it
|
|
95
|
+
* learner's grip and keys leave it.
|
|
96
96
|
*/
|
|
97
97
|
export declare function keptOn(at: readonly [number, number], size: Size): readonly [number, number];
|
|
98
98
|
/** Whether a point of the sheet lies on the tracing paper, its edges too. */
|
|
99
99
|
export declare function onTracing(point: Point, at: readonly [number, number], size: Size): boolean;
|
|
100
100
|
/**
|
|
101
101
|
* A point of the sheet as a stroke on the tracing paper of `size` at `scale` holds it: from the
|
|
102
|
-
* paper's top left corner, in its own units, kept to the paper
|
|
102
|
+
* paper's top left corner, in its own units, kept to the paper.
|
|
103
103
|
*/
|
|
104
104
|
export declare function toTracing(point: Point, at: readonly [number, number], size: Size, scale?: number): Point;
|
|
105
105
|
/**
|
|
106
106
|
* A stroke of the tracing paper where it lies on the sheet: its points scaled by `scale` and moved
|
|
107
|
-
* by `at`, and kept to the sheet, should the paper lie in part beyond it — the rules of the groups
|
|
108
|
-
* the sheet alone
|
|
107
|
+
* by `at`, and kept to the sheet, should the paper lie in part beyond it — the rules of the groups
|
|
108
|
+
* and the crop hold on the sheet alone. The same ID, kind and times.
|
|
109
109
|
*/
|
|
110
110
|
export declare function onSheet(stroke: Stroke, at: readonly [number, number], scale?: number): Stroke;
|
|
111
111
|
/**
|
|
@@ -115,7 +115,7 @@ export declare function onSheet(stroke: Stroke, at: readonly [number, number], s
|
|
|
115
115
|
*/
|
|
116
116
|
export declare function boxOnSheet(box: Box, at: readonly [number, number], scale?: number): Box;
|
|
117
117
|
/**
|
|
118
|
-
* The tracing paper's rectangle on the sheet in whole tenths of a unit, as the crop counts
|
|
118
|
+
* The tracing paper's rectangle on the sheet in whole tenths of a unit, as the crop counts,
|
|
119
119
|
* kept to the sheet: the part of it a crop of the work takes in.
|
|
120
120
|
*/
|
|
121
121
|
export declare function tenthsOf(rect: Box): Box;
|
|
@@ -127,11 +127,11 @@ export interface Gray {
|
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* The grey of a picture's pixels, four bytes each — red, green, blue and alpha — as a canvas reads
|
|
130
|
-
* them: the luma of BT.601 in whole numbers, over white where a pixel is transparent
|
|
130
|
+
* them: the luma of BT.601 in whole numbers, over white where a pixel is transparent.
|
|
131
131
|
*/
|
|
132
132
|
export declare function grayOf(rgba: Uint8ClampedArray | Uint8Array, width: number, height: number): Gray;
|
|
133
133
|
/**
|
|
134
|
-
* The crop's picture laid into the pixels of a crop of the work
|
|
134
|
+
* The crop's picture laid into the pixels of a crop of the work, multiplied, as the screen
|
|
135
135
|
* lays the tracing paper over the sheet: `ink` the crop's pixels, `width` px wide, and `rect`
|
|
136
136
|
* where the tracing paper lies on them, in px, which may reach beyond them. Each pixel of the crop
|
|
137
137
|
* under the paper takes the mean of the picture's pixels whose centres fall within it, or the one
|
package/lib/core/tracing.js
CHANGED
|
@@ -2,7 +2,7 @@ import { record, shown } from "./fields.js";
|
|
|
2
2
|
import { tenths } from "./geometry.js";
|
|
3
3
|
import { REACH } from "./sheet.js";
|
|
4
4
|
/**
|
|
5
|
-
* The tracing paper's rule
|
|
5
|
+
* The tracing paper's rule, in sheet units: the crop is drawn as large as fits within
|
|
6
6
|
* `width` × `height`, in its own proportions; it starts at `at`, right of the bar of buttons, which
|
|
7
7
|
* stands over the sheet's left edge; the keyboard moves it by `step`, or by `leap` with Shift. The
|
|
8
8
|
* dots of its sheet stand `dots` apart.
|
|
@@ -16,16 +16,16 @@ export const TRACING = Object.freeze({
|
|
|
16
16
|
dots: 25,
|
|
17
17
|
});
|
|
18
18
|
/**
|
|
19
|
-
* The tracing paper's scale
|
|
19
|
+
* The tracing paper's scale: from `min` to `max` times its own size, as the mockup's
|
|
20
20
|
* `Zadacha-masshtab` has it; a button's press multiplies it by `button`, a notch of the wheel by
|
|
21
21
|
* `wheel`, and a scale is kept in hundredths, as the percentage shows it.
|
|
22
22
|
*/
|
|
23
23
|
export const SCALE = Object.freeze({ min: 0.4, max: 4, button: 1.2, wheel: 1.08 });
|
|
24
|
-
/** A scale kept to the rule's bounds, in hundredths
|
|
24
|
+
/** A scale kept to the rule's bounds, in hundredths. */
|
|
25
25
|
export function scaleOf(scale) {
|
|
26
26
|
return Math.round(clamp(scale, SCALE.min, SCALE.max) * 100) / 100;
|
|
27
27
|
}
|
|
28
|
-
/** The scale of a tracing state: 1 where it has none
|
|
28
|
+
/** The scale of a tracing state: 1 where it has none. */
|
|
29
29
|
export function scaleIn(state) {
|
|
30
30
|
return state.scale ?? 1;
|
|
31
31
|
}
|
|
@@ -35,7 +35,7 @@ export function scaled(size, scale) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* The grids of a task from paper's sheet in the order its button turns them, round, the first as
|
|
38
|
-
* the task comes
|
|
38
|
+
* the task comes.
|
|
39
39
|
*/
|
|
40
40
|
export const PAPER_GRIDS = Object.freeze([
|
|
41
41
|
"dots",
|
|
@@ -43,7 +43,7 @@ export const PAPER_GRIDS = Object.freeze([
|
|
|
43
43
|
"blank",
|
|
44
44
|
"squares",
|
|
45
45
|
]);
|
|
46
|
-
/** Each grid's rulings, in sheet units, as the mockup draws them: a blank sheet has none
|
|
46
|
+
/** Each grid's rulings, in sheet units, as the mockup draws them: a blank sheet has none. */
|
|
47
47
|
const RULINGS = Object.freeze({
|
|
48
48
|
dots: Object.freeze({ kind: "dots", step: TRACING.dots }),
|
|
49
49
|
lines: Object.freeze({ kind: "lines", step: 40 }),
|
|
@@ -54,18 +54,18 @@ const RULINGS = Object.freeze({
|
|
|
54
54
|
export function isPaperGrid(value) {
|
|
55
55
|
return typeof value === "string" && PAPER_GRIDS.includes(value);
|
|
56
56
|
}
|
|
57
|
-
/** The rulings of a task from paper's grid, or none for a blank sheet
|
|
57
|
+
/** The rulings of a task from paper's grid, or none for a blank sheet. */
|
|
58
58
|
export function rulingsOf(grid) {
|
|
59
59
|
return RULINGS[grid];
|
|
60
60
|
}
|
|
61
|
-
/** The grid the button turns a task from paper's grid to: the next, round
|
|
61
|
+
/** The grid the button turns a task from paper's grid to: the next, round. */
|
|
62
62
|
export function nextGrid(grid) {
|
|
63
63
|
return PAPER_GRIDS[(PAPER_GRIDS.indexOf(grid) + 1) % PAPER_GRIDS.length];
|
|
64
64
|
}
|
|
65
65
|
/** The size before the crop's picture is read: the largest the tracing paper may be. */
|
|
66
66
|
export const LARGEST = Object.freeze({ width: TRACING.width, height: TRACING.height });
|
|
67
67
|
/**
|
|
68
|
-
* The tracing paper's size for a crop `width` × `height` px
|
|
68
|
+
* The tracing paper's size for a crop `width` × `height` px: as large as fits within the
|
|
69
69
|
* rule's box, in the crop's proportions. A picture of no size has the largest.
|
|
70
70
|
*/
|
|
71
71
|
export function sizeOf(width, height) {
|
|
@@ -81,7 +81,7 @@ export const TRACING_START = Object.freeze({
|
|
|
81
81
|
scale: 1,
|
|
82
82
|
});
|
|
83
83
|
/**
|
|
84
|
-
* A tracing state a consumer gives
|
|
84
|
+
* A tracing state a consumer gives, checked and frozen: an object of `at`, [x, y] in
|
|
85
85
|
* units, finite numbers, `hidden`, true or false, and `scale`, if any, from 0.4 to 4; other fields
|
|
86
86
|
* are passed over. A state that puts the tracing paper of `size` at its scale wholly off the sheet
|
|
87
87
|
* is a TypeError, as is anything else that is not such a state.
|
|
@@ -125,10 +125,10 @@ export function whollyOff(at, size) {
|
|
|
125
125
|
const [x, y] = at;
|
|
126
126
|
return x >= REACH.width || y >= REACH.height || x + size.width <= 0 || y + size.height <= 0;
|
|
127
127
|
}
|
|
128
|
-
/** The most statements a reading holds, as the attempt's tasks are
|
|
128
|
+
/** The most statements a reading holds, as the attempt's tasks are. */
|
|
129
129
|
const STATEMENTS = 20;
|
|
130
130
|
/**
|
|
131
|
-
* A reading of the statement a consumer gives
|
|
131
|
+
* A reading of the statement a consumer gives, checked and frozen: `state` "ready" or
|
|
132
132
|
* "busy", or "done" with `statements`, from none to 20 strings; other fields are passed over.
|
|
133
133
|
* Anything else is a TypeError.
|
|
134
134
|
*/
|
|
@@ -158,7 +158,7 @@ export function rectOf(at, size) {
|
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* The place nearest `at` where the tracing paper of `size` lies wholly on the sheet: where the
|
|
161
|
-
* learner's grip and keys leave it
|
|
161
|
+
* learner's grip and keys leave it.
|
|
162
162
|
*/
|
|
163
163
|
export function keptOn(at, size) {
|
|
164
164
|
return Object.freeze([
|
|
@@ -173,7 +173,7 @@ export function onTracing(point, at, size) {
|
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* A point of the sheet as a stroke on the tracing paper of `size` at `scale` holds it: from the
|
|
176
|
-
* paper's top left corner, in its own units, kept to the paper
|
|
176
|
+
* paper's top left corner, in its own units, kept to the paper.
|
|
177
177
|
*/
|
|
178
178
|
export function toTracing(point, at, size, scale = 1) {
|
|
179
179
|
return {
|
|
@@ -183,8 +183,8 @@ export function toTracing(point, at, size, scale = 1) {
|
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* A stroke of the tracing paper where it lies on the sheet: its points scaled by `scale` and moved
|
|
186
|
-
* by `at`, and kept to the sheet, should the paper lie in part beyond it — the rules of the groups
|
|
187
|
-
* the sheet alone
|
|
186
|
+
* by `at`, and kept to the sheet, should the paper lie in part beyond it — the rules of the groups
|
|
187
|
+
* and the crop hold on the sheet alone. The same ID, kind and times.
|
|
188
188
|
*/
|
|
189
189
|
export function onSheet(stroke, at, scale = 1) {
|
|
190
190
|
return Object.freeze({
|
|
@@ -212,7 +212,7 @@ export function boxOnSheet(box, at, scale = 1) {
|
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
|
-
* The tracing paper's rectangle on the sheet in whole tenths of a unit, as the crop counts
|
|
215
|
+
* The tracing paper's rectangle on the sheet in whole tenths of a unit, as the crop counts,
|
|
216
216
|
* kept to the sheet: the part of it a crop of the work takes in.
|
|
217
217
|
*/
|
|
218
218
|
export function tenthsOf(rect) {
|
|
@@ -225,7 +225,7 @@ export function tenthsOf(rect) {
|
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
227
|
* The grey of a picture's pixels, four bytes each — red, green, blue and alpha — as a canvas reads
|
|
228
|
-
* them: the luma of BT.601 in whole numbers, over white where a pixel is transparent
|
|
228
|
+
* them: the luma of BT.601 in whole numbers, over white where a pixel is transparent.
|
|
229
229
|
*/
|
|
230
230
|
export function grayOf(rgba, width, height) {
|
|
231
231
|
if (rgba.length !== 4 * width * height) {
|
|
@@ -243,7 +243,7 @@ export function grayOf(rgba, width, height) {
|
|
|
243
243
|
return { gray, width, height };
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
|
-
* The crop's picture laid into the pixels of a crop of the work
|
|
246
|
+
* The crop's picture laid into the pixels of a crop of the work, multiplied, as the screen
|
|
247
247
|
* lays the tracing paper over the sheet: `ink` the crop's pixels, `width` px wide, and `rect`
|
|
248
248
|
* where the tracing paper lies on them, in px, which may reach beyond them. Each pixel of the crop
|
|
249
249
|
* under the paper takes the mean of the picture's pixels whose centres fall within it, or the one
|
package/lib/core/widths.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** A digit: they are all as wide, and the page asks for figures of one width
|
|
1
|
+
/** A digit: they are all as wide, and the page asks for figures of one width. */
|
|
2
2
|
export declare const DIGIT = 53;
|
|
3
3
|
/** A sign of an operation or a comparison: one width for all of them, the mean of theirs. */
|
|
4
4
|
export declare const SIGN = 56;
|
|
5
|
-
/** The signs of operations and comparisons, one width for all
|
|
5
|
+
/** The signs of operations and comparisons, one width for all. */
|
|
6
6
|
export declare const SIGNS = "+\u2212\u00D7\u00F7=<>\u2264\u2265\u2260\u00B1\u2248";
|
|
7
7
|
/** The space between two words, which the layout sets itself. */
|
|
8
8
|
export declare const SPACE = 26;
|
package/lib/core/widths.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// The width table of the workbook's layout
|
|
1
|
+
// The width table of the workbook's layout: how wide each character of a line is, in whole
|
|
2
2
|
// hundredths of the type size, so that the layout puts the boxes where it puts them on any device,
|
|
3
|
-
// whatever its fonts, and the text is fitted to its width by SVG
|
|
3
|
+
// whatever its fonts, and the text is fitted to its width by SVG. The numbers are the
|
|
4
4
|
// canvas's own: each the mean of Liberation Sans and Liberation Serif, the fonts of the image the
|
|
5
5
|
// tests run in, rounded to a hundredth — no font's table. Which character is which comes from
|
|
6
6
|
// explicit ranges of code points alone, never from the engine's Unicode tables — no `\p{…}`, no
|
|
7
7
|
// `\s`, no `Intl.Segmenter` — for those follow each engine's version of Unicode, and the layout
|
|
8
|
-
// must be the same in every engine and in Node, as the crop is
|
|
9
|
-
/** A digit: they are all as wide, and the page asks for figures of one width
|
|
8
|
+
// must be the same in every engine and in Node, as the crop is.
|
|
9
|
+
/** A digit: they are all as wide, and the page asks for figures of one width. */
|
|
10
10
|
export const DIGIT = 53;
|
|
11
11
|
/** A sign of an operation or a comparison: one width for all of them, the mean of theirs. */
|
|
12
12
|
export const SIGN = 56;
|
|
13
|
-
/** The signs of operations and comparisons, one width for all
|
|
13
|
+
/** The signs of operations and comparisons, one width for all. */
|
|
14
14
|
export const SIGNS = "+−×÷=<>≤≥≠±≈";
|
|
15
15
|
/** The space between two words, which the layout sets itself. */
|
|
16
16
|
export const SPACE = 26;
|
package/lib/core/work.d.ts
CHANGED
|
@@ -4,25 +4,25 @@ import type { Stroke } from "./ink.js";
|
|
|
4
4
|
import type { Point } from "./screen.js";
|
|
5
5
|
/**
|
|
6
6
|
* The work on the sheet: the strokes in sight, the stack of the actions that undo takes back, the
|
|
7
|
-
* last first
|
|
8
|
-
*
|
|
7
|
+
* last first, and the history of writing, every action as an event at the sheet's time.
|
|
8
|
+
* Clearing and erasing are actions too, so undo brings their strokes back. Nothing is
|
|
9
9
|
* redone. The times its methods take are the page's, and the sheet's clock turns one into the
|
|
10
10
|
* sheet's time only when the action lands: an undo that has nothing to take back is no event. A
|
|
11
|
-
* history given to the sheet is replayed by the same rules, each action at its own time
|
|
11
|
+
* history given to the sheet is replayed by the same rules, each action at its own time.
|
|
12
12
|
*/
|
|
13
13
|
export declare class Work {
|
|
14
14
|
#private;
|
|
15
15
|
constructor(clock?: Clock);
|
|
16
16
|
/**
|
|
17
|
-
* The work a history of writing given to the sheet leaves
|
|
17
|
+
* The work a history of writing given to the sheet leaves: its strokes, its stack of
|
|
18
18
|
* actions for undo and the history itself, in frozen objects of the work's own. The events are
|
|
19
|
-
* checked as `historyOf` checks them, then replayed by the work's own rules, each at its own
|
|
20
|
-
* and each must be what the work records for it: an erasing takes off strokes on the sheet,
|
|
21
|
-
* the sheet's order; a clearing clears a sheet with strokes, all of them; an undo takes back
|
|
22
|
-
* last action still in force and says what the stack says. A history the sheet could not have
|
|
19
|
+
* checked as `historyOf` checks them, then replayed by the work's own rules, each at its own
|
|
20
|
+
* time, and each must be what the work records for it: an erasing takes off strokes on the sheet,
|
|
21
|
+
* in the sheet's order; a clearing clears a sheet with strokes, all of them; an undo takes back
|
|
22
|
+
* the last action still in force and says what the stack says. A history the sheet could not have
|
|
23
23
|
* written is a TypeError that names the event. The clock is not asked: it goes on as the sheet
|
|
24
|
-
* that takes the work tells it (`Clock.resume`). On a task from paper, `paper`, a stroke may
|
|
25
|
-
*
|
|
24
|
+
* that takes the work tells it (`Clock.resume`). On a task from paper, `paper`, a stroke may be
|
|
25
|
+
* the tracing paper's.
|
|
26
26
|
*/
|
|
27
27
|
static restore(value: unknown, clock: Clock, paper?: boolean): Work;
|
|
28
28
|
/**
|
|
@@ -31,13 +31,13 @@ export declare class Work {
|
|
|
31
31
|
*/
|
|
32
32
|
get strokes(): readonly Stroke[];
|
|
33
33
|
/**
|
|
34
|
-
* Whether undo has an action to take back
|
|
35
|
-
* button stands unavailable while it is
|
|
34
|
+
* Whether undo has an action to take back: the stack is not empty. The element's Undo
|
|
35
|
+
* button stands unavailable while it is.
|
|
36
36
|
*/
|
|
37
37
|
get undoable(): boolean;
|
|
38
38
|
/**
|
|
39
39
|
* Whether a stroke of this ID was written on the tracing paper of a task from paper, its points
|
|
40
|
-
* from the paper's corner
|
|
40
|
+
* from the paper's corner.
|
|
41
41
|
*/
|
|
42
42
|
onTracing(id: number): boolean;
|
|
43
43
|
/** Whether any stroke was written on the tracing paper, erased or not. */
|
|
@@ -53,7 +53,7 @@ export declare class Work {
|
|
|
53
53
|
* than a longer one, for an array once handed out never changes: a clearing keeps the one it
|
|
54
54
|
* cleared, and whoever read `strokes` keeps what they read. It lands at the sheet's latest time:
|
|
55
55
|
* its last point's, unless an action landed while it was under way and it ended without its
|
|
56
|
-
* pointerup, its last point earlier. A stroke on the tracing paper says so, `on
|
|
56
|
+
* pointerup, its last point earlier. A stroke on the tracing paper says so, `on`.
|
|
57
57
|
*/
|
|
58
58
|
write(stroke: Stroke, on?: "tracing"): void;
|
|
59
59
|
/**
|
|
@@ -71,17 +71,17 @@ export declare class Work {
|
|
|
71
71
|
/**
|
|
72
72
|
* The strokes on the sheet whose line comes within `reach` of the segment from `from` to `to`, in
|
|
73
73
|
* sheet units: the index finds those whose box is near enough, and the distance to each segment
|
|
74
|
-
* of their points decides
|
|
74
|
+
* of their points decides. A segment whose ends are one point is that point. On a task from
|
|
75
75
|
* paper an erasing takes the strokes of one layer alone, `layer`: the tracing paper's, its
|
|
76
|
-
* points from its corner, or the sheet's
|
|
76
|
+
* points from its corner, or the sheet's.
|
|
77
77
|
*/
|
|
78
78
|
near(from: Point, to: Point, reach: number, layer?: "tracing" | "sheet"): Stroke[];
|
|
79
79
|
}
|
|
80
|
-
/** The ID the next stroke takes after a history
|
|
80
|
+
/** The ID the next stroke takes after a history: one past the highest written, or 1. */
|
|
81
81
|
export declare function nextIdOf(history: readonly HistoryEvent[]): number;
|
|
82
82
|
/**
|
|
83
|
-
* Where the sheet's clock goes on after a history given to it
|
|
84
|
-
* than the pause of the groups
|
|
83
|
+
* Where the sheet's clock goes on after a history given to it: past its last event by more
|
|
84
|
+
* than the pause of the groups, so that the first stroke after it is no neighbour of its
|
|
85
85
|
* strokes; at 0 after an empty history, which is a new sheet's.
|
|
86
86
|
*/
|
|
87
87
|
export declare function resumeOf(history: readonly HistoryEvent[]): number;
|
package/lib/core/work.js
CHANGED
|
@@ -6,11 +6,11 @@ import { GROUP_RULE } from "./groups.js";
|
|
|
6
6
|
import { frozen, historyOf, sameEvent } from "./history.js";
|
|
7
7
|
/**
|
|
8
8
|
* The work on the sheet: the strokes in sight, the stack of the actions that undo takes back, the
|
|
9
|
-
* last first
|
|
10
|
-
*
|
|
9
|
+
* last first, and the history of writing, every action as an event at the sheet's time.
|
|
10
|
+
* Clearing and erasing are actions too, so undo brings their strokes back. Nothing is
|
|
11
11
|
* redone. The times its methods take are the page's, and the sheet's clock turns one into the
|
|
12
12
|
* sheet's time only when the action lands: an undo that has nothing to take back is no event. A
|
|
13
|
-
* history given to the sheet is replayed by the same rules, each action at its own time
|
|
13
|
+
* history given to the sheet is replayed by the same rules, each action at its own time.
|
|
14
14
|
*/
|
|
15
15
|
export class Work {
|
|
16
16
|
#clock;
|
|
@@ -28,21 +28,21 @@ export class Work {
|
|
|
28
28
|
#index = new RBush();
|
|
29
29
|
#indexed = this.#strokes;
|
|
30
30
|
#entries = new WeakMap();
|
|
31
|
-
/** The IDs of the strokes written on the tracing paper of a task from paper
|
|
31
|
+
/** The IDs of the strokes written on the tracing paper of a task from paper. */
|
|
32
32
|
#tracing = new Set();
|
|
33
33
|
constructor(clock = new Clock()) {
|
|
34
34
|
this.#clock = clock;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* The work a history of writing given to the sheet leaves
|
|
37
|
+
* The work a history of writing given to the sheet leaves: its strokes, its stack of
|
|
38
38
|
* actions for undo and the history itself, in frozen objects of the work's own. The events are
|
|
39
|
-
* checked as `historyOf` checks them, then replayed by the work's own rules, each at its own
|
|
40
|
-
* and each must be what the work records for it: an erasing takes off strokes on the sheet,
|
|
41
|
-
* the sheet's order; a clearing clears a sheet with strokes, all of them; an undo takes back
|
|
42
|
-
* last action still in force and says what the stack says. A history the sheet could not have
|
|
39
|
+
* checked as `historyOf` checks them, then replayed by the work's own rules, each at its own
|
|
40
|
+
* time, and each must be what the work records for it: an erasing takes off strokes on the sheet,
|
|
41
|
+
* in the sheet's order; a clearing clears a sheet with strokes, all of them; an undo takes back
|
|
42
|
+
* the last action still in force and says what the stack says. A history the sheet could not have
|
|
43
43
|
* written is a TypeError that names the event. The clock is not asked: it goes on as the sheet
|
|
44
|
-
* that takes the work tells it (`Clock.resume`). On a task from paper, `paper`, a stroke may
|
|
45
|
-
*
|
|
44
|
+
* that takes the work tells it (`Clock.resume`). On a task from paper, `paper`, a stroke may be
|
|
45
|
+
* the tracing paper's.
|
|
46
46
|
*/
|
|
47
47
|
static restore(value, clock, paper = false) {
|
|
48
48
|
const work = new Work(clock);
|
|
@@ -63,15 +63,15 @@ export class Work {
|
|
|
63
63
|
return this.#strokes;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Whether undo has an action to take back
|
|
67
|
-
* button stands unavailable while it is
|
|
66
|
+
* Whether undo has an action to take back: the stack is not empty. The element's Undo
|
|
67
|
+
* button stands unavailable while it is.
|
|
68
68
|
*/
|
|
69
69
|
get undoable() {
|
|
70
70
|
return this.#done.length > 0;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Whether a stroke of this ID was written on the tracing paper of a task from paper, its points
|
|
74
|
-
* from the paper's corner
|
|
74
|
+
* from the paper's corner.
|
|
75
75
|
*/
|
|
76
76
|
onTracing(id) {
|
|
77
77
|
return this.#tracing.has(id);
|
|
@@ -94,7 +94,7 @@ export class Work {
|
|
|
94
94
|
* than a longer one, for an array once handed out never changes: a clearing keeps the one it
|
|
95
95
|
* cleared, and whoever read `strokes` keeps what they read. It lands at the sheet's latest time:
|
|
96
96
|
* its last point's, unless an action landed while it was under way and it ended without its
|
|
97
|
-
* pointerup, its last point earlier. A stroke on the tracing paper says so, `on
|
|
97
|
+
* pointerup, its last point earlier. A stroke on the tracing paper says so, `on`.
|
|
98
98
|
*/
|
|
99
99
|
write(stroke, on) {
|
|
100
100
|
this.#write(stroke, Math.max(this.#clock.latest, stroke.points.at(-1)?.t ?? 0), on);
|
|
@@ -120,9 +120,9 @@ export class Work {
|
|
|
120
120
|
/**
|
|
121
121
|
* The strokes on the sheet whose line comes within `reach` of the segment from `from` to `to`, in
|
|
122
122
|
* sheet units: the index finds those whose box is near enough, and the distance to each segment
|
|
123
|
-
* of their points decides
|
|
123
|
+
* of their points decides. A segment whose ends are one point is that point. On a task from
|
|
124
124
|
* paper an erasing takes the strokes of one layer alone, `layer`: the tracing paper's, its
|
|
125
|
-
* points from its corner, or the sheet's
|
|
125
|
+
* points from its corner, or the sheet's.
|
|
126
126
|
*/
|
|
127
127
|
near(from, to, reach, layer) {
|
|
128
128
|
const hits = [];
|
|
@@ -137,8 +137,8 @@ export class Work {
|
|
|
137
137
|
// The actions, each with the sheet's time it lands at, asked for only once it does.
|
|
138
138
|
#write(stroke, t, on) {
|
|
139
139
|
// A history replayed writes its strokes one after another, without a copy of the sheet for
|
|
140
|
-
// each: thousands of strokes would copy the sheet thousands of times. A clearing keeps the
|
|
141
|
-
// it cleared and leaves the sheet a new one, so no array an action keeps grows by it.
|
|
140
|
+
// each: thousands of strokes would copy the sheet thousands of times. A clearing keeps the
|
|
141
|
+
// array it cleared and leaves the sheet a new one, so no array an action keeps grows by it.
|
|
142
142
|
if (this.#replaying)
|
|
143
143
|
this.#strokes.push(stroke);
|
|
144
144
|
else
|
|
@@ -246,7 +246,7 @@ export class Work {
|
|
|
246
246
|
return entry;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
/** The ID the next stroke takes after a history
|
|
249
|
+
/** The ID the next stroke takes after a history: one past the highest written, or 1. */
|
|
250
250
|
export function nextIdOf(history) {
|
|
251
251
|
let highest = 0;
|
|
252
252
|
for (const event of history) {
|
|
@@ -256,8 +256,8 @@ export function nextIdOf(history) {
|
|
|
256
256
|
return highest + 1;
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
|
-
* Where the sheet's clock goes on after a history given to it
|
|
260
|
-
* than the pause of the groups
|
|
259
|
+
* Where the sheet's clock goes on after a history given to it: past its last event by more
|
|
260
|
+
* than the pause of the groups, so that the first stroke after it is no neighbour of its
|
|
261
261
|
* strokes; at 0 after an empty history, which is a new sheet's.
|
|
262
262
|
*/
|
|
263
263
|
export function resumeOf(history) {
|
package/lib/core/zoom.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** The smallest and the largest zoom of the sheet: half its fit, and twice it
|
|
1
|
+
/** The smallest and the largest zoom of the sheet: half its fit, and twice it. */
|
|
2
2
|
export declare const ZOOM_MIN = 0.5;
|
|
3
3
|
export declare const ZOOM_MAX = 2;
|
|
4
4
|
/**
|
|
5
|
-
* The step of Zoom in and Zoom out, a quarter of the fit
|
|
5
|
+
* The step of Zoom in and Zoom out, a quarter of the fit: from any zoom a pinch left, a
|
|
6
6
|
* press goes to the next quarter, so 50, 75, … 200 % are where the buttons stop.
|
|
7
7
|
*/
|
|
8
8
|
export declare const ZOOM_STEP = 0.25;
|
|
@@ -14,8 +14,8 @@ export declare function clampZoom(value: number): number;
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function stepZoom(value: number, larger: boolean): number;
|
|
16
16
|
/**
|
|
17
|
-
* The page's zoom
|
|
18
|
-
* the pen mode is
|
|
17
|
+
* The page's zoom: one for every sheet of the page, from 100 % when the page is loaded, as
|
|
18
|
+
* the pen mode is. The next task is a new element, and the zoom stays: a learner who
|
|
19
19
|
* needs it larger or smaller asks once. It lives in memory alone: nothing is stored or sent.
|
|
20
20
|
*/
|
|
21
21
|
export declare class PageZoom {
|
|
@@ -25,7 +25,7 @@ export declare class PageZoom {
|
|
|
25
25
|
/** Whether there is a larger zoom to go to, for Zoom in, or a smaller one, for Zoom out. */
|
|
26
26
|
get larger(): boolean;
|
|
27
27
|
get smaller(): boolean;
|
|
28
|
-
/** A step to the next quarter, larger or smaller, if there is one
|
|
28
|
+
/** A step to the next quarter, larger or smaller, if there is one. */
|
|
29
29
|
step(larger: boolean): boolean;
|
|
30
30
|
/** The zoom set to `value` within its bounds — a pinch's —: every watcher hears of a change. */
|
|
31
31
|
set(value: number): boolean;
|
package/lib/core/zoom.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** The smallest and the largest zoom of the sheet: half its fit, and twice it
|
|
1
|
+
/** The smallest and the largest zoom of the sheet: half its fit, and twice it. */
|
|
2
2
|
export const ZOOM_MIN = 0.5;
|
|
3
3
|
export const ZOOM_MAX = 2;
|
|
4
4
|
/**
|
|
5
|
-
* The step of Zoom in and Zoom out, a quarter of the fit
|
|
5
|
+
* The step of Zoom in and Zoom out, a quarter of the fit: from any zoom a pinch left, a
|
|
6
6
|
* press goes to the next quarter, so 50, 75, … 200 % are where the buttons stop.
|
|
7
7
|
*/
|
|
8
8
|
export const ZOOM_STEP = 0.25;
|
|
@@ -22,8 +22,8 @@ export function stepZoom(value, larger) {
|
|
|
22
22
|
return clampZoom(next * ZOOM_STEP);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* The page's zoom
|
|
26
|
-
* the pen mode is
|
|
25
|
+
* The page's zoom: one for every sheet of the page, from 100 % when the page is loaded, as
|
|
26
|
+
* the pen mode is. The next task is a new element, and the zoom stays: a learner who
|
|
27
27
|
* needs it larger or smaller asks once. It lives in memory alone: nothing is stored or sent.
|
|
28
28
|
*/
|
|
29
29
|
export class PageZoom {
|
|
@@ -40,7 +40,7 @@ export class PageZoom {
|
|
|
40
40
|
get smaller() {
|
|
41
41
|
return this.#value > ZOOM_MIN;
|
|
42
42
|
}
|
|
43
|
-
/** A step to the next quarter, larger or smaller, if there is one
|
|
43
|
+
/** A step to the next quarter, larger or smaller, if there is one. */
|
|
44
44
|
step(larger) {
|
|
45
45
|
return this.set(stepZoom(this.#value, larger));
|
|
46
46
|
}
|
package/lib/element/icons.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export type IconName = keyof typeof ICONS;
|
|
|
102
102
|
/**
|
|
103
103
|
* Each value of the row, by its button's key: the icon in outline, the one the button shows while
|
|
104
104
|
* chosen — the same for a value without a fill — and whether the icon is mirrored in a row that
|
|
105
|
-
* runs right to left
|
|
105
|
+
* runs right to left.
|
|
106
106
|
*/
|
|
107
107
|
export declare const ROW: {
|
|
108
108
|
readonly task: {
|
package/lib/element/icons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Written by scripts/icons.ts — `just icons` — from @iconify-json/material-symbols 1.2.99:
|
|
2
|
-
// Material Symbols by Google, under the Apache License 2.0
|
|
2
|
+
// Material Symbols by Google, under the Apache License 2.0.
|
|
3
3
|
// ci-lint fails unless it is what the script writes, so it is never edited by hand. This module is
|
|
4
4
|
// no entry point of the package.
|
|
5
5
|
/** The icons of the row's buttons, by their names in the set, as the element draws them. */
|
|
@@ -152,7 +152,7 @@ export const ICONS = {
|
|
|
152
152
|
/**
|
|
153
153
|
* Each value of the row, by its button's key: the icon in outline, the one the button shows while
|
|
154
154
|
* chosen — the same for a value without a fill — and whether the icon is mirrored in a row that
|
|
155
|
-
* runs right to left
|
|
155
|
+
* runs right to left.
|
|
156
156
|
*/
|
|
157
157
|
export const ROW = {
|
|
158
158
|
task: { outline: "article-outline-rounded", filled: "article-rounded", mirrored: false },
|