@mark1russell7/visuals 0.2.4 → 0.3.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.
package/README.md CHANGED
@@ -382,7 +382,7 @@ shapeRing("triangle").length; // => 3: the corners of the sign, counter-clockwis
382
382
  | `run` | A list of frames and a width | A cable, a pipe, a duct |
383
383
  | `link` | Two ends, each with a record name and a point | A power line from an outlet to a computer |
384
384
  | `field` | A grid of values on a plane, and a scale | Light in lux, sound in decibels, heat |
385
- | `meter` | A value, a limit and the text of the unit | The load of a circuit against its limit |
385
+ | `meter` | A value, the text of the unit, and a limit when there is one | The load of a circuit against its limit |
386
386
 
387
387
  - Each mark has a record name, a kind, a level and a label. The kind is a word of the producer for the legend and the filter.
388
388
  - A frame is a point of a surface and the unit vector out of the surface.
@@ -392,6 +392,7 @@ shapeRing("triangle").length; // => 3: the corners of the sign, counter-clockwis
392
392
  - A viewer draws the marks in the sequence of `levelRank`, so the worst level is always in view.
393
393
  - A field has its values row by row, with `null` for a cell with no value. `fieldValue` and `fieldCellCenter` read a cell.
394
394
  - A meter has no place. A page draws it in a panel, and a 3D view ignores it.
395
+ - A meter with no limit has no `limit`. A page shows only its value and its unit.
395
396
  - Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.
396
397
 
397
398
  `checkMarks` gives the faults of a list, each with a code, the index of its mark and the part with the fault. It examines the values that the types do not hold:
package/build/marks.d.ts CHANGED
@@ -131,7 +131,11 @@ interface FieldMark extends MarkBase {
131
131
  interface MeterMark extends MarkBase {
132
132
  readonly type: "meter";
133
133
  readonly value: number;
134
- readonly limit: 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;
135
139
  /** The text of the unit of the value and of the limit, for example `W`. */
136
140
  readonly unit: string;
137
141
  }
@@ -1 +1 @@
1
- {"version":3,"file":"marks.d.ts","names":[],"sources":["../src/marks/levels.ts","../src/marks/mark.ts","../src/marks/check.ts"],"mappings":";;qBAGa;;;;;KAMD,gBAAgB;;;;;wBAMZ,UAAU,OAAO;;qBAKpB;;KAGD,qBAAqB;;;;;wBAMjB,WAAW,OAAO,oBAAoB;;UAKrC;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;qBAOE,gBAAgB,SAAS,OAAO,YAAY;;;;;wBAWzC,UAAU,OAAO,YAAY,kBAAqB;;UCxDjD;;WAEN,IAAI;;WAEJ,KAAK;;;qBAIH;;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;WACA;;WAEA;;;;;;KAOC,OAAO,YAAY,UAAU,WAAW,YAAY;;wBAGhD,aAAa,OAAO,YAAY;;wBAKhC,gBAAgB,OAAO,WAAW,gBAAgB,cAAc;;wBAOhE,WAAW,OAAO,WAAW,gBAAgB;;;;;;;;;;;;;;;;qBC5GhD;;KAgBD,wBAAwB;;UAGnB;WACN,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;qBAOE;;;;;;;wBAQG,WAAW,gBAAgB,kBAAkB"}
1
+ {"version":3,"file":"marks.d.ts","names":[],"sources":["../src/marks/levels.ts","../src/marks/mark.ts","../src/marks/check.ts"],"mappings":";;qBAGa;;;;;KAMD,gBAAgB;;;;;wBAMZ,UAAU,OAAO;;qBAKpB;;KAGD,qBAAqB;;;;;wBAMjB,WAAW,OAAO,oBAAoB;;UAKrC;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;qBAOE,gBAAgB,SAAS,OAAO,YAAY;;;;;wBAWzC,UAAU,OAAO,YAAY,kBAAqB;;UCxDjD;;WAEN,IAAI;;WAEJ,KAAK;;;qBAIH;;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;;wBAGhD,aAAa,OAAO,YAAY;;wBAKhC,gBAAgB,OAAO,WAAW,gBAAgB,cAAc;;wBAOhE,WAAW,OAAO,WAAW,gBAAgB;;;;;;;;;;;;;;;;qBChHhD;;KAgBD,wBAAwB;;UAGnB;WACN,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;qBAOE;;;;;;;wBAQG,WAAW,gBAAgB,kBAAkB"}
package/build/marks.js CHANGED
@@ -195,7 +195,7 @@ function checkMarks(marks) {
195
195
  }
196
196
  case "meter":
197
197
  finite("value", mark.value);
198
- finite("limit", mark.limit);
198
+ if (mark.limit !== void 0) finite("limit", mark.limit);
199
199
  break;
200
200
  default: fault("type", "type", `the type is not known: ${String(mark.type)}`);
201
201
  }
