@edubeam/plot 0.2.0 → 0.3.1
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/CHANGELOG.md +56 -0
- package/dist/components/types.d.ts +1 -1
- package/dist/core/model.d.ts +4 -1
- package/dist/core/polynomial.d.ts +0 -1
- package/dist/core/readout.d.ts +42 -7
- package/dist/core/scene.d.ts +73 -5
- package/dist/core/structure.d.ts +145 -3
- package/dist/core/svg.d.ts +27 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1920 -1066
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@edubeam/plot` are listed here. The project follows [Semantic Versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## 0.3.1 (2026-11-21)
|
|
6
|
+
|
|
7
|
+
- Every diagram has an undrawn `hitArea` path covering it, whatever its fill, tagged with its member, so an app
|
|
8
|
+
can treat the pointer over a diagram as over its member.
|
|
9
|
+
- A member's name along a vertical member reads upward, as the diagrams' values do; it read downward.
|
|
10
|
+
- A member's name stays at its member's middle across a diagram's line, moving only for another label.
|
|
11
|
+
- A power of ten in a label (`1.63·10⁻³`) is written as a real superscript, smaller and raised, in plain digits,
|
|
12
|
+
in the component and in `.svg` files alike; `textRuns` splits a label so an app can do the same.
|
|
13
|
+
- `displacementMarker` marks the largest displacement: a dot on the deformed shape and a dashed line to it from
|
|
14
|
+
where that point was. Its value may stand anywhere round the dot, and is placed after every maximum.
|
|
15
|
+
- `extremeOrdinates` draws the ordinate of a diagram's maximum inside a member (the largest moment under a
|
|
16
|
+
distributed load). A maximum's value stays at its tip across other diagrams' lines.
|
|
17
|
+
- A scene item's `requires` names the label it goes with: left out for want of room, the label takes its marks
|
|
18
|
+
with it, so no dot or ordinate points at a value that is not there.
|
|
19
|
+
- `loadNumberFormat`: the loads' values in a format of their own, so given data can drop the zeros results keep
|
|
20
|
+
(10 kN, not 10.00 kN).
|
|
21
|
+
- A point force's value tries other places round its arrow before giving up, and given data with no free place
|
|
22
|
+
takes the place that covers the fewest labels, instead of overlapping at its first.
|
|
23
|
+
- Among given data's labels of equal rank, the one with the fewest places is placed first.
|
|
24
|
+
- `keptGroups`: a label with no free place takes the place that covers the fewest labels already kept, rather
|
|
25
|
+
than always its first.
|
|
26
|
+
- A nodal load naming a node that is not in the model is left out by `modelFromSolver` instead of throwing.
|
|
27
|
+
|
|
28
|
+
## 0.3.0 (2026-11-20)
|
|
29
|
+
|
|
30
|
+
- **Drawing for an editor**: the options the EduBeam app's new renderer draws with, all off by default.
|
|
31
|
+
`sizes` overrides the symbols' px sizes; `loadLabels: 'ends'` writes a distributed load at both ends as bare
|
|
32
|
+
numbers; `constantDiagrams: 'ends'` and `cornerValues: 'each'` annotate every segment and every member's end;
|
|
33
|
+
`splitLoads` draws a load's two components as the two loads they were entered as; `sideBySide` stands two
|
|
34
|
+
values written along one ordinate line side by side, each half a line aside, rather than one pushed out;
|
|
35
|
+
`freeNodes` draws nodes no member reaches yet; `labelsAvoidSupports`, `displacementText`, `diagramFill`
|
|
36
|
+
(`hatch`, `solid`, `none`), `showDegrees`, `normalOnDashedSide`, `shearOnDashedSide` and `supportScale` follow
|
|
37
|
+
the app's settings.
|
|
38
|
+
- **Member names**: a `memberLabels` layer writes each member's name once, along it and never upside down.
|
|
39
|
+
- **Loads that push the same way stack**, as a textbook draws them: a second band on top of the first, a point
|
|
40
|
+
load's arrow beyond the last one's value.
|
|
41
|
+
- **Reactions on their line of action**: every reaction force, the horizontal ones too, now points at its node.
|
|
42
|
+
- A diagram running straight on through a node writes the value it has on both sides once.
|
|
43
|
+
- **Pointing at things**: paths, circles and texts carry the `entity` they draw (`member:…`, `node:…`,
|
|
44
|
+
`elementLoad:…`, `nodalLoad:…`), loads carry their `source` from `modelFromSolver`, and each distributed
|
|
45
|
+
load has an undrawn `hitArea` path covering its band, so an app can highlight or hit-test what it shows.
|
|
46
|
+
- **Values at the pointer**: `placeReadoutTags` places a readout's tags beside their diagram points, outward
|
|
47
|
+
only and inside a viewport; `readMember` and `readoutAt` snap to a member's ends and, for the quantities read,
|
|
48
|
+
to their interior extremes (the largest moment, where the shear is zero, first); `formatReadout` takes a
|
|
49
|
+
writer for displacements.
|
|
50
|
+
- **Label priorities**: `resolveScene` takes `lateGroups` (placed after the given data), `yieldingGroups` (give
|
|
51
|
+
way to every other label) and `keptGroups` (never left out), and reports the painted `bounds`. A text placement
|
|
52
|
+
marked `acrossDiagrams` may cross another diagram's outline.
|
|
53
|
+
- A structure drawn at an extreme zoom (a fit's first probe) no longer runs out of memory: a member gets at most
|
|
54
|
+
500 load arrows or hatch lines, spaced wider when it is longer.
|
|
55
|
+
- **Faster**: labels are placed against a spatial grid (a 375-member frame placed in 0.3 s, down from 10 s),
|
|
56
|
+
`mergePaths` joins alike paths (a band of thirty arrows becomes two paths), and diagram maxima are cached.
|
|
57
|
+
- **`sceneSvg`** writes a scene laid out by an application as a standalone `.svg` file, and **`sceneMarkup`** as
|
|
58
|
+
markup for an SVG of its own, with the same Word- and Inkscape-safe output as `structureSvg`.
|
|
59
|
+
- `SymbolSizes` is exported.
|
|
60
|
+
|
|
5
61
|
## 0.2.0 (2026-11-19)
|
|
6
62
|
|
|
7
63
|
- **Translatable screen-reader texts**: `PLOT_TEXTS` (an injection key) lets an app give the figure's accessible
|
|
@@ -9,7 +9,7 @@ import type { PlotLayer, ReactionLabels, ResultLabelMode, ResultLayer } from '..
|
|
|
9
9
|
import type { Units } from '../core/units.js';
|
|
10
10
|
import type { PlotColors } from './theme.js';
|
|
11
11
|
export interface StructurePlotProps {
|
|
12
|
-
/**
|
|
12
|
+
/** An @edubeam/fem solver; solved, to show results. Pass a new one (or bump `revision`) after a change. */
|
|
13
13
|
solver?: Solver;
|
|
14
14
|
/** Or the plain data `modelFromSolver` makes, e.g. prepared at build time. */
|
|
15
15
|
model?: PlotModel;
|
package/dist/core/model.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface LineIntensity {
|
|
|
31
31
|
}
|
|
32
32
|
export type PlotLoad =
|
|
33
33
|
/** A force at a node, global components, N. */
|
|
34
|
-
{
|
|
34
|
+
({
|
|
35
35
|
readonly kind: 'nodalForce';
|
|
36
36
|
readonly node: string;
|
|
37
37
|
readonly fx: number;
|
|
@@ -80,6 +80,9 @@ export type PlotLoad =
|
|
|
80
80
|
readonly dx?: number;
|
|
81
81
|
readonly dz?: number;
|
|
82
82
|
readonly ry?: number;
|
|
83
|
+
}) & {
|
|
84
|
+
/** Where the caller keeps it, to tell which drawn load is which (the editor's `nodalLoad:3`). */
|
|
85
|
+
readonly source?: string;
|
|
83
86
|
};
|
|
84
87
|
export type PlotLoadKind = PlotLoad['kind'];
|
|
85
88
|
export type ReactionDof = 'dx' | 'dz' | 'ry';
|
|
@@ -24,7 +24,6 @@ export declare const evalPieceSlope: (piece: Piece, x: number) => number;
|
|
|
24
24
|
* right of one - never leaks into the piece: its end values are the one-sided limits.
|
|
25
25
|
*/
|
|
26
26
|
export declare const fitPiece: (f: (x: number) => number, x0: number, x1: number, degree: number) => Piece;
|
|
27
|
-
/** Largest |value| over the pieces, end values and interior extremes included. */
|
|
28
27
|
export declare const maxAbs: (pw: Piecewise) => number;
|
|
29
28
|
/**
|
|
30
29
|
* Drops coefficients below `tolerance`: the round-off a solved structure leaves in a value that is
|
package/dist/core/readout.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* values where a point load or a support makes a step.
|
|
4
4
|
*/
|
|
5
5
|
import { type MemberResults, type PlotModel } from './model.js';
|
|
6
|
-
import { type Tone, type Transform } from './scene.js';
|
|
6
|
+
import { type Bounds, type Tone, type Transform } from './scene.js';
|
|
7
7
|
import { type Units } from './units.js';
|
|
8
8
|
/** Either side of a point; the two are equal where the result is continuous. */
|
|
9
9
|
export interface SidedValue {
|
|
@@ -22,14 +22,22 @@ export interface Readout {
|
|
|
22
22
|
/** Displacement along the member's local x there, m. */
|
|
23
23
|
readonly u: number;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The results at x, snapping to a point a reader looks for within `snap` metres: a break, so a step
|
|
27
|
+
* shows both its values, or - given the member's `length` - an end; else an interior extreme of a
|
|
28
|
+
* quantity in `extremaOf`, the largest moment (where the shear is zero) before the largest
|
|
29
|
+
* deflection, then shear and normal force. Within a kind, the nearest.
|
|
30
|
+
*/
|
|
31
|
+
export declare const readMember: (results: MemberResults, x: number, snap?: number, length?: number, extremaOf?: readonly ReadoutQuantity[]) => {
|
|
27
32
|
x: number;
|
|
28
33
|
u: number;
|
|
29
34
|
values: Record<ReadoutQuantity, SidedValue>;
|
|
30
35
|
};
|
|
31
|
-
/**
|
|
32
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The member nearest the screen point (px, py), within `reach` px, and its results there, snapped
|
|
38
|
+
* to its steps, its ends and the extremes of the quantities in `extremaOf` (see `readMember`).
|
|
39
|
+
*/
|
|
40
|
+
export declare const readoutAt: (model: PlotModel, t: Transform, px: number, py: number, reach: number, extremaOf?: readonly ReadoutQuantity[]) => Readout | null;
|
|
33
41
|
/** Where a read value sits on the drawing: on its diagram's outline, or on the deformed shape. */
|
|
34
42
|
export interface ReadoutMark {
|
|
35
43
|
readonly tone: Tone;
|
|
@@ -44,5 +52,32 @@ export interface ReadoutMark {
|
|
|
44
52
|
* per SI unit, `side` the side each diagram is drawn on (see `diagramScales`, `diagramSide`).
|
|
45
53
|
*/
|
|
46
54
|
export declare const readoutMarks: (model: PlotModel, t: Transform, r: Readout, shown: readonly ReadoutQuantity[], k: Readonly<Record<ReadoutQuantity, number>>, side: Readonly<Record<"N" | "V" | "M", 1 | -1>>) => ReadoutMark[];
|
|
47
|
-
/**
|
|
48
|
-
|
|
55
|
+
/**
|
|
56
|
+
* "M = 54 kNm", or "V = 13.3 → −6.7 kN" across a step. `write`, given a value in display units,
|
|
57
|
+
* writes the number in place of `format` (an editor's own style for displacements, say).
|
|
58
|
+
*/
|
|
59
|
+
export declare const formatReadout: (r: Readout, q: ReadoutQuantity, units: Units, format?: Intl.NumberFormat, write?: (value: number) => string) => string;
|
|
60
|
+
/** A value read off the drawing, as a small tag beside the point it belongs to. */
|
|
61
|
+
export interface ReadoutTag {
|
|
62
|
+
readonly tone: Tone;
|
|
63
|
+
readonly text: string;
|
|
64
|
+
/** The tag's box, px. */
|
|
65
|
+
readonly x: number;
|
|
66
|
+
readonly y: number;
|
|
67
|
+
readonly w: number;
|
|
68
|
+
readonly h: number;
|
|
69
|
+
/** The point it belongs to, px: a diagram's tip, the displaced point, or the member point. */
|
|
70
|
+
readonly at: readonly [number, number];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Each read value as a tag just past the point it belongs to, along that quantity's own ordinate
|
|
74
|
+
* (out from the member), stepping further out only to keep clear of the tags already placed, the
|
|
75
|
+
* member and the pointer. The station's `x` is the last tag, beside the member point on the side
|
|
76
|
+
* the fewest values take. `member` is the member's line on screen, px.
|
|
77
|
+
*/
|
|
78
|
+
export declare const placeReadoutTags: (readings: readonly {
|
|
79
|
+
readonly mark: ReadoutMark;
|
|
80
|
+
readonly text: string;
|
|
81
|
+
}[], caption: string | null, member: readonly [readonly [number, number], readonly [number, number]], pointer: readonly [number, number], fontSize: number,
|
|
82
|
+
/** The visible area, px: a tag that would leave it is put elsewhere */
|
|
83
|
+
viewport?: Bounds) => ReadoutTag[];
|
package/dist/core/scene.d.ts
CHANGED
|
@@ -49,6 +49,16 @@ export type LayerIndex = (typeof LAYERS)[keyof typeof LAYERS];
|
|
|
49
49
|
/** What every item carries: the caller's layer it belongs to, which switches it on and off. */
|
|
50
50
|
interface SceneBase {
|
|
51
51
|
readonly group: string;
|
|
52
|
+
/**
|
|
53
|
+
* What the item draws, for a caller that marks it on hover or selection: `member:<id>`,
|
|
54
|
+
* `node:<id>`, or a load's own `source`. Items of nothing in particular (dimensions) have none.
|
|
55
|
+
*/
|
|
56
|
+
readonly entity?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Drawn only when this label is: a mark that points at a value (a maximum's ordinate, the largest
|
|
59
|
+
* displacement's dot) goes with the value when there is no room for it, rather than point at nothing.
|
|
60
|
+
*/
|
|
61
|
+
readonly requires?: SceneText;
|
|
52
62
|
}
|
|
53
63
|
export interface ScenePath extends SceneBase {
|
|
54
64
|
readonly kind: 'path';
|
|
@@ -73,6 +83,11 @@ export interface ScenePath extends SceneBase {
|
|
|
73
83
|
readonly shield?: boolean;
|
|
74
84
|
/** Drawn on from start to end when it appears; the number staggers members one after another. */
|
|
75
85
|
readonly draw?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Not drawn: the area a caller hit-tests the item it belongs to by (a distributed load's band,
|
|
88
|
+
* mostly empty between its arrows). Never an obstacle, never fitted.
|
|
89
|
+
*/
|
|
90
|
+
readonly hitArea?: boolean;
|
|
76
91
|
}
|
|
77
92
|
export type TextAlign = 'start' | 'middle' | 'end';
|
|
78
93
|
export type TextBaseline = 'top' | 'middle' | 'bottom';
|
|
@@ -87,6 +102,11 @@ export interface TextPlacement {
|
|
|
87
102
|
readonly size?: number;
|
|
88
103
|
/** Clockwise turn, degrees. */
|
|
89
104
|
readonly rotate?: number;
|
|
105
|
+
/**
|
|
106
|
+
* The spot may cross another diagram's outline, the label's halo keeping it readable: beside a
|
|
107
|
+
* value at the same point, which is where a reader looks for it, rather than further away.
|
|
108
|
+
*/
|
|
109
|
+
readonly acrossDiagrams?: boolean;
|
|
90
110
|
}
|
|
91
111
|
export interface SceneText extends SceneBase {
|
|
92
112
|
readonly kind: 'text';
|
|
@@ -106,6 +126,8 @@ export interface SceneText extends SceneBase {
|
|
|
106
126
|
readonly size?: number;
|
|
107
127
|
/** Written after `text`, smaller and lower: the x of A_x. */
|
|
108
128
|
readonly sub?: string;
|
|
129
|
+
/** The place may cross another diagram's outline (see TextPlacement). */
|
|
130
|
+
readonly acrossDiagrams?: boolean;
|
|
109
131
|
/** Other places to try, in order, when the first is taken. */
|
|
110
132
|
readonly alternatives?: readonly TextPlacement[];
|
|
111
133
|
}
|
|
@@ -129,6 +151,22 @@ export interface Transform {
|
|
|
129
151
|
}
|
|
130
152
|
export declare const project: (t: Transform, a: Anchor) => [number, number];
|
|
131
153
|
export declare const textWidth: (text: string, size: number) => number;
|
|
154
|
+
/** A superscript's size, and how far it rises above the baseline, as shares of its text's size */
|
|
155
|
+
export declare const SUP_SCALE = 0.75;
|
|
156
|
+
export declare const SUP_RISE = 0.38;
|
|
157
|
+
/** A piece of a label: written on the line, or raised as a superscript and smaller */
|
|
158
|
+
export interface TextRun {
|
|
159
|
+
readonly text: string;
|
|
160
|
+
/** The size it is written at, px, where it is not the label's own */
|
|
161
|
+
readonly size?: number;
|
|
162
|
+
/** How far it moves the baseline, px: up into a superscript, back down after it */
|
|
163
|
+
readonly dy?: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A label's text in runs, its superscript characters (a power of ten, `1.71·10⁻³`) as a real
|
|
167
|
+
* superscript: plain digits, smaller and raised, rather than the font's tiny superscript glyphs.
|
|
168
|
+
*/
|
|
169
|
+
export declare const textRuns: (text: string, size: number) => TextRun[];
|
|
132
170
|
/** A subscript's size, as a share of its text's */
|
|
133
171
|
export declare const SUB_SCALE = 0.75;
|
|
134
172
|
/** How far a subscript drops below the baseline, as a share of its text's size */
|
|
@@ -174,6 +212,7 @@ export interface Fit extends Transform {
|
|
|
174
212
|
export declare const fitScene: (items: readonly SceneItem[], box: FitBox) => Fit;
|
|
175
213
|
export interface ResolvedPath {
|
|
176
214
|
readonly group: string;
|
|
215
|
+
readonly entity?: string;
|
|
177
216
|
readonly d: string;
|
|
178
217
|
readonly layer: LayerIndex;
|
|
179
218
|
readonly tone: Tone;
|
|
@@ -184,9 +223,12 @@ export interface ResolvedPath {
|
|
|
184
223
|
readonly dash?: string;
|
|
185
224
|
readonly cap?: 'round' | 'butt';
|
|
186
225
|
readonly draw?: number;
|
|
226
|
+
/** Not to be drawn: an area to hit-test by (see ScenePath) */
|
|
227
|
+
readonly hitArea?: boolean;
|
|
187
228
|
}
|
|
188
229
|
export interface ResolvedText {
|
|
189
230
|
readonly group: string;
|
|
231
|
+
readonly entity?: string;
|
|
190
232
|
readonly x: number;
|
|
191
233
|
readonly y: number;
|
|
192
234
|
readonly text: string;
|
|
@@ -200,6 +242,7 @@ export interface ResolvedText {
|
|
|
200
242
|
}
|
|
201
243
|
export interface ResolvedCircle {
|
|
202
244
|
readonly group: string;
|
|
245
|
+
readonly entity?: string;
|
|
203
246
|
readonly cx: number;
|
|
204
247
|
readonly cy: number;
|
|
205
248
|
readonly r: number;
|
|
@@ -212,6 +255,11 @@ export interface ResolvedScene {
|
|
|
212
255
|
readonly paths: readonly ResolvedPath[];
|
|
213
256
|
readonly circles: readonly ResolvedCircle[];
|
|
214
257
|
readonly texts: readonly ResolvedText[];
|
|
258
|
+
/**
|
|
259
|
+
* What is painted, px at the transform's scale with no translation: the labels where they were
|
|
260
|
+
* placed (left-out ones not at all), without the fit-ignored hatching and hit areas.
|
|
261
|
+
*/
|
|
262
|
+
readonly bounds: Bounds;
|
|
215
263
|
}
|
|
216
264
|
export declare const pathData: (segments: readonly Segment[], t: Transform) => string;
|
|
217
265
|
/** Whether the segment p–q passes through the box (Liang-Barsky clipping). */
|
|
@@ -236,13 +284,33 @@ export interface ResolveOptions {
|
|
|
236
284
|
* hidden diagram does not keep a load's value off the place it would take.
|
|
237
285
|
*/
|
|
238
286
|
readonly shields?: ReadonlySet<string>;
|
|
287
|
+
/**
|
|
288
|
+
* Groups placed after every other label: the results, read off the structure. The others (loads,
|
|
289
|
+
* reactions, names) are what the reader was given, so they go first. With it, a label that finds
|
|
290
|
+
* no place clear of another diagram's outline may cross it, its halo keeping it readable, rather
|
|
291
|
+
* than be left out. Without it, every group is placed by priority alone.
|
|
292
|
+
*/
|
|
293
|
+
readonly lateGroups?: ReadonlySet<string>;
|
|
294
|
+
/**
|
|
295
|
+
* Groups that give way to every other label: their labels are placed last, and their lines keep
|
|
296
|
+
* no other group's label off (an editor's loads, whose values stand outside their bands while the
|
|
297
|
+
* internal forces' values may lie over a band's side).
|
|
298
|
+
*/
|
|
299
|
+
readonly yieldingGroups?: ReadonlySet<string>;
|
|
300
|
+
/**
|
|
301
|
+
* Groups whose labels are never left out: with no free place, at the place that covers the least
|
|
302
|
+
* of the labels already kept (its first place among equals).
|
|
303
|
+
*/
|
|
304
|
+
readonly keptGroups?: ReadonlySet<string>;
|
|
239
305
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Which labels to draw. By priority, a label is kept unless it would overlap one already kept,
|
|
242
|
-
* cross a member, or leave the viewport - so the figure never shows two numbers on top of each
|
|
243
|
-
* other or a number struck through by the structure.
|
|
244
|
-
*/
|
|
245
306
|
export declare const placeLabels: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => Map<SceneText, SceneText>;
|
|
246
307
|
/** Screen geometry for the scene, with the labels `placeLabels` keeps. */
|
|
308
|
+
/**
|
|
309
|
+
* The resolved paths with every run that would paint alike - same layer, group, entity and style -
|
|
310
|
+
* joined into one path: a band of thirty arrows becomes two paths (shafts, heads) instead of sixty.
|
|
311
|
+
* Paint order is kept between layers and between different styles; within a layer, alike paths
|
|
312
|
+
* gather where the first of them was. Paths that animate on (`draw`) are left alone.
|
|
313
|
+
*/
|
|
314
|
+
export declare const mergePaths: (paths: readonly ResolvedPath[]) => ResolvedPath[];
|
|
247
315
|
export declare const resolveScene: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => ResolvedScene;
|
|
248
316
|
export {};
|
package/dist/core/structure.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type InternalForce, type MemberFrame, type MemberResults, type PlotMode
|
|
|
11
11
|
import { type Anchor, type SceneItem, type TextPlacement } from './scene.js';
|
|
12
12
|
import { type Units } from './units.js';
|
|
13
13
|
/** What the caller switches on and off. Results are named by their symbol. */
|
|
14
|
-
export type PlotLayer = 'nodes' | 'nodeLabels' | 'dimensions' | 'members' | 'supports' | 'loads' | 'reactions' | 'N' | 'V' | 'M' | 'w';
|
|
14
|
+
export type PlotLayer = 'nodes' | 'nodeLabels' | 'memberLabels' | 'dimensions' | 'members' | 'supports' | 'loads' | 'reactions' | 'N' | 'V' | 'M' | 'w';
|
|
15
15
|
/** Every layer, in paint order: results under the structure, nodes on top as BuildSteps draws them. */
|
|
16
16
|
export declare const PLOT_LAYERS: readonly PlotLayer[];
|
|
17
17
|
export interface TemperatureSymbols {
|
|
@@ -28,8 +28,58 @@ export interface StructureSceneOptions {
|
|
|
28
28
|
readonly layers: ReadonlySet<PlotLayer>;
|
|
29
29
|
/** Thumbnail drawing: smaller symbols, at most two values per member, magnitudes only. */
|
|
30
30
|
readonly compact: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Sizes in place of the preset's (full or compact), px: an editor draws its members lighter, its
|
|
33
|
+
* arrows shorter and alike for loads and reactions, its moments as a nearly closed ring.
|
|
34
|
+
*/
|
|
35
|
+
readonly sizes?: Partial<SymbolSizes>;
|
|
36
|
+
/**
|
|
37
|
+
* How loads are written. `figure` (the default): with their units, a uniform load once as
|
|
38
|
+
* `q = …`. `ends`: as an editor annotates them, bare numbers (its units shown elsewhere), and a
|
|
39
|
+
* distributed load at both its ends, zero included, as students are taught to write it.
|
|
40
|
+
*/
|
|
41
|
+
readonly loadLabels?: 'figure' | 'ends';
|
|
42
|
+
/**
|
|
43
|
+
* A diagram constant along its member: its value `once`, mid-member (the default), or at both
|
|
44
|
+
* `ends`, as students are taught to annotate every segment.
|
|
45
|
+
*/
|
|
46
|
+
readonly constantDiagrams?: 'once' | 'ends';
|
|
47
|
+
/**
|
|
48
|
+
* A moment the same round a rigid corner: written `once` (the default), at the member with the
|
|
49
|
+
* most room, or at `each` member's end, as students annotate every member.
|
|
50
|
+
*/
|
|
51
|
+
readonly cornerValues?: 'once' | 'each';
|
|
52
|
+
/** Labels keep off the support symbols too, not only the members and arrows. */
|
|
53
|
+
readonly labelsAvoidSupports?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Nodes no member reaches are drawn too, with their names and supports: an editor's nodes, placed
|
|
56
|
+
* before they are connected. By default a figure leaves them out.
|
|
57
|
+
*/
|
|
58
|
+
readonly freeNodes?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* A distributed load with both components drawn as the two loads it was entered as (along and
|
|
61
|
+
* across the member for a local load, x and z for a global one), each with its own value, rather
|
|
62
|
+
* than as their resultant.
|
|
63
|
+
*/
|
|
64
|
+
readonly splitLoads?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Values of different diagrams on one ordinate line, written along it, stand side by side there,
|
|
67
|
+
* each half a line aside, rather than one pushed further out (see `sideBySide`).
|
|
68
|
+
*/
|
|
69
|
+
readonly sideBySide?: boolean;
|
|
31
70
|
readonly units: Units;
|
|
32
71
|
readonly numberFormat?: Intl.NumberFormat;
|
|
72
|
+
/**
|
|
73
|
+
* Writes the loads' values, which are given rather than worked out: an editor may leave off the
|
|
74
|
+
* zeros its results keep (10 kN, not 10.00 kN). `numberFormat` when left out.
|
|
75
|
+
*/
|
|
76
|
+
readonly loadNumberFormat?: Intl.NumberFormat;
|
|
77
|
+
/**
|
|
78
|
+
* Writes a displacement, given in display units. Displacements are orders of magnitude smaller
|
|
79
|
+
* than the forces, so an editor writes them its own way (a power of ten where `numberFormat`'s
|
|
80
|
+
* fixed decimals would round a deflection to zero).
|
|
81
|
+
*/
|
|
82
|
+
readonly displacementText?: (value: number) => string;
|
|
33
83
|
/** The temperature load's symbols, which apps write differently: the Czech EduBeam has ΔTs and ΔTd − ΔTh. */
|
|
34
84
|
readonly temperatureSymbols?: TemperatureSymbols;
|
|
35
85
|
/** Current scale in px per metre: spaces ordinates and load arrows evenly on screen. */
|
|
@@ -42,6 +92,29 @@ export interface StructureSceneOptions {
|
|
|
42
92
|
readonly diagramScale?: Partial<Record<ResultLayer, number>>;
|
|
43
93
|
/** M on the tension side (most of Europe); off draws it on the compression side. */
|
|
44
94
|
readonly momentOnTensionSide: boolean;
|
|
95
|
+
/** Positive N on the member's dashed side (local +z); off (the default), on the other. */
|
|
96
|
+
readonly normalOnDashedSide?: boolean;
|
|
97
|
+
/** Positive V on the member's dashed side (local +z); off (the default), on the other. */
|
|
98
|
+
readonly shearOnDashedSide?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* How a diagram's area is drawn: `hatch` (the default), lines across the member as drawn by
|
|
101
|
+
* hand; `solid`, a light tint; `none`, the outline alone.
|
|
102
|
+
*/
|
|
103
|
+
readonly diagramFill?: 'hatch' | 'solid' | 'none';
|
|
104
|
+
/** Write each piece's polynomial degree inside the diagram: 0°, 1°, 2°, 3°. */
|
|
105
|
+
readonly showDegrees?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Marks where the structure moves most, as a student marks w_max: a dot on the deformed shape,
|
|
108
|
+
* and a dashed line to it from where that point was.
|
|
109
|
+
*/
|
|
110
|
+
readonly displacementMarker?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* A diagram's extremes inside a member (the largest moment under a distributed load) get their
|
|
113
|
+
* ordinate drawn, from the member to the tip, as a student marks a maximum.
|
|
114
|
+
*/
|
|
115
|
+
readonly extremeOrdinates?: boolean;
|
|
116
|
+
/** Support symbols' size, as a multiple of the preset's (the editor's support size setting). */
|
|
117
|
+
readonly supportScale?: number;
|
|
45
118
|
/** The plot's font size, px: labels in a tight spot may step down from it to 10 px. */
|
|
46
119
|
readonly fontSize?: number;
|
|
47
120
|
/** Values upright (`horizontal`) or turned to run along their ordinate (`axis`), as in the app. */
|
|
@@ -58,19 +131,88 @@ export type ResultLabelMode = 'axis' | 'horizontal';
|
|
|
58
131
|
export type ReactionLabels = 'values' | 'names';
|
|
59
132
|
/** Ordinates are this far apart on screen, as in the app and the website's figures. */
|
|
60
133
|
export declare const HATCH_SPACING_PX = 7;
|
|
134
|
+
/** Symbol sizes in px: the website's figures, and a smaller set for thumbnails. */
|
|
135
|
+
declare const SIZES: {
|
|
136
|
+
readonly full: {
|
|
137
|
+
readonly member: 3.5;
|
|
138
|
+
/** A hinge's circle, radius: its own size, so a lighter member keeps a readable hinge */
|
|
139
|
+
readonly hinge: 4.5;
|
|
140
|
+
/** A moment load's arc: how far round it runs, its weight and its head */
|
|
141
|
+
readonly arcSweep: 270;
|
|
142
|
+
readonly arcWidth: 1.75;
|
|
143
|
+
readonly arcHead: 8;
|
|
144
|
+
readonly arcHeadHalf: 3.5;
|
|
145
|
+
readonly pointShaft: 3;
|
|
146
|
+
readonly pointHead: 12;
|
|
147
|
+
readonly pointHeadWidth: 14;
|
|
148
|
+
readonly pointArrow: 52;
|
|
149
|
+
readonly udlArrow: 32;
|
|
150
|
+
readonly udlSpacing: 18;
|
|
151
|
+
readonly reaction: 46;
|
|
152
|
+
readonly reactionShaft: 1.75;
|
|
153
|
+
readonly reactionHead: 9;
|
|
154
|
+
readonly reactionHeadWidth: 9;
|
|
155
|
+
readonly reactionGap: 11;
|
|
156
|
+
/** A reaction's arrow clear of a moment's ring round the same node */
|
|
157
|
+
readonly reactionArcGap: 8;
|
|
158
|
+
/** A node's label from the node, and from it when a moment's ring surrounds it */
|
|
159
|
+
readonly nodeLabelGap: 9;
|
|
160
|
+
readonly arcLabelGap: 24;
|
|
161
|
+
readonly arcLabelFirst: 24;
|
|
162
|
+
readonly arc: 15;
|
|
163
|
+
readonly reactionArc: 20;
|
|
164
|
+
/** A moment reaction's arc: a half circle on the support's side, clear of the diagrams */
|
|
165
|
+
readonly reactionArcSweep: 190;
|
|
166
|
+
readonly deformed: 2.25;
|
|
167
|
+
};
|
|
168
|
+
readonly compact: {
|
|
169
|
+
readonly member: 2.75;
|
|
170
|
+
readonly hinge: 3.75;
|
|
171
|
+
readonly arcSweep: 270;
|
|
172
|
+
readonly arcWidth: 1.75;
|
|
173
|
+
readonly arcHead: 8;
|
|
174
|
+
readonly arcHeadHalf: 3.5;
|
|
175
|
+
readonly pointShaft: 2.25;
|
|
176
|
+
readonly pointHead: 9;
|
|
177
|
+
readonly pointHeadWidth: 10;
|
|
178
|
+
readonly pointArrow: 34;
|
|
179
|
+
readonly udlArrow: 22;
|
|
180
|
+
readonly udlSpacing: 14;
|
|
181
|
+
readonly reaction: 32;
|
|
182
|
+
readonly reactionShaft: 1.75;
|
|
183
|
+
readonly reactionHead: 9;
|
|
184
|
+
readonly reactionHeadWidth: 9;
|
|
185
|
+
readonly reactionGap: 8;
|
|
186
|
+
readonly reactionArcGap: 8;
|
|
187
|
+
readonly nodeLabelGap: 9;
|
|
188
|
+
readonly arcLabelGap: 24;
|
|
189
|
+
readonly arcLabelFirst: 24;
|
|
190
|
+
readonly arc: 11;
|
|
191
|
+
readonly reactionArc: 15;
|
|
192
|
+
readonly reactionArcSweep: 190;
|
|
193
|
+
readonly deformed: 1.75;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
/** Every symbol's size, px: line weights, arrow lengths and heads, arcs. */
|
|
197
|
+
export type SymbolSizes = {
|
|
198
|
+
readonly [K in keyof (typeof SIZES)['full']]: number;
|
|
199
|
+
};
|
|
61
200
|
type Vec = {
|
|
62
201
|
readonly x: number;
|
|
63
202
|
readonly y: number;
|
|
64
203
|
};
|
|
65
204
|
/** Which way a positive value is drawn, along the member's local z: +1 toward local +z. */
|
|
66
|
-
export declare const diagramSide: (q: InternalForce, momentOnTensionSide: boolean
|
|
205
|
+
export declare const diagramSide: (q: InternalForce, momentOnTensionSide: boolean, dashed?: {
|
|
206
|
+
readonly normalOnDashedSide?: boolean;
|
|
207
|
+
readonly shearOnDashedSide?: boolean;
|
|
208
|
+
}) => 1 | -1;
|
|
67
209
|
/**
|
|
68
210
|
* Where a value goes: just beyond the tip of the ordinate it denotes, along that ordinate, so it
|
|
69
211
|
* reads as the ordinate's continuation. With `axis` the text turns to run along the ordinate
|
|
70
212
|
* (across the member), as the app writes it, never upside down. Each further place moves it
|
|
71
213
|
* outward along the same ordinate - it never leaves its tip.
|
|
72
214
|
*/
|
|
73
|
-
export declare const tipPlacements: (tip: Anchor, out: Vec, mode: ResultLabelMode, gaps?: number[]) => TextPlacement[];
|
|
215
|
+
export declare const tipPlacements: (tip: Anchor, out: Vec, mode: ResultLabelMode, gaps?: readonly number[], asides?: readonly number[]) => TextPlacement[];
|
|
74
216
|
/** Every member carries one constant normal force and no member loads: a truss, read bar by bar. */
|
|
75
217
|
export declare const isBarStructure: (model: PlotModel, results: Readonly<Record<string, MemberResults>>) => boolean;
|
|
76
218
|
/** px per SI unit for each result, from the largest value anywhere in the structure. */
|
package/dist/core/svg.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PlotModel } from './model.js';
|
|
2
|
-
import { type Tone } from './scene.js';
|
|
2
|
+
import { type ResolvedScene, type Tone } from './scene.js';
|
|
3
3
|
import { type PlotLayer, type ReactionLabels, type ResultLabelMode, type TemperatureSymbols } from './structure.js';
|
|
4
4
|
import { type Units } from './units.js';
|
|
5
5
|
/** Concrete colours for a file that has no page around it: the EduBeam app's, on white. */
|
|
@@ -48,3 +48,29 @@ export interface StructureSvgOptions {
|
|
|
48
48
|
* `paint-order`.
|
|
49
49
|
*/
|
|
50
50
|
export declare const structureSvg: (model: PlotModel, options?: StructureSvgOptions) => string;
|
|
51
|
+
export interface SceneSvgOptions {
|
|
52
|
+
readonly colors?: Partial<Record<Tone | 'paper', string>>;
|
|
53
|
+
/** The labels' size where a label has none of its own, px. Default 13. */
|
|
54
|
+
readonly fontSize?: number;
|
|
55
|
+
readonly fontFamily?: string;
|
|
56
|
+
/** Paint the background in `paper`; off leaves it transparent. Default on. */
|
|
57
|
+
readonly background?: boolean;
|
|
58
|
+
/** Accessible name, written as the SVG's `<title>`. */
|
|
59
|
+
readonly title?: string;
|
|
60
|
+
}
|
|
61
|
+
/** How a scene's shapes and labels are written: its colours and its labels' size. */
|
|
62
|
+
export type SceneMarkupOptions = Pick<SceneSvgOptions, 'colors' | 'fontSize'>;
|
|
63
|
+
/**
|
|
64
|
+
* A scene already laid out, as SVG markup without the root element: its shapes layer by layer in
|
|
65
|
+
* paint order, then every label, each with its halo as a text of its own underneath (for programs
|
|
66
|
+
* that ignore `paint-order`). For an application that places the drawing in an SVG of its own.
|
|
67
|
+
*/
|
|
68
|
+
export declare const sceneMarkup: (resolved: Pick<ResolvedScene, "paths" | "circles" | "texts">, options?: SceneMarkupOptions) => string;
|
|
69
|
+
/**
|
|
70
|
+
* A scene already laid out, as the text of a standalone `.svg` file of the given size: for an
|
|
71
|
+
* application that lays a structure out its own way and saves it as `structureSvg` saves its own.
|
|
72
|
+
*/
|
|
73
|
+
export declare const sceneSvg: (resolved: Pick<ResolvedScene, "paths" | "circles" | "texts">, size: {
|
|
74
|
+
readonly width: number;
|
|
75
|
+
readonly height: number;
|
|
76
|
+
}, options?: SceneSvgOptions) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ export { EduBeamPlot } from './plugin.js';
|
|
|
6
6
|
export { DEFAULT_PLOT_TEXTS, PLOT_TEXTS, usePlotTexts, type PlotTexts } from './components/texts.js';
|
|
7
7
|
export { modelFromSolver, type FromSolverOptions } from './core/fromSolver.js';
|
|
8
8
|
export { layoutStructure, alternativeResultGroups, type StructureLayout } from './core/layout.js';
|
|
9
|
-
export { structureSvg, PRINT_COLORS, type StructureSvgOptions } from './core/svg.js';
|
|
9
|
+
export { structureSvg, sceneSvg, sceneMarkup, PRINT_COLORS, type StructureSvgOptions, type SceneSvgOptions, type SceneMarkupOptions, } from './core/svg.js';
|
|
10
10
|
export * from './core/model.js';
|
|
11
11
|
export * from './core/polynomial.js';
|
|
12
12
|
export * from './core/units.js';
|
|
13
13
|
export { supportKind, supportPlacement, supportGlyph, glyphReach, type SupportKind, type SupportPlacement, type GlyphPart, } from './core/supports.js';
|
|
14
|
-
export { buildStructureScene, defaultResultLayer, diagramScales, diagramSide, isBarStructure, memberFrames, HATCH_SPACING_PX, DEFAULT_TEMPERATURE_SYMBOLS, PLOT_LAYERS, RESULT_LAYERS, type PlotLayer, type TemperatureSymbols, type ReactionLabels, type ResultLabelMode, type ResultLayer, type StructureSceneOptions, tipPlacements, } from './core/structure.js';
|
|
15
|
-
export { fitScene, placeLabels, resolveScene, sceneBounds, project, type Anchor, type Fit, type FitBox, type SceneItem, type ResolvedScene, type ResolvedPath, type ResolvedText, type ResolvedCircle, type ResolveOptions, type SceneText, type Bounds, type TextPlacement, type Transform, type Tone, } from './core/scene.js';
|
|
16
|
-
export { readMember, readoutAt, readoutMarks, formatReadout, type Readout, type ReadoutMark, type ReadoutQuantity, type SidedValue, } from './core/readout.js';
|
|
14
|
+
export { buildStructureScene, defaultResultLayer, diagramScales, diagramSide, isBarStructure, memberFrames, HATCH_SPACING_PX, DEFAULT_TEMPERATURE_SYMBOLS, PLOT_LAYERS, RESULT_LAYERS, type PlotLayer, type TemperatureSymbols, type ReactionLabels, type ResultLabelMode, type ResultLayer, type StructureSceneOptions, type SymbolSizes, tipPlacements, } from './core/structure.js';
|
|
15
|
+
export { fitScene, placeLabels, resolveScene, mergePaths, sceneBounds, textRuns, type TextRun, project, type Anchor, type Fit, type FitBox, type SceneItem, type ResolvedScene, type ResolvedPath, type ResolvedText, type ResolvedCircle, type ResolveOptions, type SceneText, type Bounds, type TextPlacement, type Transform, type Tone, } from './core/scene.js';
|
|
16
|
+
export { readMember, readoutAt, readoutMarks, formatReadout, placeReadoutTags, type ReadoutTag, type Readout, type ReadoutMark, type ReadoutQuantity, type SidedValue, } from './core/readout.js';
|
|
17
17
|
export { beamLine, lineDiagram, lineModel, pointLoadAt, rowOutline, rowOrdinates, rowRange, rowPeaks, rowBreaks, type BeamLine, type LineMember, type RowPeak, type StackRow, } from './core/stack.js';
|