react-cheminfo 0.127.0 → 0.129.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +79 -43
  2. package/lib/drawing/core/camera.d.ts +22 -0
  3. package/lib/drawing/core/camera.d.ts.map +1 -1
  4. package/lib/drawing/core/camera.js +37 -0
  5. package/lib/drawing/core/camera.js.map +1 -1
  6. package/lib/drawing/core/graphics.d.ts.map +1 -1
  7. package/lib/drawing/core/graphics.js +2 -10
  8. package/lib/drawing/core/graphics.js.map +1 -1
  9. package/lib/drawing/core/groupFiles.d.ts +22 -0
  10. package/lib/drawing/core/groupFiles.d.ts.map +1 -0
  11. package/lib/drawing/core/groupFiles.js +51 -0
  12. package/lib/drawing/core/groupFiles.js.map +1 -0
  13. package/lib/drawing/core/groups.d.ts +76 -0
  14. package/lib/drawing/core/groups.d.ts.map +1 -0
  15. package/lib/drawing/core/groups.js +190 -0
  16. package/lib/drawing/core/groups.js.map +1 -0
  17. package/lib/drawing/core/index.d.ts +7 -2
  18. package/lib/drawing/core/index.d.ts.map +1 -1
  19. package/lib/drawing/core/index.js +5 -2
  20. package/lib/drawing/core/index.js.map +1 -1
  21. package/lib/drawing/core/selectionFrame.d.ts +70 -0
  22. package/lib/drawing/core/selectionFrame.d.ts.map +1 -0
  23. package/lib/drawing/core/selectionFrame.js +156 -0
  24. package/lib/drawing/core/selectionFrame.js.map +1 -0
  25. package/lib/drawing/core/transform.d.ts +30 -0
  26. package/lib/drawing/core/transform.d.ts.map +1 -1
  27. package/lib/drawing/core/transform.js +59 -0
  28. package/lib/drawing/core/transform.js.map +1 -1
  29. package/lib/drawing/ui/FrameMarks.d.ts +30 -0
  30. package/lib/drawing/ui/FrameMarks.d.ts.map +1 -0
  31. package/lib/drawing/ui/FrameMarks.js +19 -0
  32. package/lib/drawing/ui/FrameMarks.js.map +1 -0
  33. package/lib/drawing/ui/curveHandleMarks.d.ts +10 -0
  34. package/lib/drawing/ui/curveHandleMarks.d.ts.map +1 -1
  35. package/lib/drawing/ui/curveHandleMarks.js +20 -2
  36. package/lib/drawing/ui/curveHandleMarks.js.map +1 -1
  37. package/lib/drawing/ui/index.d.ts +5 -1
  38. package/lib/drawing/ui/index.d.ts.map +1 -1
  39. package/lib/drawing/ui/index.js +3 -1
  40. package/lib/drawing/ui/index.js.map +1 -1
  41. package/lib/drawing/ui/useCanvasNavigation.d.ts +35 -0
  42. package/lib/drawing/ui/useCanvasNavigation.d.ts.map +1 -0
  43. package/lib/drawing/ui/useCanvasNavigation.js +95 -0
  44. package/lib/drawing/ui/useCanvasNavigation.js.map +1 -0
  45. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  46. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  47. package/lib/ir/ui/BandsPanel.d.ts +3 -3
  48. package/lib/ir/ui/BandsPanel.d.ts.map +1 -1
  49. package/lib/ir/ui/BandsPanel.js +7 -7
  50. package/lib/ir/ui/BandsPanel.js.map +1 -1
  51. package/lib/ir/ui/BandsToolbar.d.ts.map +1 -1
  52. package/lib/ir/ui/BandsToolbar.js +2 -4
  53. package/lib/ir/ui/BandsToolbar.js.map +1 -1
  54. package/lib/ir/ui/IrEditor.d.ts +7 -0
  55. package/lib/ir/ui/IrEditor.d.ts.map +1 -1
  56. package/lib/ir/ui/IrEditor.js.map +1 -1
  57. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  58. package/lib/ir/ui/IrShell.js +3 -2
  59. package/lib/ir/ui/IrShell.js.map +1 -1
  60. package/lib/ir/ui/IrStatusBar.js +2 -2
  61. package/lib/ir/ui/IrStatusBar.js.map +1 -1
  62. package/lib/ir/ui/IrToolbar.js +2 -2
  63. package/lib/ir/ui/IrToolbar.js.map +1 -1
  64. package/lib/ir/ui/VibrationalEditor.d.ts +7 -0
  65. package/lib/ir/ui/VibrationalEditor.d.ts.map +1 -1
  66. package/lib/ir/ui/VibrationalEditor.js +2 -1
  67. package/lib/ir/ui/VibrationalEditor.js.map +1 -1
  68. package/lib/ir/ui/useIrEditor.d.ts +12 -0
  69. package/lib/ir/ui/useIrEditor.d.ts.map +1 -1
  70. package/lib/ir/ui/useIrEditor.js +10 -3
  71. package/lib/ir/ui/useIrEditor.js.map +1 -1
  72. package/lib/locales/de.json +9 -0
  73. package/lib/locales/en.json +9 -0
  74. package/lib/locales/es.json +9 -0
  75. package/lib/locales/fr.json +9 -0
  76. package/lib/locales/it.json +9 -0
  77. package/lib/pedagogy/ui/ExerciseActions.d.ts +10 -2
  78. package/lib/pedagogy/ui/ExerciseActions.d.ts.map +1 -1
  79. package/lib/pedagogy/ui/ExerciseActions.js +7 -5
  80. package/lib/pedagogy/ui/ExerciseActions.js.map +1 -1
  81. package/lib/share/core/exampleMark.d.ts +31 -0
  82. package/lib/share/core/exampleMark.d.ts.map +1 -0
  83. package/lib/share/core/exampleMark.js +31 -0
  84. package/lib/share/core/exampleMark.js.map +1 -0
  85. package/lib/share/core/index.d.ts +5 -0
  86. package/lib/share/core/index.d.ts.map +1 -1
  87. package/lib/share/core/index.js +3 -0
  88. package/lib/share/core/index.js.map +1 -1
  89. package/lib/share/core/linkBytes.d.ts +29 -0
  90. package/lib/share/core/linkBytes.d.ts.map +1 -0
  91. package/lib/share/core/linkBytes.js +70 -0
  92. package/lib/share/core/linkBytes.js.map +1 -0
  93. package/lib/share/core/linkValue.d.ts +34 -0
  94. package/lib/share/core/linkValue.d.ts.map +1 -0
  95. package/lib/share/core/linkValue.js +58 -0
  96. package/lib/share/core/linkValue.js.map +1 -0
  97. package/lib/share/core/opensOn.d.ts +133 -0
  98. package/lib/share/core/opensOn.d.ts.map +1 -0
  99. package/lib/share/core/opensOn.js +82 -0
  100. package/lib/share/core/opensOn.js.map +1 -0
  101. package/lib/share/core/seal.d.ts.map +1 -1
  102. package/lib/share/core/seal.js +3 -32
  103. package/lib/share/core/seal.js.map +1 -1
  104. package/lib/share/ui/ShareOpensOn.d.ts +32 -0
  105. package/lib/share/ui/ShareOpensOn.d.ts.map +1 -0
  106. package/lib/share/ui/ShareOpensOn.js +49 -0
  107. package/lib/share/ui/ShareOpensOn.js.map +1 -0
  108. package/lib/share/ui/index.d.ts +4 -0
  109. package/lib/share/ui/index.d.ts.map +1 -1
  110. package/lib/share/ui/index.js +2 -0
  111. package/lib/share/ui/index.js.map +1 -1
  112. package/lib/share/ui/useOpensOnShare.d.ts +65 -0
  113. package/lib/share/ui/useOpensOnShare.d.ts.map +1 -0
  114. package/lib/share/ui/useOpensOnShare.js +60 -0
  115. package/lib/share/ui/useOpensOnShare.js.map +1 -0
  116. package/package.json +1 -1
  117. package/src/drawing/core/camera.ts +45 -0
  118. package/src/drawing/core/graphics.ts +2 -12
  119. package/src/drawing/core/groupFiles.ts +55 -0
  120. package/src/drawing/core/groups.ts +221 -0
  121. package/src/drawing/core/index.ts +29 -1
  122. package/src/drawing/core/selectionFrame.ts +192 -0
  123. package/src/drawing/core/transform.ts +80 -0
  124. package/src/drawing/ui/FrameMarks.tsx +57 -0
  125. package/src/drawing/ui/curveHandleMarks.tsx +43 -10
  126. package/src/drawing/ui/index.ts +8 -1
  127. package/src/drawing/ui/useCanvasNavigation.ts +120 -0
  128. package/src/ir/ui/BandsPanel.tsx +15 -10
  129. package/src/ir/ui/BandsToolbar.tsx +2 -4
  130. package/src/ir/ui/IrEditor.tsx +7 -0
  131. package/src/ir/ui/IrShell.tsx +4 -2
  132. package/src/ir/ui/IrStatusBar.tsx +2 -2
  133. package/src/ir/ui/IrToolbar.tsx +2 -2
  134. package/src/ir/ui/VibrationalEditor.tsx +9 -0
  135. package/src/ir/ui/useIrEditor.ts +23 -4
  136. package/src/locales/de.json +9 -0
  137. package/src/locales/en.json +9 -0
  138. package/src/locales/es.json +9 -0
  139. package/src/locales/fr.json +9 -0
  140. package/src/locales/it.json +9 -0
  141. package/src/pedagogy/ui/ExerciseActions.tsx +22 -7
  142. package/src/share/core/exampleMark.ts +52 -0
  143. package/src/share/core/index.ts +25 -0
  144. package/src/share/core/linkBytes.ts +75 -0
  145. package/src/share/core/linkValue.ts +66 -0
  146. package/src/share/core/opensOn.ts +203 -0
  147. package/src/share/core/seal.ts +3 -36
  148. package/src/share/ui/ShareOpensOn.tsx +169 -0
  149. package/src/share/ui/index.ts +7 -0
  150. package/src/share/ui/useOpensOnShare.tsx +152 -0
  151. package/styles/chrome.css +18 -0
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Groups: items of a figure selected, moved, scaled and turned as one, the
3
+ * same on every canvas of the family. A group names its members by their
4
+ * identifiers — the site's items, or other groups, so that grouping two groups
5
+ * and ungrouping the result gives the two back. What a member stands for (a
6
+ * molecule's atoms on draw, a membrane on cell) is the site's to say; this
7
+ * module knows only identifiers.
8
+ */
9
+ /**
10
+ * The group each member is held in.
11
+ * @param groups - The groups of a figure.
12
+ * @returns The identifier of the group holding each member, by the member's.
13
+ */
14
+ export function parentsOf(groups) {
15
+ const parents = new Map();
16
+ for (const group of groups ?? []) {
17
+ for (const id of group.members)
18
+ parents.set(id, group.id);
19
+ }
20
+ return parents;
21
+ }
22
+ /**
23
+ * The outermost things some members belong to: the outermost group of a
24
+ * grouped member, or the member itself.
25
+ * @param groups - The groups of a figure.
26
+ * @param members - The members, by identifier.
27
+ * @returns The outermost units, each once.
28
+ */
29
+ export function outermostUnits(groups, members) {
30
+ const parents = parentsOf(groups);
31
+ const units = new Set();
32
+ for (const member of members) {
33
+ let top = member;
34
+ const seen = new Set();
35
+ for (let parent = parents.get(top); parent; parent = parents.get(top)) {
36
+ if (seen.has(parent))
37
+ break;
38
+ seen.add(parent);
39
+ top = parent;
40
+ }
41
+ units.add(top);
42
+ }
43
+ return units;
44
+ }
45
+ /**
46
+ * The items some units stand for: a group's members in turn, at any depth,
47
+ * and an item itself.
48
+ * @param groups - The groups of a figure.
49
+ * @param units - Items and groups, by identifier.
50
+ * @returns The items, each once, groups left out.
51
+ */
52
+ export function leafMembers(groups, units) {
53
+ const byId = new Map((groups ?? []).map((group) => [group.id, group]));
54
+ const leaves = new Set();
55
+ const seen = new Set();
56
+ const visit = (ids) => {
57
+ for (const id of ids) {
58
+ const group = byId.get(id);
59
+ if (!group) {
60
+ leaves.add(id);
61
+ }
62
+ else if (!seen.has(id)) {
63
+ seen.add(id);
64
+ visit(group.members);
65
+ }
66
+ }
67
+ };
68
+ visit(units);
69
+ return [...leaves];
70
+ }
71
+ /**
72
+ * Some items grown to the whole of every group they belong to, which is what
73
+ * a click or a box with the selection tool picks.
74
+ * @param groups - The groups of a figure.
75
+ * @param items - The items, by identifier.
76
+ * @returns The items and every item grouped with them.
77
+ */
78
+ export function expandToGroups(groups, items) {
79
+ if (!groups?.length)
80
+ return [...items];
81
+ return leafMembers(groups, outermostUnits(groups, items));
82
+ }
83
+ /**
84
+ * Group the outermost things some items belong to.
85
+ * @param groups - The groups of a figure.
86
+ * @param items - What to group, by identifier.
87
+ * @param id - The new group's identifier.
88
+ * @returns The groups with the new one, or undefined when the items belong
89
+ * to fewer than two things to group.
90
+ */
91
+ export function withGroup(groups, items, id) {
92
+ const units = outermostUnits(groups, items);
93
+ if (units.size < 2)
94
+ return undefined;
95
+ return [...(groups ?? []), { id, members: [...units] }];
96
+ }
97
+ /**
98
+ * Take apart, one level, the outermost groups some items belong to: a group
99
+ * of groups gives its groups back.
100
+ * @param groups - The groups of a figure.
101
+ * @param items - The items, by identifier.
102
+ * @returns The groups left, or undefined when the items belong to none.
103
+ */
104
+ export function withoutGroups(groups, items) {
105
+ if (!groups?.length)
106
+ return undefined;
107
+ const ids = new Set(groups.map((group) => group.id));
108
+ const top = new Set([...outermostUnits(groups, items)].filter((unit) => ids.has(unit)));
109
+ if (top.size === 0)
110
+ return undefined;
111
+ return groups.filter((group) => !top.has(group.id));
112
+ }
113
+ /**
114
+ * Groups brought in step with what a figure holds: a member gone leaves its
115
+ * group, a member named twice stays in the first group naming it, a group
116
+ * never holds itself, and a group left with one member gives it back to the
117
+ * group above.
118
+ * @param groups - The groups.
119
+ * @param existing - The items the figure holds, by identifier; groups need not
120
+ * be listed.
121
+ * @param rejoining - A group to put an item back in, when the site knows the
122
+ * item replaced one that was grouped (a molecule split in two on draw).
123
+ * @returns The groups, the same array when nothing changed.
124
+ */
125
+ export function reconcileGroups(groups, existing, rejoining) {
126
+ const groupIds = new Set(groups.map((group) => group.id));
127
+ const parents = new Map();
128
+ let next = groups.map((group) => {
129
+ const members = [];
130
+ for (const id of group.members) {
131
+ if (!(existing.has(id) || groupIds.has(id)) || parents.has(id))
132
+ continue;
133
+ if (encloses(parents, id, group.id))
134
+ continue;
135
+ parents.set(id, group.id);
136
+ members.push(id);
137
+ }
138
+ return { id: group.id, members };
139
+ });
140
+ for (const [item, groupId] of rejoining ?? []) {
141
+ if (parents.has(item))
142
+ continue;
143
+ const group = next.find((candidate) => candidate.id === groupId);
144
+ if (!group)
145
+ continue;
146
+ group.members.push(item);
147
+ parents.set(item, groupId);
148
+ }
149
+ next = dissolveSmall(next, parents);
150
+ return JSON.stringify(next) === JSON.stringify(groups) ? groups : next;
151
+ }
152
+ // Whether a member is the group itself, or a group holding it at some depth.
153
+ function encloses(parents, candidate, groupId) {
154
+ if (candidate === groupId)
155
+ return true;
156
+ const seen = new Set();
157
+ for (let at = parents.get(groupId); at;) {
158
+ if (at === candidate || seen.has(at))
159
+ return true;
160
+ seen.add(at);
161
+ at = parents.get(at);
162
+ }
163
+ return false;
164
+ }
165
+ // Groups left with fewer than two members dissolved: an empty one goes, and
166
+ // the one member of another moves up to the group above it.
167
+ function dissolveSmall(groups, parents) {
168
+ let current = groups;
169
+ for (;;) {
170
+ const small = current.find((group) => group.members.length < 2);
171
+ if (!small)
172
+ return current;
173
+ const kept = current.filter((group) => group !== small);
174
+ const parent = kept.find((group) => group.id === parents.get(small.id));
175
+ if (parent) {
176
+ parent.members = parent.members.filter((id) => id !== small.id);
177
+ for (const id of small.members) {
178
+ parent.members.push(id);
179
+ parents.set(id, parent.id);
180
+ }
181
+ }
182
+ else {
183
+ for (const id of small.members)
184
+ parents.delete(id);
185
+ }
186
+ parents.delete(small.id);
187
+ current = kept;
188
+ }
189
+ }
190
+ //# sourceMappingURL=groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../src/drawing/core/groups.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,MAAwC;IAExC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;QACjC,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAwC,EACxC,OAAyB;IAEzB,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,GAAG,GAAG,MAAM,CAAC;QACjB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACtE,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;gBAAE,MAAM;YAC5B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjB,GAAG,GAAG,MAAM,CAAC;QACf,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAM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AAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;YAChE,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC/B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO;gBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export type { Arrangement } from './arrangement.ts';
2
2
  export { arrangementShifts } from './arrangement.ts';
3
3
  export type { Camera } from './camera.ts';
4
- export { PIXELS_PER_POINT, START_CAMERA, ZOOM_PRESETS, ZOOM_RANGE, fillCamera, frameCamera, visibleBox, zoomAround, zoomOfShare, zoomShare, } from './camera.ts';
4
+ export { PIXELS_PER_POINT, START_CAMERA, ZOOM_PRESETS, ZOOM_RANGE, fillCamera, frameCamera, pannedCamera, visibleBox, wheelZoomFactor, zoomAround, zoomOfShare, zoomShare, } from './camera.ts';
5
5
  export type { DrawText, TextAlign, TextLayout, TextPatch, TextVerticalAlign, } from './captions.ts';
6
6
  export { CAPTION_SIZE_LIMITS, MAX_TEXT, addText, clampCaptionSize, parseText, updateText, } from './captions.ts';
7
7
  export type { ChemicalRange } from './chemicalText.ts';
@@ -51,8 +51,13 @@ export type { CurveDragOptions, CurveHandle } from './shapeHandles.ts';
51
51
  export { dragShapeHandle, resetShapeVertex, shapeHandleAt, shapeHandles, shapeLineAt, } from './shapeHandles.ts';
52
52
  export type { Patching } from './shared.ts';
53
53
  export { idsOf, patchOf, sharedValue } from './shared.ts';
54
+ export type { DrawGroup } from './groups.ts';
55
+ export { expandToGroups, leafMembers, outermostUnits, parentsOf, reconcileGroups, withGroup, withoutGroups, } from './groups.ts';
56
+ export { parseGroups, renumberGroups } from './groupFiles.ts';
57
+ export type { FrameHandle } from './selectionFrame.ts';
58
+ export { ROTATE_HANDLE_GAP, frameCorners, frameCursor, frameHandleAt, frameHandles, frameTransform, framedBox, } from './selectionFrame.ts';
54
59
  export type { Similarity } from './transform.ts';
55
- export { pointMap } from './transform.ts';
60
+ export { mapCurve, pointMap, transformCaption, transformPicture, } from './transform.ts';
56
61
  export type { Box, DrawPage, FigureSize, Point } from './types.ts';
57
62
  export { arrayOf, isFiniteNumber, isRecord } from './values.ts';
58
63
  export { along, leftOf, turnAbout, unit } from './vectors.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drawing/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,SAAS,EACT,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EA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,EACT,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { arrangementShifts } from "./arrangement.js";
2
- export { PIXELS_PER_POINT, START_CAMERA, ZOOM_PRESETS, ZOOM_RANGE, fillCamera, frameCamera, visibleBox, zoomAround, zoomOfShare, zoomShare, } from "./camera.js";
2
+ export { PIXELS_PER_POINT, START_CAMERA, ZOOM_PRESETS, ZOOM_RANGE, fillCamera, frameCamera, pannedCamera, visibleBox, wheelZoomFactor, zoomAround, zoomOfShare, zoomShare, } from "./camera.js";
3
3
  export { CAPTION_SIZE_LIMITS, MAX_TEXT, addText, clampCaptionSize, parseText, updateText, } from "./captions.js";
4
4
  export { LINE_DASHES, isLineDash } from "./dashes.js";
5
5
  export { chemicalRanges } from "./chemicalText.js";
@@ -30,7 +30,10 @@ export { MAX_RUN_SIZE, readMarks } from "./richTextMarks.js";
30
30
  export { writeRichText } from "./richTextWriter.js";
31
31
  export { dragShapeHandle, resetShapeVertex, shapeHandleAt, shapeHandles, shapeLineAt, } from "./shapeHandles.js";
32
32
  export { idsOf, patchOf, sharedValue } from "./shared.js";
33
- export { pointMap } from "./transform.js";
33
+ export { expandToGroups, leafMembers, outermostUnits, parentsOf, reconcileGroups, withGroup, withoutGroups, } from "./groups.js";
34
+ export { parseGroups, renumberGroups } from "./groupFiles.js";
35
+ export { ROTATE_HANDLE_GAP, frameCorners, frameCursor, frameHandleAt, frameHandles, frameTransform, framedBox, } from "./selectionFrame.js";
36
+ export { mapCurve, pointMap, transformCaption, transformPicture, } from "./transform.js";
34
37
  export { arrayOf, isFiniteNumber, isRecord } from "./values.js";
35
38
  export { along, leftOf, turnAbout, unit } from "./vectors.js";
36
39
  export { createUndoHistory } from "./undoHistory.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawing/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,aAAa,CAAC;AAQrB,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,OAAO,EACP,WAAW,EACX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AE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawing/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,aAAa,CAAC;AAQrB,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,cAAc,EACd,SAAS,GACV,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,eAAe,EACf,eA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AAM,aAAa,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The frame around a selection and its handles, the same on every canvas of
3
+ * the family: a corner scales everything selected about the corner across
4
+ * from it, keeping its proportions, and the round handle above it turns it
5
+ * about the frame's middle, by 15° steps; Shift frees the angle. A group is a
6
+ * selection like any other, so it is scaled and turned the same way. Handles
7
+ * keep their size on screen, so where they sit depends on the zoom.
8
+ *
9
+ * What the frame surrounds is the site's to measure — the box of what its
10
+ * selection draws — and how each of its items takes a {@link Similarity} is
11
+ * the site's too.
12
+ */
13
+ import type { Similarity } from './transform.ts';
14
+ import type { Box, Point } from './types.ts';
15
+ /** A corner of the frame, or the handle that turns it. */
16
+ export type FrameHandle = 'nw' | 'ne' | 'se' | 'sw' | 'rotate';
17
+ /** How far above a frame its turning handle sits, in screen pixels. */
18
+ export declare const ROTATE_HANDLE_GAP = 24;
19
+ /**
20
+ * The frame around the box of what a selection draws, standing off it.
21
+ * @param box - The box of what the selection draws.
22
+ * @param pixel - Units per screen pixel.
23
+ * @returns The frame, or undefined when there is nothing a scale or a turn
24
+ * would change.
25
+ */
26
+ export declare function framedBox(box: Box | undefined, pixel: number): Box | undefined;
27
+ /**
28
+ * Where the handles of a frame are drawn.
29
+ * @param frame - The frame.
30
+ * @param pixel - Units per screen pixel.
31
+ * @returns Each handle and its centre; the turning handle first.
32
+ */
33
+ export declare function frameHandles(frame: Box, pixel: number): Array<{
34
+ handle: FrameHandle;
35
+ point: Point;
36
+ }>;
37
+ /**
38
+ * The handle of a frame under the pointer, if any.
39
+ * @param frame - The frame.
40
+ * @param point - The pointer.
41
+ * @param pixel - Units per screen pixel.
42
+ * @returns The closest handle within reach, or undefined.
43
+ */
44
+ export declare function frameHandleAt(frame: Box, point: Point, pixel: number): FrameHandle | undefined;
45
+ /**
46
+ * The scale or the turn a handle dragged from one point to another asks for.
47
+ * @param frame - The frame as it was when the handle was taken.
48
+ * @param handle - The handle.
49
+ * @param start - Where the pointer took it.
50
+ * @param pointer - Where the pointer is.
51
+ * @param free - Whether Shift is held, which frees the angle of a turn.
52
+ * @returns The transform.
53
+ */
54
+ export declare function frameTransform(frame: Box, handle: FrameHandle, start: Point, pointer: Point, free: boolean): Similarity;
55
+ /**
56
+ * The corners of a frame once a transform is applied, to draw it while a
57
+ * handle is dragged.
58
+ * @param frame - The frame.
59
+ * @param transform - The transform.
60
+ * @returns The four corners, in order around the frame.
61
+ */
62
+ export declare function frameCorners(frame: Box, transform: Similarity): Point[];
63
+ /**
64
+ * The pointer's shape over a handle.
65
+ * @param handle - The handle.
66
+ * @param held - Whether it is held.
67
+ * @returns A CSS cursor.
68
+ */
69
+ export declare function frameCursor(handle: FrameHandle, held: boolean): string;
70
+ //# sourceMappingURL=selectionFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionFrame.d.ts","sourceRoot":"","sources":["../../../src/drawing/core/selectionFrame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE7C,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE/D,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAsBpC;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,GAAG,GAAG,SAAS,EACpB,KAAK,EAAE,MAAM,GACZ,GAAG,GAAG,SAAS,CASjB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,GAAG,EACV,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAiB9C;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,GAAG,EACV,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,GACZ,WAAW,GAAG,SAAS,CAWzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,KAAK,EACd,IAAI,EAAE,OAAO,GACZ,UAAU,CA0BZ;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,GAAG,KAAK,EAAE,CAKvE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAGtE"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * The frame around a selection and its handles, the same on every canvas of
3
+ * the family: a corner scales everything selected about the corner across
4
+ * from it, keeping its proportions, and the round handle above it turns it
5
+ * about the frame's middle, by 15° steps; Shift frees the angle. A group is a
6
+ * selection like any other, so it is scaled and turned the same way. Handles
7
+ * keep their size on screen, so where they sit depends on the zoom.
8
+ *
9
+ * What the frame surrounds is the site's to measure — the box of what its
10
+ * selection draws — and how each of its items takes a {@link Similarity} is
11
+ * the site's too.
12
+ */
13
+ import { roundCoordinate } from "./geometry.js";
14
+ import { normalizeDegrees } from "./pictures.js";
15
+ import { pointMap } from "./transform.js";
16
+ /** How far above a frame its turning handle sits, in screen pixels. */
17
+ export const ROTATE_HANDLE_GAP = 24;
18
+ /** How far the frame stands off what it frames, in screen pixels. */
19
+ const FRAME_GAP = 6;
20
+ /** How far from a handle the pointer still takes it, in screen pixels. */
21
+ const HANDLE_REACH = 7;
22
+ /** The step a selection turns by unless Shift is held, in degrees. */
23
+ const ROTATION_STEP = 15;
24
+ /** The smallest the longer side of a frame is scaled down to, in its units. */
25
+ const MIN_SIDE = 4;
26
+ /** Where each corner sits, as signs of the half-sides. */
27
+ const CORNERS = {
28
+ nw: { x: -1, y: -1 },
29
+ ne: { x: 1, y: -1 },
30
+ se: { x: 1, y: 1 },
31
+ sw: { x: -1, y: 1 },
32
+ };
33
+ /**
34
+ * The frame around the box of what a selection draws, standing off it.
35
+ * @param box - The box of what the selection draws.
36
+ * @param pixel - Units per screen pixel.
37
+ * @returns The frame, or undefined when there is nothing a scale or a turn
38
+ * would change.
39
+ */
40
+ export function framedBox(box, pixel) {
41
+ if (!box || Math.max(box.width, box.height) < 1)
42
+ return undefined;
43
+ const gap = FRAME_GAP * pixel;
44
+ return {
45
+ x: box.x - gap,
46
+ y: box.y - gap,
47
+ width: box.width + 2 * gap,
48
+ height: box.height + 2 * gap,
49
+ };
50
+ }
51
+ /**
52
+ * Where the handles of a frame are drawn.
53
+ * @param frame - The frame.
54
+ * @param pixel - Units per screen pixel.
55
+ * @returns Each handle and its centre; the turning handle first.
56
+ */
57
+ export function frameHandles(frame, pixel) {
58
+ const handles = [
59
+ {
60
+ handle: 'rotate',
61
+ point: {
62
+ x: frame.x + frame.width / 2,
63
+ y: frame.y - ROTATE_HANDLE_GAP * pixel,
64
+ },
65
+ },
66
+ ];
67
+ for (const [handle, sign] of Object.entries(CORNERS)) {
68
+ handles.push({
69
+ handle: handle,
70
+ point: cornerOf(frame, sign),
71
+ });
72
+ }
73
+ return handles;
74
+ }
75
+ /**
76
+ * The handle of a frame under the pointer, if any.
77
+ * @param frame - The frame.
78
+ * @param point - The pointer.
79
+ * @param pixel - Units per screen pixel.
80
+ * @returns The closest handle within reach, or undefined.
81
+ */
82
+ export function frameHandleAt(frame, point, pixel) {
83
+ let best;
84
+ let bestDistance = HANDLE_REACH * pixel;
85
+ for (const { handle, point: centre } of frameHandles(frame, pixel)) {
86
+ const value = Math.hypot(point.x - centre.x, point.y - centre.y);
87
+ if (value <= bestDistance) {
88
+ best = handle;
89
+ bestDistance = value;
90
+ }
91
+ }
92
+ return best;
93
+ }
94
+ /**
95
+ * The scale or the turn a handle dragged from one point to another asks for.
96
+ * @param frame - The frame as it was when the handle was taken.
97
+ * @param handle - The handle.
98
+ * @param start - Where the pointer took it.
99
+ * @param pointer - Where the pointer is.
100
+ * @param free - Whether Shift is held, which frees the angle of a turn.
101
+ * @returns The transform.
102
+ */
103
+ export function frameTransform(frame, handle, start, pointer, free) {
104
+ if (handle === 'rotate') {
105
+ const pivot = {
106
+ x: frame.x + frame.width / 2,
107
+ y: frame.y + frame.height / 2,
108
+ };
109
+ const turned = ((Math.atan2(pointer.y - pivot.y, pointer.x - pivot.x) -
110
+ Math.atan2(start.y - pivot.y, start.x - pivot.x)) *
111
+ 180) /
112
+ Math.PI;
113
+ const rotation = free
114
+ ? Math.round(turned * 10) / 10
115
+ : Math.round(turned / ROTATION_STEP) * ROTATION_STEP;
116
+ return { pivot, scale: 1, rotation: normalizeDegrees(rotation) };
117
+ }
118
+ const sign = CORNERS[handle];
119
+ const pivot = cornerOf(frame, { x: -sign.x, y: -sign.y });
120
+ const corner = cornerOf(frame, sign);
121
+ const diagonal = { x: corner.x - pivot.x, y: corner.y - pivot.y };
122
+ const reach = ((pointer.x - pivot.x) * diagonal.x + (pointer.y - pivot.y) * diagonal.y) /
123
+ (diagonal.x * diagonal.x + diagonal.y * diagonal.y);
124
+ const floor = MIN_SIDE / Math.max(frame.width, frame.height);
125
+ const scale = Math.max(Math.round(reach * 1000) / 1000, floor);
126
+ return { pivot, scale, rotation: 0 };
127
+ }
128
+ /**
129
+ * The corners of a frame once a transform is applied, to draw it while a
130
+ * handle is dragged.
131
+ * @param frame - The frame.
132
+ * @param transform - The transform.
133
+ * @returns The four corners, in order around the frame.
134
+ */
135
+ export function frameCorners(frame, transform) {
136
+ const map = pointMap(transform);
137
+ return [CORNERS.nw, CORNERS.ne, CORNERS.se, CORNERS.sw].map((sign) => map(cornerOf(frame, sign)));
138
+ }
139
+ /**
140
+ * The pointer's shape over a handle.
141
+ * @param handle - The handle.
142
+ * @param held - Whether it is held.
143
+ * @returns A CSS cursor.
144
+ */
145
+ export function frameCursor(handle, held) {
146
+ if (handle === 'rotate')
147
+ return held ? 'grabbing' : 'grab';
148
+ return handle === 'nw' || handle === 'se' ? 'nwse-resize' : 'nesw-resize';
149
+ }
150
+ function cornerOf(frame, sign) {
151
+ return {
152
+ x: roundCoordinate(frame.x + ((sign.x + 1) / 2) * frame.width),
153
+ y: roundCoordinate(frame.y + ((sign.y + 1) / 2) * frame.height),
154
+ };
155
+ }
156
+ //# sourceMappingURL=selectionFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionFrame.js","sourceRoot":"","sources":["../../../src/drawing/core/selectionFrame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM1C,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,qEAAqE;AACrE,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,0EAA0E;AAC1E,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,sEAAsE;AACtE,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,+EAA+E;AAC/E,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB,0DAA0D;AAC1D,MAAM,OAAO,GAAG;IACd,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;IACpB,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;IACnB,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC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
3
3
  * them.
4
4
  */
5
+ import type { DrawText } from './captions.ts';
6
+ import type { CurveControl } from './curves.ts';
7
+ import type { DrawPicture } from './pictures.ts';
5
8
  import type { Point } from './types.ts';
6
9
  /** A scale and a turn about a point. */
7
10
  export interface Similarity {
@@ -18,4 +21,31 @@ export interface Similarity {
18
21
  * @returns The map.
19
22
  */
20
23
  export declare function pointMap(transform: Similarity): (point: Point) => Point;
24
+ /**
25
+ * A curve — a shape's path, a membrane, a strand — whose points and hand-set
26
+ * controls a map takes elsewhere.
27
+ * @param curve - The curve.
28
+ * @param map - Where each point goes.
29
+ * @returns The curve, moved.
30
+ */
31
+ export declare function mapCurve<T extends {
32
+ points: readonly Point[];
33
+ controls?: ReadonlyArray<CurveControl | null>;
34
+ }>(curve: T, map: (point: Point) => Point): T;
35
+ /**
36
+ * A caption scaled and turned with a selection: its anchor follows, its size
37
+ * scales within the bounds a caption keeps, and its turn adds up.
38
+ * @param text - The caption.
39
+ * @param transform - The scale and the turn.
40
+ * @param defaultSize - The size a caption without its own is drawn at.
41
+ * @returns The caption, transformed.
42
+ */
43
+ export declare function transformCaption<T extends DrawText>(text: T, transform: Similarity, defaultSize: number): T;
44
+ /**
45
+ * A picture scaled and turned with a selection, about its centre.
46
+ * @param picture - The picture.
47
+ * @param transform - The scale and the turn.
48
+ * @returns The picture, transformed and normalized.
49
+ */
50
+ export declare function transformPicture<T extends DrawPicture>(picture: T, transform: Similarity): T;
21
51
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/drawing/core/transform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,wCAAwC;AACxC,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,KAAK,EAAE,KAAK,CAAC;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,Q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AO,EAAE,CAAC,EACV,SAAS,EAAE,UAAU,GACpB,CAAC,CAeH"}
@@ -2,7 +2,9 @@
2
2
  * A scale and a turn about a pivot, as the handles of a selection frame make
3
3
  * them.
4
4
  */
5
+ import { clampCaptionSize } from "./captions.js";
5
6
  import { roundCoordinate } from "./geometry.js";
7
+ import { normalizeDegrees, normalizePicture } from "./pictures.js";
6
8
  import { turnAbout } from "./vectors.js";
7
9
  /**
8
10
  * Where a transform takes a point, rounded as coordinates are.
@@ -16,4 +18,61 @@ export function pointMap(transform) {
16
18
  return { x: roundCoordinate(x), y: roundCoordinate(y) };
17
19
  };
18
20
  }
21
+ /**
22
+ * A curve — a shape's path, a membrane, a strand — whose points and hand-set
23
+ * controls a map takes elsewhere.
24
+ * @param curve - The curve.
25
+ * @param map - Where each point goes.
26
+ * @returns The curve, moved.
27
+ */
28
+ export function mapCurve(curve, map) {
29
+ const moved = { ...curve, points: curve.points.map(map) };
30
+ if (curve.controls) {
31
+ moved.controls = curve.controls.map((control) => control
32
+ ? { before: map(control.before), after: map(control.after) }
33
+ : null);
34
+ }
35
+ return moved;
36
+ }
37
+ /**
38
+ * A caption scaled and turned with a selection: its anchor follows, its size
39
+ * scales within the bounds a caption keeps, and its turn adds up.
40
+ * @param text - The caption.
41
+ * @param transform - The scale and the turn.
42
+ * @param defaultSize - The size a caption without its own is drawn at.
43
+ * @returns The caption, transformed.
44
+ */
45
+ export function transformCaption(text, transform, defaultSize) {
46
+ const { rotation: turn, ...rest } = text;
47
+ const moved = { ...rest, ...pointMap(transform)(text) };
48
+ if (transform.scale !== 1) {
49
+ moved.size = clampCaptionSize(roundCoordinate((text.size ?? defaultSize) * transform.scale));
50
+ }
51
+ const nextTurn = normalizeDegrees((turn ?? 0) + transform.rotation);
52
+ if (nextTurn !== 0)
53
+ moved.rotation = nextTurn;
54
+ return moved;
55
+ }
56
+ /**
57
+ * A picture scaled and turned with a selection, about its centre.
58
+ * @param picture - The picture.
59
+ * @param transform - The scale and the turn.
60
+ * @returns The picture, transformed and normalized.
61
+ */
62
+ export function transformPicture(picture, transform) {
63
+ const width = picture.width * transform.scale;
64
+ const height = picture.height * transform.scale;
65
+ const centre = pointMap(transform)({
66
+ x: picture.x + picture.width / 2,
67
+ y: picture.y + picture.height / 2,
68
+ });
69
+ return normalizePicture({
70
+ ...picture,
71
+ x: centre.x - width / 2,
72
+ y: centre.y - height / 2,
73
+ width,
74
+ height,
75
+ rotation: (picture.rotation ?? 0) + transform.rotation,
76
+ });
77
+ }
19
78
  //# sourceMappingURL=transform.js.map