@rangefoundry/svg-drawings 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +21 -1
  3. package/dist/bullet/density.d.ts +65 -0
  4. package/dist/bullet/density.js +91 -0
  5. package/dist/bullet/figure.d.ts +34 -0
  6. package/dist/bullet/figure.js +50 -0
  7. package/dist/bullet/index.d.ts +4 -0
  8. package/dist/bullet/index.js +5 -0
  9. package/dist/bullet/outline.d.ts +144 -0
  10. package/dist/bullet/outline.js +683 -0
  11. package/dist/bullet/profile.d.ts +76 -0
  12. package/dist/bullet/profile.js +257 -0
  13. package/dist/cartridge/callouts.d.ts +18 -0
  14. package/dist/cartridge/callouts.js +153 -0
  15. package/dist/cartridge/detail.d.ts +34 -0
  16. package/dist/cartridge/detail.js +99 -0
  17. package/dist/cartridge/figure.d.ts +59 -0
  18. package/dist/cartridge/figure.js +113 -0
  19. package/dist/cartridge/figures.d.ts +47 -0
  20. package/dist/cartridge/figures.js +54 -0
  21. package/dist/cartridge/focus.d.ts +3 -0
  22. package/dist/cartridge/focus.js +7 -0
  23. package/dist/cartridge/index.d.ts +8 -0
  24. package/dist/cartridge/index.js +8 -0
  25. package/dist/cartridge/profile.d.ts +46 -0
  26. package/dist/cartridge/profile.js +630 -0
  27. package/dist/cartridge/regions.d.ts +28 -0
  28. package/dist/cartridge/regions.js +50 -0
  29. package/dist/core/advances.json +106 -0
  30. package/dist/core/annotate.d.ts +11 -0
  31. package/dist/core/annotate.js +715 -0
  32. package/dist/core/cache.d.ts +4 -0
  33. package/dist/core/cache.js +16 -0
  34. package/dist/core/face.d.ts +56 -0
  35. package/dist/core/face.js +54 -0
  36. package/dist/core/fillet.d.ts +7 -0
  37. package/dist/core/fillet.js +42 -0
  38. package/dist/core/geometry.d.ts +22 -0
  39. package/dist/core/geometry.js +136 -0
  40. package/dist/core/layout.d.ts +46 -0
  41. package/dist/core/layout.js +69 -0
  42. package/dist/core/placer.d.ts +60 -0
  43. package/dist/core/placer.js +291 -0
  44. package/dist/core/section.d.ts +32 -0
  45. package/dist/core/section.js +75 -0
  46. package/dist/core/text.d.ts +19 -0
  47. package/dist/core/text.js +38 -0
  48. package/dist/core/types.d.ts +185 -0
  49. package/dist/core/types.js +2 -0
  50. package/dist/core/units.d.ts +18 -0
  51. package/dist/core/units.js +26 -0
  52. package/dist/core/vector.d.ts +8 -0
  53. package/dist/core/vector.js +23 -0
  54. package/dist/index.d.ts +9 -0
  55. package/dist/index.js +10 -0
  56. package/dist/seating/chamber.d.ts +21 -0
  57. package/dist/seating/chamber.js +23 -0
  58. package/dist/seating/index.d.ts +3 -0
  59. package/dist/seating/index.js +4 -0
  60. package/dist/seating/preview.d.ts +12 -0
  61. package/dist/seating/preview.js +30 -0
  62. package/dist/seating/seating.d.ts +210 -0
  63. package/dist/seating/seating.js +284 -0
  64. package/dist/target/face.d.ts +68 -0
  65. package/dist/target/face.js +50 -0
  66. package/dist/target/index.d.ts +1 -0
  67. package/dist/target/index.js +2 -0
  68. package/package.json +60 -4