@@ -1 +1 @@
1
- {"version":3,"file":"marks.js","names":[],"sources":["../src/marks/levels.ts","../src/marks/check.ts","../src/marks/mark.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\n\n/** These are the levels of a mark, from the lowest to the highest. */\nexport const LEVELS: readonly [\"unknown\", \"ok\", \"near\", \"over\"] = [\"unknown\", \"ok\", \"near\", \"over\"];\n\n/**\n * A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.\n * A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.\n */\nexport type Level = (typeof LEVELS)[number];\n\n/**\n * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.\n * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.\n */\nexport function levelRank(level: Level): number {\n return LEVELS.indexOf(level);\n}\n\n/** These are the shapes of the sign of a level. */\nexport const LEVEL_SHAPES: readonly [\"ring\", \"disc\", \"triangle\", \"square\"] = [\"ring\", \"disc\", \"triangle\", \"square\"];\n\n/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */\nexport type LevelShape = (typeof LEVEL_SHAPES)[number];\n\n/**\n * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.\n * The level `unknown` has a ring, and so has a record with no level.\n */\nexport function levelShape(level: Level | undefined): LevelShape {\n return level === \"ok\" ? \"disc\" : level === \"near\" ? \"triangle\" : level === \"over\" ? \"square\" : \"ring\";\n}\n\n/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */\nexport interface ShapeOutline {\n /** The radius of the circle through the corners, for a disc with the radius 1. */\n readonly radius: number;\n /** The number of the sides. */\n readonly sides: number;\n /** The angle of the first corner, in radians, counter-clockwise from the x axis. */\n readonly start: number;\n /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */\n readonly hole: number;\n}\n\n/**\n * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.\n * A triangle and a square with the radius of the disc look small, so they are larger.\n */\nexport const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>> = {\n ring: { radius: 1, sides: 40, start: 0, hole: 0.52 },\n disc: { radius: 1, sides: 40, start: 0, hole: 0 },\n triangle: { radius: 1.3, sides: 3, start: Math.PI / 2, hole: 0 },\n square: { radius: 1.25, sides: 4, start: Math.PI / 4, hole: 0 },\n};\n\n/**\n * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.\n * The center of the sign is the origin, and `radius` is the radius of a disc.\n */\nexport function shapeRing(shape: LevelShape, radius: number = 1): Ring {\n const outline = SHAPE_OUTLINES[shape];\n return Array.from({ length: outline.sides }, (_, index): readonly [number, number] => {\n const angle = outline.start + (index * 2 * Math.PI) / outline.sides;\n return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];\n });\n}\n","import { dot3, length3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport { LEVELS } from \"./levels.ts\";\nimport type { Frame, Mark } from \"./mark.ts\";\n\n/**\n * These are the codes of the faults of a mark:\n * - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.\n * - `level`: the level of the mark is not known.\n * - `name`: a record name or the kind is empty.\n * - `label`: the label is empty, or it has more than one line.\n * - `number`: a number is not finite.\n * - `direction`: a direction is not a unit vector.\n * - `angle`: the column step of a field is not at a right angle to the direction out of its plane.\n * - `size`: a size, a width or a cell is not more than 0.\n * - `grid`: the number of the columns or of the rows of a field is not a whole number of 1 or more.\n * - `values`: a field does not have one value for each cell.\n * - `scale`: the `min` of the scale of a field is not less than its `max`.\n * - `path`: a run has fewer than 2 points.\n */\nexport const MARK_FAULT_CODES: readonly [\"type\", \"level\", \"name\", \"label\", \"number\", \"direction\", \"angle\", \"size\", \"grid\", \"values\", \"scale\", \"path\"] = [\n \"type\",\n \"level\",\n \"name\",\n \"label\",\n \"number\",\n \"direction\",\n \"angle\",\n \"size\",\n \"grid\",\n \"values\",\n \"scale\",\n \"path\",\n];\n\n/** A code of a fault of a mark. */\nexport type MarkFaultCode = (typeof MARK_FAULT_CODES)[number];\n\n/** One fault of a mark of a list. */\nexport interface MarkFault {\n readonly code: MarkFaultCode;\n /** The index of the mark in the list. */\n readonly index: number;\n /** The record name of the mark. */\n readonly record: string;\n /** The part of the mark with the fault, for example `path[2].out`. */\n readonly part: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n}\n\n/**\n * The tolerance of a direction. A unit vector has the length 1 with this tolerance.\n * Two directions are at a right angle when their dot product is 0 with this tolerance.\n */\nexport const DIRECTION_TOLERANCE = 1e-6;\n\n/**\n * This function gives the faults of a list of marks, in the sequence of the list. A list with no fault gives an empty list.\n * It examines the values that the types do not hold: finite numbers, unit vectors, sizes, the grid of a field and the names.\n * A producer of marks uses it as a gate in its tests, and a viewer uses it on a list that it did not make.\n * It does not examine the form of a mark: read a list from JSON through a schema first.\n */\nexport function checkMarks(marks: readonly Mark[]): readonly MarkFault[] {\n const faults: MarkFault[] = [];\n marks.forEach((mark, index) => {\n const fault = (code: MarkFaultCode, part: string, message: string): void => {\n faults.push({ code, index, record: mark.record, part, message });\n };\n const finite = (part: string, value: number): boolean => {\n if (Number.isFinite(value)) return true;\n fault(\"number\", part, `${part} is not a finite number: ${String(value)}`);\n return false;\n };\n const point = (part: string, value: Point3): boolean => {\n const x = finite(`${part}.x`, value.x);\n const y = finite(`${part}.y`, value.y);\n const z = finite(`${part}.z`, value.z);\n return x && y && z;\n };\n const direction = (part: string, value: Point3): boolean => {\n if (!point(part, value)) return false;\n const length = length3(value);\n if (Math.abs(length - 1) <= DIRECTION_TOLERANCE) return true;\n fault(\"direction\", part, `${part} is not a unit vector: its length is ${String(length)}`);\n return false;\n };\n const frame = (part: string, value: Frame): boolean => {\n const at = point(`${part}.at`, value.at);\n const out = direction(`${part}.out`, value.out);\n return at && out;\n };\n const positive = (part: string, value: number): void => {\n if (finite(part, value) && value <= 0) fault(\"size\", part, `${part} is not more than 0: ${String(value)}`);\n };\n const count = (part: string, value: number): boolean => {\n if (Number.isInteger(value) && value >= 1) return true;\n fault(\"grid\", part, `${part} is not a whole number of 1 or more: ${String(value)}`);\n return false;\n };\n\n if (mark.record === \"\") fault(\"name\", \"record\", \"the mark has no record name\");\n if (mark.kind === \"\") fault(\"name\", \"kind\", \"the mark has no kind\");\n if (!(LEVELS as readonly string[]).includes(mark.level)) fault(\"level\", \"level\", `the level is not known: ${String(mark.level)}`);\n if (mark.label.trim() === \"\") fault(\"label\", \"label\", \"the mark has no label\");\n else if (/[\\r\\n]/.test(mark.label)) fault(\"label\", \"label\", \"the label has more than one line\");\n\n switch (mark.type) {\n case \"point\":\n frame(\"frame\", mark.frame);\n if (mark.size !== undefined) positive(\"size\", mark.size);\n break;\n case \"run\":\n if (mark.path.length < 2) fault(\"path\", \"path\", `the path has ${String(mark.path.length)} points, and a run needs 2 or more`);\n mark.path.forEach((step, at) => frame(`path[${String(at)}]`, step));\n positive(\"width\", mark.width);\n break;\n case \"link\":\n for (const [name, end] of [\n [\"from\", mark.from],\n [\"to\", mark.to],\n ] as const) {\n if (end.record === \"\") fault(\"name\", `${name}.record`, `the end ${name} has no record name`);\n point(`${name}.at`, end.at);\n }\n break;\n case \"field\": {\n const hasFrame = frame(\"frame\", mark.frame);\n const hasAcross = direction(\"across\", mark.across);\n if (hasFrame && hasAcross) {\n const dot = dot3(mark.frame.out, mark.across);\n if (Math.abs(dot) > DIRECTION_TOLERANCE) fault(\"angle\", \"across\", `across is not at a right angle to frame.out: their dot product is ${String(dot)}`);\n }\n positive(\"cell\", mark.cell);\n const hasColumns = count(\"columns\", mark.columns);\n const hasRows = count(\"rows\", mark.rows);\n if (hasColumns && hasRows && mark.values.length !== mark.columns * mark.rows) {\n fault(\"values\", \"values\", `the field has ${String(mark.values.length)} values, and ${String(mark.columns)} columns of ${String(mark.rows)} rows need ${String(mark.columns * mark.rows)}`);\n }\n // A field can have many cells, so the values give one fault, not one fault for each cell.\n const bad = mark.values.flatMap((value, at) => (value === null || Number.isFinite(value) ? [] : [at]));\n const first = bad[0];\n if (first !== undefined) {\n fault(\"number\", `values[${String(first)}]`, `${String(bad.length)} of the values are not finite numbers, the first is values[${String(first)}]: ${String(mark.values[first])}`);\n }\n const hasMin = finite(\"scale.min\", mark.scale.min);\n const hasMax = finite(\"scale.max\", mark.scale.max);\n if (hasMin && hasMax && mark.scale.min >= mark.scale.max) {\n fault(\"scale\", \"scale\", `scale.min is not less than scale.max: ${String(mark.scale.min)} and ${String(mark.scale.max)}`);\n }\n break;\n }\n case \"meter\":\n finite(\"value\", mark.value);\n finite(\"limit\", mark.limit);\n break;\n default:\n fault(\"type\", \"type\", `the type is not known: ${String((mark as { readonly type: unknown }).type)}`);\n }\n });\n return faults;\n}\n","import { addPoints3, cross3, scalePoint3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Level } from \"./levels.ts\";\n\n/** A point of a surface, and the direction out of the surface. */\nexport interface Frame {\n /** The point. */\n readonly at: Point3;\n /** The unit vector out of the surface at the point. */\n readonly out: Point3;\n}\n\n/** These are the types of a mark. */\nexport const MARK_TYPES: readonly [\"point\", \"run\", \"link\", \"field\", \"meter\"] = [\"point\", \"run\", \"link\", \"field\", \"meter\"];\n\n/** A type of a mark. */\nexport type MarkType = (typeof MARK_TYPES)[number];\n\n/**\n * The parts that each mark has. A mark has no shape and no color.\n * 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.\n */\nexport interface MarkBase {\n /** The name of the record of the mark. The pointer and the selection of a viewer use this name. */\n readonly record: string;\n /** A word of the producer for the legend and the filter, for example `outlet`. */\n readonly kind: string;\n /** The level of the mark. The producer calculates it. */\n readonly level: Level;\n /** One line of text: the name of the mark for a person and for a screen reader. */\n readonly label: string;\n}\n\n/** A mark at one point of a surface, for example an outlet, a tap or a lamp. */\nexport interface PointMark extends MarkBase {\n readonly type: \"point\";\n /** The point, and the direction out of its surface. */\n readonly frame: Frame;\n /** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */\n readonly size?: number | undefined;\n}\n\n/** A mark along a path on surfaces, for example a cable, a pipe or a duct. */\nexport interface RunMark extends MarkBase {\n readonly type: \"run\";\n /** 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. */\n readonly path: readonly Frame[];\n /** The width of the run, in the unit of the space. */\n readonly width: number;\n}\n\n/** One end of a link. */\nexport interface LinkEnd {\n /** 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. */\n readonly record: string;\n /** The point of this end. */\n readonly at: Point3;\n}\n\n/** A mark between two records, for example a power line from an outlet to a computer. */\nexport interface LinkMark extends MarkBase {\n readonly type: \"link\";\n readonly from: LinkEnd;\n readonly to: LinkEnd;\n}\n\n/** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */\nexport interface FieldScale {\n /** The value of the first color. It is less than `max`. */\n readonly min: number;\n /** The value of the last color. */\n readonly max: number;\n /** The text of the unit of the values, for example `lx`. */\n readonly unit: string;\n}\n\n/** A grid of values on a plane, for example the light on a floor or the heat of a wall. */\nexport interface FieldMark extends MarkBase {\n readonly type: \"field\";\n /** The corner of the first cell, and the direction out of the plane. */\n readonly frame: Frame;\n /** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */\n readonly across: Point3;\n /** The length of a side of a cell, in the unit of the space. */\n readonly cell: number;\n /** The number of the columns. */\n readonly columns: number;\n /** The number of the rows. */\n readonly rows: number;\n /**\n * The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.\n * A cell with no value has `null`, because JSON has no NaN.\n */\n readonly values: readonly (number | null)[];\n readonly scale: FieldScale;\n}\n\n/**\n * A value against a limit, for example the load of a circuit. A meter has no place.\n * A page draws it in a panel, and a 3D view ignores it.\n */\nexport interface MeterMark extends MarkBase {\n readonly type: \"meter\";\n readonly value: number;\n readonly limit: number;\n /** The text of the unit of the value and of the limit, for example `W`. */\n readonly unit: string;\n}\n\n/**\n * A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.\n * Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.\n */\nexport type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;\n\n/** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */\nexport function fieldRowStep(field: FieldMark): Point3 {\n return cross3(field.frame.out, field.across);\n}\n\n/** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */\nexport function fieldCellCenter(field: FieldMark, column: number, row: number): Point3 {\n const across = scalePoint3(field.across, (column + 0.5) * field.cell);\n const down = scalePoint3(fieldRowStep(field), (row + 0.5) * field.cell);\n return addPoints3(field.frame.at, addPoints3(across, down));\n}\n\n/** 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. */\nexport function fieldValue(field: FieldMark, column: number, row: number): number | null {\n if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;\n return field.values[row * field.columns + column] ?? null;\n}\n"],"mappings":";;;AAGA,MAAa,SAAqD;CAAC;CAAW;CAAM;CAAQ;AAAM;;;;;AAYlG,SAAgB,UAAU,OAAsB;CAC9C,OAAO,OAAO,QAAQ,KAAK;AAC7B;;AAGA,MAAa,eAAgE;CAAC;CAAQ;CAAQ;CAAY;AAAQ;;;;;AASlH,SAAgB,WAAW,OAAsC;CAC/D,OAAO,UAAU,OAAO,SAAS,UAAU,SAAS,aAAa,UAAU,SAAS,WAAW;AACjG;;;;;AAkBA,MAAa,iBAA6D;CACxE,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAK;CACnD,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAE;CAChD,UAAU;EAAE,QAAQ;EAAK,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;CAC/D,QAAQ;EAAE,QAAQ;EAAM,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;AAChE;;;;;AAMA,SAAgB,UAAU,OAAmB,SAAiB,GAAS;CACrE,MAAM,UAAU,eAAe;CAC/B,OAAO,MAAM,KAAK,EAAE,QAAQ,QAAQ,MAAM,IAAI,GAAG,UAAqC;EACpF,MAAM,QAAQ,QAAQ,QAAS,QAAQ,IAAI,KAAK,KAAM,QAAQ;EAC9D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MAAM,GAAG,GAAG;IAEzH;GACF;GACA,KAAK;IACH,OAAO,SAAS,KAAK,KAAK;IAC1B,OAAO,SAAS,KAAK,KAAK;IAC1B;GACF,SACE,MAAM,QAAQ,QAAQ,0BAA0B,OAAQ,KAAoC,IAAI,GAAG;EACvG;CACF,CAAC;CACD,OAAO;AACT;;;ACpJA,MAAa,aAAkE;CAAC;CAAS;CAAO;CAAQ;CAAS;AAAO;;AAuGxH,SAAgB,aAAa,OAA0B;CACrD,OAAO,OAAO,MAAM,MAAM,KAAK,MAAM,MAAM;AAC7C;;AAGA,SAAgB,gBAAgB,OAAkB,QAAgB,KAAqB;CACrF,MAAM,SAAS,YAAY,MAAM,SAAS,SAAS,MAAO,MAAM,IAAI;CACpE,MAAM,OAAO,YAAY,aAAa,KAAK,IAAI,MAAM,MAAO,MAAM,IAAI;CACtE,OAAO,WAAW,MAAM,MAAM,IAAI,WAAW,QAAQ,IAAI,CAAC;AAC5D;;AAGA,SAAgB,WAAW,OAAkB,QAAgB,KAA4B;CACvF,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,CAAC,OAAO,UAAU,GAAG,KAAK,SAAS,KAAK,MAAM,KAAK,UAAU,MAAM,WAAW,OAAO,MAAM,MAAM,OAAO;CACzI,OAAO,MAAM,OAAO,MAAM,MAAM,UAAU,WAAW;AACvD"}
1
+ {"version":3,"file":"marks.js","names":[],"sources":["../src/marks/levels.ts","../src/marks/check.ts","../src/marks/mark.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\n\n/** These are the levels of a mark, from the lowest to the highest. */\nexport const LEVELS: readonly [\"unknown\", \"ok\", \"near\", \"over\"] = [\"unknown\", \"ok\", \"near\", \"over\"];\n\n/**\n * A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.\n * A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.\n */\nexport type Level = (typeof LEVELS)[number];\n\n/**\n * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.\n * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.\n */\nexport function levelRank(level: Level): number {\n return LEVELS.indexOf(level);\n}\n\n/** These are the shapes of the sign of a level. */\nexport const LEVEL_SHAPES: readonly [\"ring\", \"disc\", \"triangle\", \"square\"] = [\"ring\", \"disc\", \"triangle\", \"square\"];\n\n/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */\nexport type LevelShape = (typeof LEVEL_SHAPES)[number];\n\n/**\n * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.\n * The level `unknown` has a ring, and so has a record with no level.\n */\nexport function levelShape(level: Level | undefined): LevelShape {\n return level === \"ok\" ? \"disc\" : level === \"near\" ? \"triangle\" : level === \"over\" ? \"square\" : \"ring\";\n}\n\n/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */\nexport interface ShapeOutline {\n /** The radius of the circle through the corners, for a disc with the radius 1. */\n readonly radius: number;\n /** The number of the sides. */\n readonly sides: number;\n /** The angle of the first corner, in radians, counter-clockwise from the x axis. */\n readonly start: number;\n /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */\n readonly hole: number;\n}\n\n/**\n * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.\n * A triangle and a square with the radius of the disc look small, so they are larger.\n */\nexport const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>> = {\n ring: { radius: 1, sides: 40, start: 0, hole: 0.52 },\n disc: { radius: 1, sides: 40, start: 0, hole: 0 },\n triangle: { radius: 1.3, sides: 3, start: Math.PI / 2, hole: 0 },\n square: { radius: 1.25, sides: 4, start: Math.PI / 4, hole: 0 },\n};\n\n/**\n * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.\n * The center of the sign is the origin, and `radius` is the radius of a disc.\n */\nexport function shapeRing(shape: LevelShape, radius: number = 1): Ring {\n const outline = SHAPE_OUTLINES[shape];\n return Array.from({ length: outline.sides }, (_, index): readonly [number, number] => {\n const angle = outline.start + (index * 2 * Math.PI) / outline.sides;\n return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];\n });\n}\n","import { dot3, length3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport { LEVELS } from \"./levels.ts\";\nimport type { Frame, Mark } from \"./mark.ts\";\n\n/**\n * These are the codes of the faults of a mark:\n * - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.\n * - `level`: the level of the mark is not known.\n * - `name`: a record name or the kind is empty.\n * - `label`: the label is empty, or it has more than one line.\n * - `number`: a number is not finite.\n * - `direction`: a direction is not a unit vector.\n * - `angle`: the column step of a field is not at a right angle to the direction out of its plane.\n * - `size`: a size, a width or a cell is not more than 0.\n * - `grid`: the number of the columns or of the rows of a field is not a whole number of 1 or more.\n * - `values`: a field does not have one value for each cell.\n * - `scale`: the `min` of the scale of a field is not less than its `max`.\n * - `path`: a run has fewer than 2 points.\n */\nexport const MARK_FAULT_CODES: readonly [\"type\", \"level\", \"name\", \"label\", \"number\", \"direction\", \"angle\", \"size\", \"grid\", \"values\", \"scale\", \"path\"] = [\n \"type\",\n \"level\",\n \"name\",\n \"label\",\n \"number\",\n \"direction\",\n \"angle\",\n \"size\",\n \"grid\",\n \"values\",\n \"scale\",\n \"path\",\n];\n\n/** A code of a fault of a mark. */\nexport type MarkFaultCode = (typeof MARK_FAULT_CODES)[number];\n\n/** One fault of a mark of a list. */\nexport interface MarkFault {\n readonly code: MarkFaultCode;\n /** The index of the mark in the list. */\n readonly index: number;\n /** The record name of the mark. */\n readonly record: string;\n /** The part of the mark with the fault, for example `path[2].out`. */\n readonly part: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n}\n\n/**\n * The tolerance of a direction. A unit vector has the length 1 with this tolerance.\n * Two directions are at a right angle when their dot product is 0 with this tolerance.\n */\nexport const DIRECTION_TOLERANCE = 1e-6;\n\n/**\n * This function gives the faults of a list of marks, in the sequence of the list. A list with no fault gives an empty list.\n * It examines the values that the types do not hold: finite numbers, unit vectors, sizes, the grid of a field and the names.\n * A producer of marks uses it as a gate in its tests, and a viewer uses it on a list that it did not make.\n * It does not examine the form of a mark: read a list from JSON through a schema first.\n */\nexport function checkMarks(marks: readonly Mark[]): readonly MarkFault[] {\n const faults: MarkFault[] = [];\n marks.forEach((mark, index) => {\n const fault = (code: MarkFaultCode, part: string, message: string): void => {\n faults.push({ code, index, record: mark.record, part, message });\n };\n const finite = (part: string, value: number): boolean => {\n if (Number.isFinite(value)) return true;\n fault(\"number\", part, `${part} is not a finite number: ${String(value)}`);\n return false;\n };\n const point = (part: string, value: Point3): boolean => {\n const x = finite(`${part}.x`, value.x);\n const y = finite(`${part}.y`, value.y);\n const z = finite(`${part}.z`, value.z);\n return x && y && z;\n };\n const direction = (part: string, value: Point3): boolean => {\n if (!point(part, value)) return false;\n const length = length3(value);\n if (Math.abs(length - 1) <= DIRECTION_TOLERANCE) return true;\n fault(\"direction\", part, `${part} is not a unit vector: its length is ${String(length)}`);\n return false;\n };\n const frame = (part: string, value: Frame): boolean => {\n const at = point(`${part}.at`, value.at);\n const out = direction(`${part}.out`, value.out);\n return at && out;\n };\n const positive = (part: string, value: number): void => {\n if (finite(part, value) && value <= 0) fault(\"size\", part, `${part} is not more than 0: ${String(value)}`);\n };\n const count = (part: string, value: number): boolean => {\n if (Number.isInteger(value) && value >= 1) return true;\n fault(\"grid\", part, `${part} is not a whole number of 1 or more: ${String(value)}`);\n return false;\n };\n\n if (mark.record === \"\") fault(\"name\", \"record\", \"the mark has no record name\");\n if (mark.kind === \"\") fault(\"name\", \"kind\", \"the mark has no kind\");\n if (!(LEVELS as readonly string[]).includes(mark.level)) fault(\"level\", \"level\", `the level is not known: ${String(mark.level)}`);\n if (mark.label.trim() === \"\") fault(\"label\", \"label\", \"the mark has no label\");\n else if (/[\\r\\n]/.test(mark.label)) fault(\"label\", \"label\", \"the label has more than one line\");\n\n switch (mark.type) {\n case \"point\":\n frame(\"frame\", mark.frame);\n if (mark.size !== undefined) positive(\"size\", mark.size);\n break;\n case \"run\":\n if (mark.path.length < 2) fault(\"path\", \"path\", `the path has ${String(mark.path.length)} points, and a run needs 2 or more`);\n mark.path.forEach((step, at) => frame(`path[${String(at)}]`, step));\n positive(\"width\", mark.width);\n break;\n case \"link\":\n for (const [name, end] of [\n [\"from\", mark.from],\n [\"to\", mark.to],\n ] as const) {\n if (end.record === \"\") fault(\"name\", `${name}.record`, `the end ${name} has no record name`);\n point(`${name}.at`, end.at);\n }\n break;\n case \"field\": {\n const hasFrame = frame(\"frame\", mark.frame);\n const hasAcross = direction(\"across\", mark.across);\n if (hasFrame && hasAcross) {\n const dot = dot3(mark.frame.out, mark.across);\n if (Math.abs(dot) > DIRECTION_TOLERANCE) fault(\"angle\", \"across\", `across is not at a right angle to frame.out: their dot product is ${String(dot)}`);\n }\n positive(\"cell\", mark.cell);\n const hasColumns = count(\"columns\", mark.columns);\n const hasRows = count(\"rows\", mark.rows);\n if (hasColumns && hasRows && mark.values.length !== mark.columns * mark.rows) {\n fault(\"values\", \"values\", `the field has ${String(mark.values.length)} values, and ${String(mark.columns)} columns of ${String(mark.rows)} rows need ${String(mark.columns * mark.rows)}`);\n }\n // A field can have many cells, so the values give one fault, not one fault for each cell.\n const bad = mark.values.flatMap((value, at) => (value === null || Number.isFinite(value) ? [] : [at]));\n const first = bad[0];\n if (first !== undefined) {\n fault(\"number\", `values[${String(first)}]`, `${String(bad.length)} of the values are not finite numbers, the first is values[${String(first)}]: ${String(mark.values[first])}`);\n }\n const hasMin = finite(\"scale.min\", mark.scale.min);\n const hasMax = finite(\"scale.max\", mark.scale.max);\n if (hasMin && hasMax && mark.scale.min >= mark.scale.max) {\n fault(\"scale\", \"scale\", `scale.min is not less than scale.max: ${String(mark.scale.min)} and ${String(mark.scale.max)}`);\n }\n break;\n }\n case \"meter\":\n finite(\"value\", mark.value);\n // A meter with no limit is correct. A list from JSON can have `null` there, and `null` is not a number.\n if (mark.limit !== undefined) finite(\"limit\", mark.limit);\n break;\n default:\n fault(\"type\", \"type\", `the type is not known: ${String((mark as { readonly type: unknown }).type)}`);\n }\n });\n return faults;\n}\n","import { addPoints3, cross3, scalePoint3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Level } from \"./levels.ts\";\n\n/** A point of a surface, and the direction out of the surface. */\nexport interface Frame {\n /** The point. */\n readonly at: Point3;\n /** The unit vector out of the surface at the point. */\n readonly out: Point3;\n}\n\n/** These are the types of a mark. */\nexport const MARK_TYPES: readonly [\"point\", \"run\", \"link\", \"field\", \"meter\"] = [\"point\", \"run\", \"link\", \"field\", \"meter\"];\n\n/** A type of a mark. */\nexport type MarkType = (typeof MARK_TYPES)[number];\n\n/**\n * The parts that each mark has. A mark has no shape and no color.\n * 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.\n */\nexport interface MarkBase {\n /** The name of the record of the mark. The pointer and the selection of a viewer use this name. */\n readonly record: string;\n /** A word of the producer for the legend and the filter, for example `outlet`. */\n readonly kind: string;\n /** The level of the mark. The producer calculates it. */\n readonly level: Level;\n /** One line of text: the name of the mark for a person and for a screen reader. */\n readonly label: string;\n}\n\n/** A mark at one point of a surface, for example an outlet, a tap or a lamp. */\nexport interface PointMark extends MarkBase {\n readonly type: \"point\";\n /** The point, and the direction out of its surface. */\n readonly frame: Frame;\n /** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */\n readonly size?: number | undefined;\n}\n\n/** A mark along a path on surfaces, for example a cable, a pipe or a duct. */\nexport interface RunMark extends MarkBase {\n readonly type: \"run\";\n /** 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. */\n readonly path: readonly Frame[];\n /** The width of the run, in the unit of the space. */\n readonly width: number;\n}\n\n/** One end of a link. */\nexport interface LinkEnd {\n /** 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. */\n readonly record: string;\n /** The point of this end. */\n readonly at: Point3;\n}\n\n/** A mark between two records, for example a power line from an outlet to a computer. */\nexport interface LinkMark extends MarkBase {\n readonly type: \"link\";\n readonly from: LinkEnd;\n readonly to: LinkEnd;\n}\n\n/** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */\nexport interface FieldScale {\n /** The value of the first color. It is less than `max`. */\n readonly min: number;\n /** The value of the last color. */\n readonly max: number;\n /** The text of the unit of the values, for example `lx`. */\n readonly unit: string;\n}\n\n/** A grid of values on a plane, for example the light on a floor or the heat of a wall. */\nexport interface FieldMark extends MarkBase {\n readonly type: \"field\";\n /** The corner of the first cell, and the direction out of the plane. */\n readonly frame: Frame;\n /** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */\n readonly across: Point3;\n /** The length of a side of a cell, in the unit of the space. */\n readonly cell: number;\n /** The number of the columns. */\n readonly columns: number;\n /** The number of the rows. */\n readonly rows: number;\n /**\n * The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.\n * A cell with no value has `null`, because JSON has no NaN.\n */\n readonly values: readonly (number | null)[];\n readonly scale: FieldScale;\n}\n\n/**\n * A value against a limit, for example the load of a circuit. A meter has no place.\n * A page draws it in a panel, and a 3D view ignores it.\n */\nexport interface MeterMark extends MarkBase {\n readonly type: \"meter\";\n readonly value: number;\n /**\n * 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.\n * 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.\n */\n readonly limit?: number | undefined;\n /** The text of the unit of the value and of the limit, for example `W`. */\n readonly unit: string;\n}\n\n/**\n * A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.\n * Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.\n */\nexport type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;\n\n/** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */\nexport function fieldRowStep(field: FieldMark): Point3 {\n return cross3(field.frame.out, field.across);\n}\n\n/** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */\nexport function fieldCellCenter(field: FieldMark, column: number, row: number): Point3 {\n const across = scalePoint3(field.across, (column + 0.5) * field.cell);\n const down = scalePoint3(fieldRowStep(field), (row + 0.5) * field.cell);\n return addPoints3(field.frame.at, addPoints3(across, down));\n}\n\n/** 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. */\nexport function fieldValue(field: FieldMark, column: number, row: number): number | null {\n if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;\n return field.values[row * field.columns + column] ?? null;\n}\n"],"mappings":";;;AAGA,MAAa,SAAqD;CAAC;CAAW;CAAM;CAAQ;AAAM;;;;;AAYlG,SAAgB,UAAU,OAAsB;CAC9C,OAAO,OAAO,QAAQ,KAAK;AAC7B;;AAGA,MAAa,eAAgE;CAAC;CAAQ;CAAQ;CAAY;AAAQ;;;;;AASlH,SAAgB,WAAW,OAAsC;CAC/D,OAAO,UAAU,OAAO,SAAS,UAAU,SAAS,aAAa,UAAU,SAAS,WAAW;AACjG;;;;;AAkBA,MAAa,iBAA6D;CACxE,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAK;CACnD,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAE;CAChD,UAAU;EAAE,QAAQ;EAAK,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;CAC/D,QAAQ;EAAE,QAAQ;EAAM,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;AAChE;;;;;AAMA,SAAgB,UAAU,OAAmB,SAAiB,GAAS;CACrE,MAAM,UAAU,eAAe;CAC/B,OAAO,MAAM,KAAK,EAAE,QAAQ,QAAQ,MAAM,IAAI,GAAG,UAAqC;EACpF,MAAM,QAAQ,QAAQ,QAAS,QAAQ,IAAI,KAAK,KAAM,QAAQ;EAC9D,OAAO,CAAC,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,GAAG,SAAS,QAAQ,SAAS,KAAK,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,KAAK,UAAU,KAAA,GAAW,OAAO,SAAS,KAAK,KAAK;IACxD;GACF,SACE,MAAM,QAAQ,QAAQ,0BAA0B,OAAQ,KAAoC,IAAI,GAAG;EACvG;CACF,CAAC;CACD,OAAO;AACT;;;ACrJA,MAAa,aAAkE;CAAC;CAAS;CAAO;CAAQ;CAAS;AAAO;;AA2GxH,SAAgB,aAAa,OAA0B;CACrD,OAAO,OAAO,MAAM,MAAM,KAAK,MAAM,MAAM;AAC7C;;AAGA,SAAgB,gBAAgB,OAAkB,QAAgB,KAAqB;CACrF,MAAM,SAAS,YAAY,MAAM,SAAS,SAAS,MAAO,MAAM,IAAI;CACpE,MAAM,OAAO,YAAY,aAAa,KAAK,IAAI,MAAM,MAAO,MAAM,IAAI;CACtE,OAAO,WAAW,MAAM,MAAM,IAAI,WAAW,QAAQ,IAAI,CAAC;AAC5D;;AAGA,SAAgB,WAAW,OAAkB,QAAgB,KAA4B;CACvF,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,CAAC,OAAO,UAAU,GAAG,KAAK,SAAS,KAAK,MAAM,KAAK,UAAU,MAAM,WAAW,OAAO,MAAM,MAAM,OAAO;CACzI,OAAO,MAAM,OAAO,MAAM,MAAM,UAAU,WAAW;AACvD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/visuals",
4
- "version": "0.2.4",
4
+ "version": "0.3.0",
5
5
  "description": "3D stages for data on three.js: a camera that a person moves, views by name, picking, highlights and themes, a globe of the Earth, and the shared marks of the viewers as data.",
6
6
  "license": "MIT",
7
7
  "repository": {