@mark1russell7/visuals 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,162 @@
1
+ import { Point3, Ring, Transform3 } from "@mark1russell7/layout-contract";
2
+ /** These are the levels of a mark, from the lowest to the highest. */
3
+ declare const LEVELS: readonly ["unknown", "ok", "near", "over"];
4
+ /**
5
+ * A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.
6
+ * A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.
7
+ */
8
+ type Level = (typeof LEVELS)[number];
9
+ /**
10
+ * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.
11
+ * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.
12
+ */
13
+ declare function levelRank(level: Level): number;
14
+ /** These are the shapes of the sign of a level. */
15
+ declare const LEVEL_SHAPES: readonly ["ring", "disc", "triangle", "square"];
16
+ /** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */
17
+ type LevelShape = (typeof LEVEL_SHAPES)[number];
18
+ /**
19
+ * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
20
+ * The level `unknown` has a ring, and so has a record with no level.
21
+ */
22
+ declare function levelShape(level: Level | undefined): LevelShape;
23
+ /** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */
24
+ interface ShapeOutline {
25
+ /** The radius of the circle through the corners, for a disc with the radius 1. */
26
+ readonly radius: number;
27
+ /** The number of the sides. */
28
+ readonly sides: number;
29
+ /** The angle of the first corner, in radians, counter-clockwise from the x axis. */
30
+ readonly start: number;
31
+ /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */
32
+ readonly hole: number;
33
+ }
34
+ /**
35
+ * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
36
+ * A triangle and a square with the radius of the disc look small, so they are larger.
37
+ */
38
+ declare const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>>;
39
+ /**
40
+ * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
41
+ * The center of the sign is the origin, and `radius` is the radius of a disc.
42
+ */
43
+ declare function shapeRing(shape: LevelShape, radius?: number): Ring;
44
+ /** A point of a surface, and the direction out of the surface. */
45
+ interface Frame {
46
+ /** The point. */
47
+ readonly at: Point3;
48
+ /** The unit vector out of the surface at the point. */
49
+ readonly out: Point3;
50
+ }
51
+ /** These are the types of a mark. */
52
+ declare const MARK_TYPES: readonly ["point", "run", "link", "field", "meter"];
53
+ /** A type of a mark. */
54
+ type MarkType = (typeof MARK_TYPES)[number];
55
+ /**
56
+ * The parts that each mark has. A mark has no shape and no color.
57
+ * A viewer gets the shape from the level, and the color from the level and its theme. Thus a mark does not use color alone.
58
+ */
59
+ interface MarkBase {
60
+ /** The name of the record of the mark. The pointer and the selection of a viewer use this name. */
61
+ readonly record: string;
62
+ /** A word of the producer for the legend and the filter, for example `outlet`. */
63
+ readonly kind: string;
64
+ /** The level of the mark. The producer calculates it. */
65
+ readonly level: Level;
66
+ /** One line of text: the name of the mark for a person and for a screen reader. */
67
+ readonly label: string;
68
+ }
69
+ /** A mark at one point of a surface, for example an outlet, a tap or a lamp. */
70
+ interface PointMark extends MarkBase {
71
+ readonly type: "point";
72
+ /** The point, and the direction out of its surface. */
73
+ readonly frame: Frame;
74
+ /** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */
75
+ readonly size?: number | undefined;
76
+ }
77
+ /** A mark along a path on surfaces, for example a cable, a pipe or a duct. */
78
+ interface RunMark extends MarkBase {
79
+ readonly type: "run";
80
+ /** The points of the path, in sequence. Each point has its own direction, so a run can go across surfaces. A path has 2 or more points. */
81
+ readonly path: readonly Frame[];
82
+ /** The width of the run, in the unit of the space. */
83
+ readonly width: number;
84
+ }
85
+ /** One end of a link. */
86
+ interface LinkEnd {
87
+ /** The name of the record at this end. A viewer shows the link when the record of one end is selected or under the pointer. */
88
+ readonly record: string;
89
+ /** The point of this end. */
90
+ readonly at: Point3;
91
+ }
92
+ /** A mark between two records, for example a power line from an outlet to a computer. */
93
+ interface LinkMark extends MarkBase {
94
+ readonly type: "link";
95
+ readonly from: LinkEnd;
96
+ readonly to: LinkEnd;
97
+ }
98
+ /** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */
99
+ interface FieldScale {
100
+ /** The value of the first color. It is less than `max`. */
101
+ readonly min: number;
102
+ /** The value of the last color. */
103
+ readonly max: number;
104
+ /** The text of the unit of the values, for example `lx`. */
105
+ readonly unit: string;
106
+ }
107
+ /** A grid of values on a plane, for example the light on a floor or the heat of a wall. */
108
+ interface FieldMark extends MarkBase {
109
+ readonly type: "field";
110
+ /** The corner of the first cell, and the direction out of the plane. */
111
+ readonly frame: Frame;
112
+ /** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */
113
+ readonly across: Point3;
114
+ /** The length of a side of a cell, in the unit of the space. */
115
+ readonly cell: number;
116
+ /** The number of the columns. */
117
+ readonly columns: number;
118
+ /** The number of the rows. */
119
+ readonly rows: number;
120
+ /**
121
+ * The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.
122
+ * A cell with no value has `null`, because JSON has no NaN.
123
+ */
124
+ readonly values: readonly (number | null)[];
125
+ readonly scale: FieldScale;
126
+ }
127
+ /**
128
+ * A value against a limit, for example the load of a circuit. A meter has no place.
129
+ * A page draws it in a panel, and a 3D view ignores it.
130
+ */
131
+ interface MeterMark extends MarkBase {
132
+ readonly type: "meter";
133
+ readonly value: number;
134
+ /**
135
+ * The limit of the value. A meter with no limit has no `limit`, for example a circuit with a known load and no known breaker.
136
+ * A page shows only the value and the unit of that meter. A limit of 0 is a real limit, so it is not a sign for no limit.
137
+ */
138
+ readonly limit?: number | undefined;
139
+ /** The text of the unit of the value and of the limit, for example `W`. */
140
+ readonly unit: string;
141
+ }
142
+ /**
143
+ * A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.
144
+ * Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.
145
+ */
146
+ type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;
147
+ /** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */
148
+ declare function fieldRowStep(field: FieldMark): Point3;
149
+ /** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */
150
+ declare function fieldCellCenter(field: FieldMark, column: number, row: number): Point3;
151
+ /** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */
152
+ declare function fieldValue(field: FieldMark, column: number, row: number): number | null;
153
+ /**
154
+ * This function gives the marks in a different space. Each point gets the transform, and each direction gets only its rotation.
155
+ * An example is the marks of a room with the z axis up, for a stage with the y axis up.
156
+ *
157
+ * A transform has no scale, so each length stays: the size of a point, the width of a run and the cell of a field.
158
+ * A meter has no place, so it stays. Each other part of a mark stays, and the function changes no mark of the list.
159
+ */
160
+ declare function transformMarks(marks: readonly Mark[], transform: Transform3): readonly Mark[];
161
+ export { levelRank as C, ShapeOutline as S, shapeRing as T, LEVELS as _, LinkMark as a, LevelShape as b, MarkBase as c, PointMark as d, RunMark as f, transformMarks as g, fieldValue as h, LinkEnd as i, MarkType as l, fieldRowStep as m, FieldScale as n, MARK_TYPES as o, fieldCellCenter as p, Frame as r, Mark as s, FieldMark as t, MeterMark as u, LEVEL_SHAPES as v, levelShape as w, SHAPE_OUTLINES as x, Level as y };
162
+ //# sourceMappingURL=mark-ubn709Qw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mark-ubn709Qw.d.ts","names":[],"sources":["../src/marks/levels.ts","../src/marks/mark.ts"],"mappings":";;cAGa;;;;;KAMD,gBAAgB;;;;;iBAMZ,UAAU,OAAO;;cAKpB;;KAGD,qBAAqB;;;;;iBAMjB,WAAW,OAAO,oBAAoB;;UAKrC;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;cAOE,gBAAgB,SAAS,OAAO,YAAY;;;;;iBAWzC,UAAU,OAAO,YAAY,kBAAqB;;UCxDjD;;WAEN,IAAI;;WAEJ,KAAK;;;cAIH;;KAGD,mBAAmB;;;;;UAMd;;WAEN;;WAEA;;WAEA,OAAO;;WAEP;;;UAIM,kBAAkB;WACxB;;WAEA,OAAO;;WAEP;;;UAIM,gBAAgB;WACtB;;WAEA,eAAe;;WAEf;;;UAIM;;WAEN;;WAEA,IAAI;;;UAIE,iBAAiB;WACvB;WACA,MAAM;WACN,IAAI;;;UAIE;;WAEN;;WAEA;;WAEA;;;UAIM,kBAAkB;WACxB;;WAEA,OAAO;;WAEP,QAAQ;;WAER;;WAEA;;WAEA;;;;;WAKA;WACA,OAAO;;;;;;UAOD,kBAAkB;WACxB;WACA;;;;;WAKA;;WAEA;;;;;;KAOC,OAAO,YAAY,UAAU,WAAW,YAAY;;iBAGhD,aAAa,OAAO,YAAY;;iBAKhC,gBAAgB,OAAO,WAAW,gBAAgB,cAAc;;iBAOhE,WAAW,OAAO,WAAW,gBAAgB;;;;;;;;iBAiB7C,eAAe,gBAAgB,QAAQ,WAAW,sBAAsB"}
@@ -0,0 +1,67 @@
1
+ import { s as Mark, y as Level } from "./mark-ubn709Qw.js";
2
+ import { r as StageContent } from "./stage-DmFfah2e.js";
3
+ import { t as StageTheme } from "./theme-3EGbXXoP.js";
4
+ /** The colors of the marks of a stage. Each color is a CSS hex color, for example `#22364a`. */
5
+ interface MarkersTheme extends StageTheme {
6
+ /** The color of the marks of each level. */
7
+ readonly levels: Readonly<Record<Level, string>>;
8
+ /** The color of the line around a sign and around a run. Give the color of the page, so a mark is clear on each solid. */
9
+ readonly halo: string;
10
+ /** The color of the line around a mark whose record has a highlight. */
11
+ readonly accent: string;
12
+ /**
13
+ * The colors of a field, from the value `min` of its scale to the value `max`.
14
+ * A value between two colors gets a mix of them. A list with no color gives the color of the level of the field.
15
+ */
16
+ readonly field: readonly string[];
17
+ /** The part of a field that is not clear, from 0 to 1. The default is 0.8. */
18
+ readonly fieldOpacity?: number | undefined;
19
+ }
20
+ /** The options of the marks of a stage. */
21
+ interface MarkersOptions {
22
+ /** The radius of the sign of a point with no size, in CSS pixels. The default is `SIGN_RADIUS`. */
23
+ readonly signRadius?: number | undefined;
24
+ /** The width of the line of a link, in CSS pixels. The default is 2. */
25
+ readonly linkWidth?: number | undefined;
26
+ /** The lengths of a dash and of a gap of a link, in CSS pixels. The default is a dash of 6 and a gap of 4. */
27
+ readonly linkDash?: readonly [dash: number, gap: number] | undefined;
28
+ /**
29
+ * The distance of a sign and of a field from their surface, in the unit of the space.
30
+ * It is only for the test of what hides a mark: the surface of a mark does not hide it.
31
+ * The default is 1/400 of the size of the space of the marks.
32
+ */
33
+ readonly lift?: number | undefined;
34
+ }
35
+ /** The content of a stage that draws marks. The value of a pick is the mark. */
36
+ interface MarkersContent extends StageContent<Mark, MarkersTheme> {
37
+ /**
38
+ * This function shows only the marks that a test accepts, for example the marks of one kind. A mark that the picture does not show gets no pick.
39
+ * Start `refresh` of the stage after it. A test that accepts each mark shows all of them again.
40
+ */
41
+ show(test: (mark: Mark) => boolean): void;
42
+ }
43
+ /** The radius of the sign of a point with no size, in CSS pixels. The sign of a disc has this radius. */
44
+ export declare const SIGN_RADIUS = 7;
45
+ /**
46
+ * This function gives the radius of the sign of a level with the line around it, in CSS pixels.
47
+ * `radius` is the radius of the sign of a disc. Give the result to the field `clear` of a label, so the text stays off the sign.
48
+ */
49
+ export declare function signReach(level: Level, radius?: number): number;
50
+ /**
51
+ * This function makes the content of a stage that draws marks. Examine the marks with `checkMarks` first.
52
+ *
53
+ * - A point is a sign with the shape and the color of its level. A sign looks at the camera.
54
+ * A sign with no size keeps its size in the picture.
55
+ * - A run is a round line with its width in the space. Its center is half of its width above its surface.
56
+ * - A link is a dashed line. The picture shows it while its record, or the record of one of its ends, has a highlight.
57
+ * - A field is a grid of colors on its plane. A cell with no value is clear.
58
+ * - A meter has no place, so the content ignores it.
59
+ *
60
+ * A mark that a solid of an earlier content hides is less clear, and a mark with a highlight stays solid.
61
+ * A sign gets a pick before each other record, and a run gets a pick before a field.
62
+ * A run and a field give the distance of their pick.
63
+ * Put the content after the content of the solids in `stackContents`.
64
+ */
65
+ export declare function createMarkers(marks: readonly Mark[], options?: MarkersOptions): MarkersContent;
66
+ export type { MarkersContent, MarkersOptions, MarkersTheme };
67
+ //# sourceMappingURL=markers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markers.d.ts","names":[],"sources":["../src/markers/content.ts"],"mappings":";;;;UA4BiB,qBAAqB;;WAE3B,QAAQ,SAAS,OAAO;;WAExB;;WAEA;;;;;WAKA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA,qBAAqB,cAAc;;;;;;WAMnC;;;UAIM,uBAAuB,aAAa,MAAM;;;;;EAKzD,KAAK,OAAO,MAAM;;;qBAIP;;;;;wBAqCG,UAAU,OAAO,OAAO;;;;;;;;;;;;;;;;wBAuNxB,cAAc,gBAAgB,QAAQ,UAAS,iBAAsB"}