@@ -0,0 +1,50 @@
1
+ import { lengthText } from '../core/units.js';
2
+ import { closedFront, storedValue } from './profile.js';
3
+ /** The symbols compared in each region: the stored values whose difference `regions` gives. */
4
+ export const regionSymbols = {
5
+ head: ['R1', 'R3', 'R'],
6
+ body: ['P1'],
7
+ shoulder: ['P2', 'H1'],
8
+ neck: ['H2'],
9
+ };
10
+ /** Caption text naming a region difference: the chamber minimum less the cartridge maximum, signed. */
11
+ export const differenceWording = 'nominal minimum difference of published dimensions';
12
+ /** The wording that names a negative region difference (chamber minimum below cartridge maximum). */
13
+ export const conflictWording = 'data conflict between published cartridge maximum and chamber minimum (check source)';
14
+ /** The stored value when it is the column's limit: a cartridge maximum, a chamber minimum. */
15
+ function limitOf(values, side, symbol) {
16
+ const v = storedValue(values, side, symbol);
17
+ if (!v)
18
+ return;
19
+ const other = side === 'cartridge' ? 'min' : 'max';
20
+ const beyond = side === 'cartridge' ? v.tolerance?.upper : v.tolerance?.lower;
21
+ return v.limit === other || beyond ? undefined : v.value;
22
+ }
23
+ /**
24
+ * The regions of a record with their differences, from stored values only: head R1, R3 and R,
25
+ * body P1, shoulder P2 and H1, neck H2. A chamber E is the recess depth, so the chamber R is
26
+ * compared only where the chamber stores no E. None behind a closed front.
27
+ */
28
+ export function regions(values) {
29
+ if (closedFront(values))
30
+ return [];
31
+ const recessE = storedValue(values, 'chamber', 'E') !== undefined;
32
+ return Object.entries(regionSymbols).flatMap(([name, symbols]) => {
33
+ const list = symbols.flatMap((symbol) => {
34
+ if (symbol === 'R' && recessE)
35
+ return [];
36
+ const [c, ch] = [limitOf(values, 'cartridge', symbol), limitOf(values, 'chamber', symbol)];
37
+ return c === undefined || ch === undefined
38
+ ? []
39
+ : [{ symbol, value: Number((ch - c).toFixed(3)) }];
40
+ });
41
+ return list.length ? [{ name, values: list }] : [];
42
+ });
43
+ }
44
+ /** A difference with its sign; a negative one is a conflict. */
45
+ export const signedLengthText = (value, unit = 'mm') => value < 0 ? `−${lengthText(-value, unit)}` : value > 0 ? `+${lengthText(value, unit)}` : '0';
46
+ /** The callout text of a region, placed at it: "P2 +0.03, H1 +0.07"; a conflict marked. */
47
+ export const regionText = ({ values }, unit = 'mm') => values
48
+ .map((v) => `${v.symbol} ${signedLengthText(v.value, unit)}${v.value < 0 ? ' conflict' : ''}`)
49
+ .join(', ');
50
+ //# sourceMappingURL=regions.js.map
@@ -0,0 +1,106 @@
1
+ {
2
+ "font": "Inter 4.1 Regular",
3
+ "advances": {
4
+ "0": 0.631,
5
+ "1": 0.407,
6
+ "2": 0.61,
7
+ "3": 0.618,
8
+ "4": 0.646,
9
+ "5": 0.593,
10
+ "6": 0.62,
11
+ "7": 0.566,
12
+ "8": 0.619,
13
+ "9": 0.62,
14
+ " ": 0.281,
15
+ "!": 0.288,
16
+ "\"": 0.466,
17
+ "#": 0.633,
18
+ "$": 0.642,
19
+ "%": 0.982,
20
+ "&": 0.644,
21
+ "'": 0.3,
22
+ "(": 0.365,
23
+ ")": 0.365,
24
+ "*": 0.501,
25
+ "+": 0.662,
26
+ ",": 0.288,
27
+ "-": 0.46,
28
+ ".": 0.288,
29
+ "/": 0.36,
30
+ ":": 0.288,
31
+ ";": 0.302,
32
+ "<": 0.662,
33
+ "=": 0.662,
34
+ ">": 0.662,
35
+ "?": 0.511,
36
+ "@": 0.966,
37
+ "A": 0.69,
38
+ "B": 0.654,
39
+ "C": 0.73,
40
+ "D": 0.722,
41
+ "E": 0.601,
42
+ "F": 0.59,
43
+ "G": 0.746,
44
+ "H": 0.743,
45
+ "I": 0.269,
46
+ "J": 0.571,
47
+ "K": 0.672,
48
+ "L": 0.565,
49
+ "M": 0.903,
50
+ "N": 0.753,
51
+ "O": 0.765,
52
+ "P": 0.639,
53
+ "Q": 0.765,
54
+ "R": 0.644,
55
+ "S": 0.642,
56
+ "T": 0.646,
57
+ "U": 0.744,
58
+ "V": 0.69,
59
+ "W": 0.985,
60
+ "X": 0.682,
61
+ "Y": 0.679,
62
+ "Z": 0.629,
63
+ "[": 0.365,
64
+ "\\": 0.36,
65
+ "]": 0.365,
66
+ "^": 0.471,
67
+ "_": 0.456,
68
+ "`": 0.323,
69
+ "a": 0.562,
70
+ "b": 0.612,
71
+ "c": 0.571,
72
+ "d": 0.612,
73
+ "e": 0.583,
74
+ "f": 0.37,
75
+ "g": 0.613,
76
+ "h": 0.591,
77
+ "i": 0.242,
78
+ "j": 0.242,
79
+ "k": 0.549,
80
+ "l": 0.242,
81
+ "m": 0.876,
82
+ "n": 0.591,
83
+ "o": 0.6,
84
+ "p": 0.612,
85
+ "q": 0.612,
86
+ "r": 0.376,
87
+ "s": 0.528,
88
+ "t": 0.327,
89
+ "u": 0.591,
90
+ "v": 0.562,
91
+ "w": 0.818,
92
+ "x": 0.546,
93
+ "y": 0.562,
94
+ "z": 0.552,
95
+ "{": 0.426,
96
+ "|": 0.333,
97
+ "}": 0.426,
98
+ "~": 0.662,
99
+ "°": 0.456,
100
+ "α": 0.664,
101
+ "β": 0.596,
102
+ "δ": 0.584,
103
+ "∅": 0.685,
104
+ "−": 0.662
105
+ }
106
+ }
@@ -0,0 +1,11 @@
1
+ import { type PartPoint } from './section.ts';
2
+ import type { Layout, Part } from './types.ts';
3
+ /**
4
+ * Lays out the dimensions of one side at text size `em` (mm) in the part frame: the length stack
5
+ * on +r, S and the diameter labels on -r, head lengths and head diameters behind the face. Each
6
+ * text takes the first of its places where it clears every other text and every line of another
7
+ * dimension, and its own lines and arrowheads clear every other text and arrowhead. Where that
8
+ * leaves a conflict, the layout without the corner rooms of the radii is taken if it has fewer.
9
+ * `horizontal` is the part-frame direction that reads level on the medium (angle labels).
10
+ */
11
+ export declare function annotate(part: Part, em: number, horizontal: PartPoint, axis: [number, number]): Layout;