@bitbybit-dev/base 1.6.1 → 1.7.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 (192) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +36 -7
  3. package/lib/api/inputs/base-inputs.js +10 -0
  4. package/lib/api/inputs/color-inputs.d.ts +54 -1
  5. package/lib/api/inputs/color-inputs.js +73 -1
  6. package/lib/api/inputs/frame-inputs.d.ts +2 -1
  7. package/lib/api/inputs/frame-inputs.js +2 -1
  8. package/lib/api/inputs/io-inputs.d.ts +527 -59
  9. package/lib/api/inputs/io-inputs.js +432 -40
  10. package/lib/api/inputs/line-inputs.d.ts +17 -0
  11. package/lib/api/inputs/line-inputs.js +15 -0
  12. package/lib/api/inputs/math-inputs.d.ts +62 -0
  13. package/lib/api/inputs/math-inputs.js +82 -0
  14. package/lib/api/inputs/mesh-inputs.d.ts +16 -0
  15. package/lib/api/inputs/mesh-inputs.js +14 -0
  16. package/lib/api/inputs/transforms-inputs.d.ts +76 -0
  17. package/lib/api/inputs/transforms-inputs.js +85 -0
  18. package/lib/api/kernel-calls/index.d.ts +1 -0
  19. package/lib/api/kernel-calls/index.js +1 -0
  20. package/lib/api/kernel-calls/settings.d.ts +82 -0
  21. package/lib/api/kernel-calls/settings.js +123 -0
  22. package/lib/api/recipes/surface-mesh.d.ts +2 -1
  23. package/lib/api/recipes/surface-mesh.js +5 -3
  24. package/lib/api/resolved-inputs/index.d.ts +32 -2
  25. package/lib/api/services/base-bitbybit.d.ts +12 -0
  26. package/lib/api/services/base-bitbybit.js +19 -3
  27. package/lib/api/services/color.d.ts +36 -2
  28. package/lib/api/services/color.js +60 -11
  29. package/lib/api/services/helpers/color/color-forms.constants.d.ts +10 -0
  30. package/lib/api/services/helpers/color/color-forms.constants.js +10 -0
  31. package/lib/api/services/helpers/color/color-forms.d.ts +3 -0
  32. package/lib/api/services/helpers/color/color-forms.js +27 -0
  33. package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
  34. package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
  35. package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
  36. package/lib/api/services/helpers/color/css-colors.js +61 -0
  37. package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
  38. package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
  39. package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
  40. package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
  41. package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
  42. package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
  43. package/lib/api/services/helpers/curves/conic-arcs.d.ts +24 -0
  44. package/lib/api/services/helpers/curves/conic-arcs.js +85 -0
  45. package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
  46. package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
  47. package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
  48. package/lib/api/services/helpers/curves/nurbs.js +10 -9
  49. package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
  50. package/lib/api/services/helpers/files/drawing/drawing-budget.js +24 -0
  51. package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +18 -0
  52. package/lib/api/services/helpers/files/drawing/drawing-geometry.js +84 -0
  53. package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +5 -0
  54. package/lib/api/services/helpers/files/drawing/drawing-model.js +252 -0
  55. package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +60 -0
  56. package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
  57. package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +28 -0
  58. package/lib/api/services/helpers/files/drawing/drawing.constants.js +29 -0
  59. package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
  60. package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
  61. package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +17 -0
  62. package/lib/api/services/helpers/files/dxf/dxf-entities.js +193 -0
  63. package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
  64. package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
  65. package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
  66. package/lib/api/services/helpers/files/dxf/dxf-generator.js +81 -523
  67. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
  68. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +81 -0
  69. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
  70. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
  71. package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +69 -0
  72. package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
  73. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +71 -0
  74. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +78 -0
  75. package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
  76. package/lib/api/services/helpers/files/dxf/dxf-reader.js +556 -0
  77. package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +27 -0
  78. package/lib/api/services/helpers/files/dxf/dxf-tables.js +247 -0
  79. package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
  80. package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
  81. package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +9 -0
  82. package/lib/api/services/helpers/files/dxf/dxf-tokens.js +65 -0
  83. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +32 -1
  84. package/lib/api/services/helpers/files/dxf/dxf.constants.js +34 -1
  85. package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
  86. package/lib/api/services/helpers/files/file-bytes.js +15 -0
  87. package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
  88. package/lib/api/services/helpers/files/ground-axes.js +4 -0
  89. package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
  90. package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
  91. package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
  92. package/lib/api/services/helpers/files/stl-axes.js +22 -0
  93. package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
  94. package/lib/api/services/helpers/files/stl-types.js +1 -0
  95. package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
  96. package/lib/api/services/helpers/files/stl.constants.js +11 -0
  97. package/lib/api/services/helpers/files/stl.d.ts +3 -0
  98. package/lib/api/services/helpers/files/stl.js +93 -0
  99. package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
  100. package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
  101. package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
  102. package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
  103. package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
  104. package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
  105. package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
  106. package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
  107. package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
  108. package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
  109. package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
  110. package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
  111. package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
  112. package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
  113. package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
  114. package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
  115. package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
  116. package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
  117. package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
  118. package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
  119. package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
  120. package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
  121. package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
  122. package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
  123. package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
  124. package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
  125. package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
  126. package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
  127. package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
  128. package/lib/api/services/helpers/files/svg/svg-strokes.js +108 -0
  129. package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
  130. package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
  131. package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
  132. package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
  133. package/lib/api/services/helpers/files/svg/svg-writer.d.ts +16 -0
  134. package/lib/api/services/helpers/files/svg/svg-writer.js +153 -0
  135. package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
  136. package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
  137. package/lib/api/services/helpers/files/svg/svg.constants.d.ts +13 -0
  138. package/lib/api/services/helpers/files/svg/svg.constants.js +13 -0
  139. package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
  140. package/lib/api/services/helpers/files/work-budget.js +26 -0
  141. package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
  142. package/lib/api/services/helpers/geometry/affine2.js +18 -0
  143. package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
  144. package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
  145. package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
  146. package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
  147. package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
  148. package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
  149. package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
  150. package/lib/api/services/helpers/geometry/quaternions.constants.d.ts +3 -0
  151. package/lib/api/services/helpers/geometry/quaternions.constants.js +3 -0
  152. package/lib/api/services/helpers/geometry/quaternions.d.ts +14 -0
  153. package/lib/api/services/helpers/geometry/quaternions.js +71 -0
  154. package/lib/api/services/helpers/geometry/scalars.constants.d.ts +1 -0
  155. package/lib/api/services/helpers/geometry/scalars.constants.js +1 -0
  156. package/lib/api/services/helpers/geometry/scalars.d.ts +3 -0
  157. package/lib/api/services/helpers/geometry/scalars.js +29 -1
  158. package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
  159. package/lib/api/services/helpers/geometry/vectors.js +6 -0
  160. package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +1 -0
  161. package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +1 -0
  162. package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +1 -0
  163. package/lib/api/services/helpers/mesh/mesh-proximity.js +40 -40
  164. package/lib/api/services/io/drawing.d.ts +170 -0
  165. package/lib/api/services/io/drawing.js +212 -0
  166. package/lib/api/services/io/dxf.d.ts +134 -0
  167. package/lib/api/services/io/dxf.js +167 -0
  168. package/lib/api/services/io/index.d.ts +4 -0
  169. package/lib/api/services/io/index.js +4 -0
  170. package/lib/api/services/io/io.d.ts +14 -0
  171. package/lib/api/services/io/io.js +15 -0
  172. package/lib/api/services/io/svg.d.ts +64 -0
  173. package/lib/api/services/io/svg.js +102 -0
  174. package/lib/api/services/line.d.ts +17 -0
  175. package/lib/api/services/line.js +20 -1
  176. package/lib/api/services/math.d.ts +35 -0
  177. package/lib/api/services/math.js +56 -1
  178. package/lib/api/services/mesh.d.ts +17 -0
  179. package/lib/api/services/mesh.js +27 -1
  180. package/lib/api/services/point.d.ts +4 -1
  181. package/lib/api/services/point.js +9 -4
  182. package/lib/api/services/recipes.d.ts +3 -0
  183. package/lib/api/services/recipes.js +4 -1
  184. package/lib/api/services/text.d.ts +4 -1
  185. package/lib/api/services/text.js +8 -3
  186. package/lib/api/services/transforms.d.ts +119 -1
  187. package/lib/api/services/transforms.js +158 -30
  188. package/package.json +1 -1
  189. package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
  190. package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
  191. package/lib/api/services/io.d.ts +0 -9
  192. package/lib/api/services/io.js +0 -10
@@ -0,0 +1,252 @@
1
+ import * as Inputs from "../../../../inputs";
2
+ import { InputError } from "../../../../kernel-calls";
3
+ import { hexChannels, hexOfChannels } from "../../color/color-forms";
4
+ import { angleWithinTurn } from "../../curves/conic-arcs";
5
+ import { clampedForm, clampedUniformKnots, periodicUniformForm } from "../../curves/nurbs-forms";
6
+ import { unitOf } from "../../geometry/frame-axes";
7
+ import { radiansOf } from "../../geometry/scalars";
8
+ import { distance3, dot3 } from "../../geometry/vectors";
9
+ import { DEFAULT_LAYER, DEFAULT_SPLINE_DEGREE, FIRST_PRINTABLE_CODE, FORBIDDEN_LAYER_CHARACTERS, FULL_TURN_DEGREES, HIGHEST_SPLINE_DEGREE, LARGEST_NUMBER, LEAST_WEIGHT, PERPENDICULAR_COSINE, POINT_SIZES, SAME_POINT, } from "./drawing.constants";
10
+ import { DXF_MAX_NAME_LENGTH } from "../dxf/dxf.constants";
11
+ const PLUS_Z = [0, 0, 1];
12
+ const LINE_TYPES = new Set(Object.values(Inputs.IO.lineTypeEnum));
13
+ const isRecord = (value) => typeof value === "object" && value !== null;
14
+ const isDrawable = (value) => typeof value === "number" && Math.abs(value) < LARGEST_NUMBER;
15
+ const finiteNumber = (value, property) => {
16
+ if (!isDrawable(value)) {
17
+ throw new InputError(`\`${property}\` must be a finite number below ${LARGEST_NUMBER} in size.`, property);
18
+ }
19
+ return value;
20
+ };
21
+ export const positiveNumber = (value, property) => {
22
+ const checked = finiteNumber(value, property);
23
+ if (checked <= 0) {
24
+ throw new InputError(`\`${property}\` must be above 0; it is ${checked}.`, property);
25
+ }
26
+ return checked;
27
+ };
28
+ const pointOf = (value, property) => {
29
+ var _a;
30
+ if (!Array.isArray(value) || !POINT_SIZES.includes(value.length) || !value.every(isDrawable)) {
31
+ throw new InputError(`\`${property}\` must be a point of 2 or 3 finite numbers below ${LARGEST_NUMBER} in size.`, property);
32
+ }
33
+ return [value[0], value[1], (_a = value[2]) !== null && _a !== void 0 ? _a : 0];
34
+ };
35
+ const directionOf = (value, property) => {
36
+ if (value === undefined) {
37
+ return PLUS_Z;
38
+ }
39
+ const direction = unitOf(pointOf(value, property));
40
+ if (direction === undefined) {
41
+ throw new InputError(`\`${property}\` must not be a zero vector.`, property);
42
+ }
43
+ return direction;
44
+ };
45
+ const numbersOf = (value, property) => {
46
+ if (!Array.isArray(value)) {
47
+ throw new InputError(`\`${property}\` must be a list of numbers.`, property);
48
+ }
49
+ return value.map((entry, at) => finiteNumber(entry, `${property}[${at}]`));
50
+ };
51
+ const lineOf = (segment, property) => ({
52
+ kind: "line",
53
+ start: pointOf(segment["start"], `${property}.start`),
54
+ end: pointOf(segment["end"], `${property}.end`),
55
+ });
56
+ const circleOf = (segment, property) => ({
57
+ kind: "circle",
58
+ center: pointOf(segment["center"], `${property}.center`),
59
+ radius: positiveNumber(segment["radius"], `${property}.radius`),
60
+ normal: directionOf(segment["normal"], `${property}.normal`),
61
+ });
62
+ const arcOf = (segment, property) => {
63
+ const startDegrees = angleWithinTurn(finiteNumber(segment["startAngle"], `${property}.startAngle`), FULL_TURN_DEGREES);
64
+ const endDegrees = angleWithinTurn(finiteNumber(segment["endAngle"], `${property}.endAngle`), FULL_TURN_DEGREES);
65
+ const turn = angleWithinTurn(endDegrees - startDegrees, FULL_TURN_DEGREES);
66
+ return {
67
+ kind: "arc",
68
+ center: pointOf(segment["center"], `${property}.center`),
69
+ radius: positiveNumber(segment["radius"], `${property}.radius`),
70
+ startAngle: radiansOf(startDegrees),
71
+ endAngle: radiansOf(startDegrees + (turn === 0 ? FULL_TURN_DEGREES : turn)),
72
+ startDegrees,
73
+ endDegrees,
74
+ normal: directionOf(segment["normal"], `${property}.normal`),
75
+ };
76
+ };
77
+ const polylineOf = (segment, property) => {
78
+ const given = segment["points"];
79
+ let points = given.map((point, at) => pointOf(point, `${property}.points[${at}]`));
80
+ if (points.length < 2) {
81
+ throw new InputError(`\`${property}.points\` must hold at least 2 points; it holds ${points.length}.`, `${property}.points`);
82
+ }
83
+ let bulges = segment["bulges"] === undefined ? points.map(() => 0) : numbersOf(segment["bulges"], `${property}.bulges`);
84
+ if (bulges.length !== points.length && bulges.length !== points.length - 1) {
85
+ throw new InputError(`\`${property}.bulges\` must hold one bulge per point (${points.length}); it holds ${bulges.length}.`, `${property}.bulges`);
86
+ }
87
+ bulges = points.map((_, at) => { var _a; return (_a = bulges[at]) !== null && _a !== void 0 ? _a : 0; });
88
+ let closed = segment["closed"] === true;
89
+ if (points.length > 2 && distance3(points[0], points[points.length - 1]) <= SAME_POINT) {
90
+ points = points.slice(0, -1);
91
+ bulges = bulges.slice(0, -1);
92
+ closed = true;
93
+ }
94
+ const planar = points.every(point => point[2] === points[0][2]);
95
+ if (!planar && bulges.some(bulge => bulge !== 0)) {
96
+ throw new InputError(`\`${property}\` has bulges, so its points must share one Z; a 3D polyline takes no bulges.`, `${property}.bulges`);
97
+ }
98
+ return { kind: "polyline", points, bulges, closed, planar };
99
+ };
100
+ const checkedKnots = (knots, pointCount, degree, property) => {
101
+ if (knots.length !== pointCount + degree + 1) {
102
+ throw new InputError(`\`${property}\` must hold ${pointCount + degree + 1} knots (the control points and the degree together, plus 1); it holds ${knots.length}.`, property);
103
+ }
104
+ if (knots.some((knot, at) => at > 0 && knot < knots[at - 1])) {
105
+ throw new InputError(`\`${property}\` must never decrease.`, property);
106
+ }
107
+ if (!(knots[degree] < knots[pointCount])) {
108
+ throw new InputError(`\`${property}\` gives the curve no length: knot ${degree} must be below knot ${pointCount}.`, property);
109
+ }
110
+ let run = 0;
111
+ for (let at = degree + 1; at < pointCount; at++) {
112
+ run = knots[at] === knots[at - 1] ? run + 1 : 1;
113
+ if (run > degree && knots[at] > knots[degree] && knots[at] < knots[pointCount]) {
114
+ throw new InputError(`\`${property}\` repeats an inner knot more often than the degree, which breaks the curve apart.`, property);
115
+ }
116
+ }
117
+ return knots;
118
+ };
119
+ const splineOf = (segment, property) => {
120
+ const points = segment["controlPoints"].map((point, at) => pointOf(point, `${property}.controlPoints[${at}]`));
121
+ const degree = segment["degree"] === undefined ? DEFAULT_SPLINE_DEGREE : finiteNumber(segment["degree"], `${property}.degree`);
122
+ if (!Number.isInteger(degree) || degree < 1 || degree > HIGHEST_SPLINE_DEGREE) {
123
+ throw new InputError(`\`${property}.degree\` must be a whole number from 1 to ${HIGHEST_SPLINE_DEGREE}; it is ${degree}.`, `${property}.degree`);
124
+ }
125
+ if (points.length <= degree) {
126
+ throw new InputError(`\`${property}.controlPoints\` must hold more points than the degree (${degree}); it holds ${points.length}.`, `${property}.controlPoints`);
127
+ }
128
+ const weights = segment["weights"] === undefined ? points.map(() => 1) : numbersOf(segment["weights"], `${property}.weights`);
129
+ if (weights.length !== points.length || weights.some(weight => weight < LEAST_WEIGHT)) {
130
+ throw new InputError(`\`${property}.weights\` must hold one weight of at least ${LEAST_WEIGHT} per control point (${points.length}).`, `${property}.weights`);
131
+ }
132
+ const overweight = points.findIndex((point, at) => point.some(coordinate => !isDrawable(coordinate * weights[at])));
133
+ if (overweight >= 0) {
134
+ throw new InputError(`\`${property}.weights[${overweight}]\` scales its control point to ${LARGEST_NUMBER} or more, past what a curve can be drawn from.`, `${property}.weights`);
135
+ }
136
+ let form;
137
+ if (segment["knots"] !== undefined) {
138
+ form = { degree, points, weights, knots: checkedKnots(numbersOf(segment["knots"], `${property}.knots`), points.length, degree, `${property}.knots`) };
139
+ }
140
+ else if (segment["closed"] === true) {
141
+ form = periodicUniformForm(points, weights, degree);
142
+ }
143
+ else {
144
+ form = { degree, points, weights, knots: clampedUniformKnots(points.length, degree) };
145
+ }
146
+ return { kind: "spline", curve: clampedForm(form) };
147
+ };
148
+ const ellipseOf = (segment, property) => {
149
+ const majorAxis = pointOf(segment["majorAxis"], `${property}.majorAxis`);
150
+ const majorDirection = unitOf(majorAxis);
151
+ if (majorDirection === undefined) {
152
+ throw new InputError(`\`${property}.majorAxis\` must not be a zero vector.`, `${property}.majorAxis`);
153
+ }
154
+ const ratio = positiveNumber(segment["ratio"], `${property}.ratio`);
155
+ if (ratio > 1) {
156
+ throw new InputError(`\`${property}.ratio\` must be at most 1, the minor axis being the shorter; it is ${ratio}.`, `${property}.ratio`);
157
+ }
158
+ const normal = directionOf(segment["normal"], `${property}.normal`);
159
+ if (Math.abs(dot3(normal, majorDirection)) > PERPENDICULAR_COSINE) {
160
+ throw new InputError(`\`${property}.majorAxis\` must lie in the ellipse's plane, perpendicular to its normal.`, `${property}.majorAxis`);
161
+ }
162
+ const start = segment["startParameter"] === undefined ? 0 : angleWithinTurn(finiteNumber(segment["startParameter"], `${property}.startParameter`), 2 * Math.PI);
163
+ const end = segment["endParameter"] === undefined ? 2 * Math.PI : finiteNumber(segment["endParameter"], `${property}.endParameter`);
164
+ const turn = angleWithinTurn(end - start, 2 * Math.PI);
165
+ return {
166
+ kind: "ellipse",
167
+ center: pointOf(segment["center"], `${property}.center`),
168
+ majorAxis,
169
+ ratio,
170
+ start,
171
+ end: start + (turn === 0 ? 2 * Math.PI : turn),
172
+ normal,
173
+ };
174
+ };
175
+ const segmentOf = (segment, property) => {
176
+ if (!isRecord(segment)) {
177
+ throw new InputError(`\`${property}\` must be a segment.`, property);
178
+ }
179
+ if (segment["majorAxis"] !== undefined) {
180
+ return ellipseOf(segment, property);
181
+ }
182
+ if (segment["center"] !== undefined && (segment["startAngle"] !== undefined || segment["endAngle"] !== undefined)) {
183
+ return arcOf(segment, property);
184
+ }
185
+ if (segment["center"] !== undefined && segment["radius"] !== undefined) {
186
+ return circleOf(segment, property);
187
+ }
188
+ if (segment["start"] !== undefined && segment["end"] !== undefined) {
189
+ return lineOf(segment, property);
190
+ }
191
+ if (Array.isArray(segment["points"])) {
192
+ return polylineOf(segment, property);
193
+ }
194
+ if (Array.isArray(segment["controlPoints"])) {
195
+ return splineOf(segment, property);
196
+ }
197
+ throw new InputError(`\`${property}\` is not a line, arc, circle, polyline, spline or ellipse segment.`, property);
198
+ };
199
+ const layerOf = (value, property) => {
200
+ const layer = typeof value === "string" ? value.trim() : "";
201
+ if (layer === "") {
202
+ return DEFAULT_LAYER;
203
+ }
204
+ if (layer.length > DXF_MAX_NAME_LENGTH) {
205
+ throw new InputError(`\`${property}\` is ${layer.length} characters long; a layer name holds at most ${DXF_MAX_NAME_LENGTH}.`, property);
206
+ }
207
+ if (FORBIDDEN_LAYER_CHARACTERS.test(layer) || [...layer].some(character => character.charCodeAt(0) < FIRST_PRINTABLE_CODE)) {
208
+ throw new InputError(`\`${property}\` "${layer}" holds a character layer names may not: < > / \\ " : ; ? * | = \` or a control character.`, property);
209
+ }
210
+ return layer;
211
+ };
212
+ const colorOf = (value, property) => {
213
+ const channels = typeof value === "string" && value.startsWith("#") ? hexChannels(value) : undefined;
214
+ if (channels === undefined) {
215
+ throw new InputError(`\`${property}\` must be a hex color such as #ff0000.`, property);
216
+ }
217
+ return hexOfChannels(channels);
218
+ };
219
+ const lineTypeOf = (value, property) => {
220
+ if (value === undefined) {
221
+ return Inputs.IO.lineTypeEnum.continuous;
222
+ }
223
+ if (typeof value !== "string" || !LINE_TYPES.has(value)) {
224
+ throw new InputError(`\`${property}\` must be one of ${[...LINE_TYPES].join(", ")}.`, property);
225
+ }
226
+ return value;
227
+ };
228
+ export const drawingPathOf = (path, property) => {
229
+ if (typeof path !== "object" || path === null || !Array.isArray(path.segments)) {
230
+ throw new InputError(`\`${property}.segments\` must be a list of segments.`, `${property}.segments`);
231
+ }
232
+ return { segments: path.segments.map((segment, at) => segmentOf(segment, `${property}.segments[${at}]`)) };
233
+ };
234
+ export const drawingPartsOf = (parts, property) => {
235
+ if (!Array.isArray(parts)) {
236
+ throw new InputError(`\`${property}\` must be a list of path parts.`, property);
237
+ }
238
+ return parts.map((part, at) => {
239
+ var _a, _b;
240
+ const where = `${property}[${at}]`;
241
+ if (!isRecord(part) || !Array.isArray(part["paths"])) {
242
+ throw new InputError(`\`${where}.paths\` must be a list of paths.`, `${where}.paths`);
243
+ }
244
+ const paths = part["paths"];
245
+ return {
246
+ layer: layerOf((_a = part["layer"]) !== null && _a !== void 0 ? _a : DEFAULT_LAYER, `${where}.layer`),
247
+ color: colorOf((_b = part["color"]) !== null && _b !== void 0 ? _b : "#000000", `${where}.color`),
248
+ lineType: lineTypeOf(part["lineType"], `${where}.lineType`),
249
+ paths: paths.map((path, index) => drawingPathOf(path, `${where}.paths[${index}]`)),
250
+ };
251
+ });
252
+ };
@@ -0,0 +1,60 @@
1
+ import type * as Inputs from "../../../../inputs";
2
+ import type { NurbsCurveForm } from "../../curves/nurbs-forms";
3
+ type Point3 = Inputs.Base.Point3;
4
+ type Vec3 = Inputs.Base.Vector3;
5
+ export interface DrawingLine {
6
+ readonly kind: "line";
7
+ readonly start: Point3;
8
+ readonly end: Point3;
9
+ }
10
+ export interface DrawingCircle {
11
+ readonly kind: "circle";
12
+ readonly center: Point3;
13
+ readonly radius: number;
14
+ readonly normal: Vec3;
15
+ }
16
+ export interface DrawingArc {
17
+ readonly kind: "arc";
18
+ readonly center: Point3;
19
+ readonly radius: number;
20
+ readonly startAngle: number;
21
+ readonly endAngle: number;
22
+ readonly startDegrees: number;
23
+ readonly endDegrees: number;
24
+ readonly normal: Vec3;
25
+ }
26
+ export interface DrawingPolyline {
27
+ readonly kind: "polyline";
28
+ readonly points: readonly Point3[];
29
+ readonly bulges: readonly number[];
30
+ readonly closed: boolean;
31
+ readonly planar: boolean;
32
+ }
33
+ export interface DrawingEllipse {
34
+ readonly kind: "ellipse";
35
+ readonly center: Point3;
36
+ readonly majorAxis: Vec3;
37
+ readonly ratio: number;
38
+ readonly start: number;
39
+ readonly end: number;
40
+ readonly normal: Vec3;
41
+ }
42
+ export interface DrawingSpline {
43
+ readonly kind: "spline";
44
+ readonly curve: NurbsCurveForm;
45
+ }
46
+ export type DrawingSegment = DrawingLine | DrawingCircle | DrawingArc | DrawingPolyline | DrawingEllipse | DrawingSpline;
47
+ export interface DrawingPath {
48
+ readonly segments: readonly DrawingSegment[];
49
+ }
50
+ export interface DrawingPart {
51
+ readonly layer: string;
52
+ readonly color: string;
53
+ readonly lineType: Inputs.IO.lineTypeEnum;
54
+ readonly paths: readonly DrawingPath[];
55
+ }
56
+ export interface DrawingBounds {
57
+ readonly min: Point3;
58
+ readonly max: Point3;
59
+ }
60
+ export {};
@@ -0,0 +1,28 @@
1
+ export declare const SAME_POINT = 1e-10;
2
+ export declare const PERPENDICULAR_COSINE = 1e-9;
3
+ export declare const FULL_TURN_DEGREES = 360;
4
+ export declare const ARBITRARY_AXIS_LIMIT: number;
5
+ export declare const FORBIDDEN_LAYER_CHARACTERS: RegExp;
6
+ export declare const FIRST_PRINTABLE_CODE = 32;
7
+ export declare const DEFAULT_LAYER = "0";
8
+ export declare const POINT_SIZES: number[];
9
+ export declare const DEFAULT_SPLINE_DEGREE = 3;
10
+ export declare const HIGHEST_SPLINE_DEGREE = 25;
11
+ export declare const LARGEST_NUMBER = 1e+100;
12
+ export declare const LEAST_WEIGHT = 1e-100;
13
+ export declare const PATTERN_UNIT_SHARE: number;
14
+ export declare const LEAST_TOLERANCE_SHARE = 0.000001;
15
+ export declare const PLAN_AXES = 2;
16
+ export declare const SPACE_AXES = 3;
17
+ export declare const WRITER_WORK_PER_NUMBER: number;
18
+ export declare const WRITER_WORK_FLOOR: number;
19
+ export declare const WRITER_WORK_CEILING: number;
20
+ export declare const NUMBERS_PER_PART = 1;
21
+ export declare const NUMBERS_PER_VERTEX = 4;
22
+ export declare const NUMBERS_PER_CURVE: Readonly<Record<"line" | "circle" | "arc" | "ellipse", number>>;
23
+ export interface LineTypePattern {
24
+ readonly name: string;
25
+ readonly description: string;
26
+ readonly elements: readonly number[];
27
+ }
28
+ export declare const LINE_TYPE_PATTERNS: Readonly<Record<string, LineTypePattern>>;
@@ -0,0 +1,29 @@
1
+ export const SAME_POINT = 1e-10;
2
+ export const PERPENDICULAR_COSINE = 1e-9;
3
+ export const FULL_TURN_DEGREES = 360;
4
+ export const ARBITRARY_AXIS_LIMIT = 1 / 64;
5
+ export const FORBIDDEN_LAYER_CHARACTERS = /[<>/\\":;?*|=`]/;
6
+ export const FIRST_PRINTABLE_CODE = 32;
7
+ export const DEFAULT_LAYER = "0";
8
+ export const POINT_SIZES = [2, 3];
9
+ export const DEFAULT_SPLINE_DEGREE = 3;
10
+ export const HIGHEST_SPLINE_DEGREE = 25;
11
+ export const LARGEST_NUMBER = 1e100;
12
+ export const LEAST_WEIGHT = 1e-100;
13
+ export const PATTERN_UNIT_SHARE = 1 / 200;
14
+ export const LEAST_TOLERANCE_SHARE = 1e-6;
15
+ export const PLAN_AXES = 2;
16
+ export const SPACE_AXES = 3;
17
+ export const WRITER_WORK_PER_NUMBER = Math.pow(2, 14);
18
+ export const WRITER_WORK_FLOOR = Math.pow(2, 20);
19
+ export const WRITER_WORK_CEILING = Math.pow(2, 25);
20
+ export const NUMBERS_PER_PART = 1;
21
+ export const NUMBERS_PER_VERTEX = 4;
22
+ export const NUMBERS_PER_CURVE = { line: 6, circle: 7, arc: 9, ellipse: 12 };
23
+ export const LINE_TYPE_PATTERNS = {
24
+ continuous: { name: "CONTINUOUS", description: "Solid line", elements: [] },
25
+ dashed: { name: "DASHED", description: "Dashed __ __ __ __", elements: [4, -2] },
26
+ hidden: { name: "HIDDEN", description: "Hidden _ _ _ _ _ _", elements: [2, -1] },
27
+ center: { name: "CENTER", description: "Center ____ _ ____ _", elements: [8, -1.5, 1.5, -1.5] },
28
+ dotted: { name: "DOT", description: "Dot . . . . . . .", elements: [0, -1] },
29
+ };
@@ -0,0 +1,5 @@
1
+ type Rgb = readonly [number, number, number];
2
+ export declare const ACI_PALETTE: readonly Rgb[];
3
+ export declare const nearestAciIndex: (hex: string) => number;
4
+ export declare const trueColorOf: (hex: string) => number;
5
+ export {};
@@ -0,0 +1,45 @@
1
+ import { hexChannels, hslChannels } from "../../color/color-forms";
2
+ import { DXF_FIXED_COLORS, DXF_GRAYS, DXF_HUE_STEP_DEGREES, DXF_HUES, DXF_PASTEL_SHARE, DXF_PURE_HUE_LIGHTNESS, DXF_SHADES, DXF_TRUE_COLOR_GREEN, DXF_TRUE_COLOR_RED, DXF_WHITE_OR_BLACK, } from "./dxf.constants";
3
+ const hueRgb = (hue, level) => {
4
+ const [red, green, blue] = hslChannels(hue, 1, DXF_PURE_HUE_LIGHTNESS);
5
+ return [red * level, green * level, blue * level];
6
+ };
7
+ const pastel = (rgb, level) => [
8
+ rgb[0] + (level - rgb[0]) * DXF_PASTEL_SHARE,
9
+ rgb[1] + (level - rgb[1]) * DXF_PASTEL_SHARE,
10
+ rgb[2] + (level - rgb[2]) * DXF_PASTEL_SHARE,
11
+ ];
12
+ const huePalette = () => {
13
+ const palette = [];
14
+ for (let hue = 0; hue < DXF_HUES; hue++) {
15
+ for (const level of DXF_SHADES) {
16
+ const full = hueRgb(hue * DXF_HUE_STEP_DEGREES, level);
17
+ palette.push(full, pastel(full, level));
18
+ }
19
+ }
20
+ return palette;
21
+ };
22
+ export const ACI_PALETTE = [
23
+ ...DXF_FIXED_COLORS,
24
+ ...huePalette(),
25
+ ...DXF_GRAYS.map((gray) => [gray, gray, gray]),
26
+ ];
27
+ const BLACK = [0, 0, 0];
28
+ const INDEXED_COLORS = [[DXF_WHITE_OR_BLACK, BLACK], ...ACI_PALETTE.map((rgb, at) => [at + 1, rgb])];
29
+ export const nearestAciIndex = (hex) => {
30
+ const [red, green, blue] = hexChannels(hex);
31
+ let nearest = DXF_WHITE_OR_BLACK;
32
+ let nearestDistance = Infinity;
33
+ for (const [index, rgb] of INDEXED_COLORS) {
34
+ const distance = Math.pow((rgb[0] - red), 2) + Math.pow((rgb[1] - green), 2) + Math.pow((rgb[2] - blue), 2);
35
+ if (distance < nearestDistance) {
36
+ nearestDistance = distance;
37
+ nearest = index;
38
+ }
39
+ }
40
+ return nearest;
41
+ };
42
+ export const trueColorOf = (hex) => {
43
+ const [red, green, blue] = hexChannels(hex);
44
+ return red * DXF_TRUE_COLOR_RED + green * DXF_TRUE_COLOR_GREEN + blue;
45
+ };
@@ -0,0 +1,17 @@
1
+ import type * as Inputs from "../../../../inputs";
2
+ import type { DrawingSegment } from "../drawing/drawing-types";
3
+ import type { DxfText } from "./dxf-text";
4
+ import type { DxfVersion } from "./dxf-tables";
5
+ export interface DxfEntityStyle {
6
+ readonly layer: string;
7
+ readonly color: string;
8
+ readonly lineType: Inputs.IO.lineTypeEnum | undefined;
9
+ }
10
+ export interface DxfEntityContext {
11
+ readonly text: DxfText;
12
+ readonly version: DxfVersion;
13
+ readonly owner: string;
14
+ readonly colorFormat: "aci" | "truecolor";
15
+ readonly curveTolerance: number;
16
+ }
17
+ export declare const writeSegment: (context: DxfEntityContext, segment: DrawingSegment, style: DxfEntityStyle) => void;
@@ -0,0 +1,193 @@
1
+ import { angleWithinTurn } from "../../curves/conic-arcs";
2
+ import { isRationalPiece } from "../../curves/nurbs-forms";
3
+ import { vectorToLocal } from "../../geometry/frame-axes";
4
+ import { distance3 } from "../../geometry/vectors";
5
+ import { ocsAxesOf, segmentSamples } from "../drawing/drawing-geometry";
6
+ import { LINE_TYPE_PATTERNS, SAME_POINT } from "../drawing/drawing.constants";
7
+ import { nearestAciIndex, trueColorOf } from "./dxf-colors";
8
+ import { DXF_CLOSED_FLAG, DXF_EXTRUSION_CODES, DXF_KNOT_TOLERANCE, DXF_OTHER_POINT_CODES, DXF_POINT_CODES, DXF_POLYLINE_3D_FLAG, DXF_RATIONAL_FLAG, DXF_TURN_SLACK } from "./dxf.constants";
9
+ const PLANAR_FLAG = 8;
10
+ const VERTEX_3D_FLAG = "32";
11
+ const PLUS_Z = [0, 0, 1];
12
+ const isModern = (context) => context.version === "AC1015";
13
+ const isPlusZ = (normal) => normal[0] === 0 && normal[1] === 0 && normal[2] > 0;
14
+ const openEntity = (context, kind, style, owner = context.owner) => {
15
+ const text = context.text;
16
+ text.pair("0", kind);
17
+ let handle = "";
18
+ if (isModern(context)) {
19
+ handle = text.nextHandle();
20
+ text.pair("5", handle);
21
+ text.pair("330", owner);
22
+ text.pair("100", "AcDbEntity");
23
+ }
24
+ text.name("8", style.layer);
25
+ if (style.lineType !== undefined) {
26
+ text.pair("6", LINE_TYPE_PATTERNS[style.lineType].name);
27
+ }
28
+ text.pair("62", String(nearestAciIndex(style.color)));
29
+ if (isModern(context) && context.colorFormat === "truecolor") {
30
+ text.pair("420", String(trueColorOf(style.color)));
31
+ }
32
+ return handle;
33
+ };
34
+ const writeLine = (context, line, style) => {
35
+ openEntity(context, "LINE", style);
36
+ if (isModern(context)) {
37
+ context.text.pair("100", "AcDbLine");
38
+ }
39
+ context.text.point(DXF_POINT_CODES, line.start);
40
+ context.text.point(DXF_OTHER_POINT_CODES, line.end);
41
+ };
42
+ const writeCircleOrArc = (context, segment, style) => {
43
+ const axes = ocsAxesOf(segment.normal);
44
+ const isWhole = segment.kind === "circle" || segment.endAngle - segment.startAngle >= 2 * Math.PI - DXF_TURN_SLACK;
45
+ openEntity(context, isWhole ? "CIRCLE" : "ARC", style);
46
+ const text = context.text;
47
+ if (isModern(context)) {
48
+ text.pair("100", "AcDbCircle");
49
+ }
50
+ text.point(DXF_POINT_CODES, vectorToLocal(axes, segment.center));
51
+ text.real("40", segment.radius);
52
+ if (!isPlusZ(segment.normal)) {
53
+ text.point(DXF_EXTRUSION_CODES, segment.normal);
54
+ }
55
+ if (!isWhole && segment.kind === "arc") {
56
+ if (isModern(context)) {
57
+ text.pair("100", "AcDbArc");
58
+ }
59
+ text.real("50", segment.startDegrees);
60
+ text.real("51", segment.endDegrees);
61
+ }
62
+ };
63
+ const writeLightPolyline = (context, points, bulges, closed, style) => {
64
+ openEntity(context, "LWPOLYLINE", style);
65
+ const text = context.text;
66
+ text.pair("100", "AcDbPolyline");
67
+ text.pair("90", String(points.length));
68
+ text.pair("70", closed ? "1" : "0");
69
+ if (points[0][2] !== 0) {
70
+ text.real("38", points[0][2]);
71
+ }
72
+ points.forEach((point, at) => {
73
+ var _a;
74
+ text.real("10", point[0]);
75
+ text.real("20", point[1]);
76
+ const bulge = (_a = bulges[at]) !== null && _a !== void 0 ? _a : 0;
77
+ if (bulge !== 0) {
78
+ text.real("42", bulge);
79
+ }
80
+ });
81
+ };
82
+ const writeHeavyPolyline = (context, points, bulges, closed, planar, style) => {
83
+ const owner = openEntity(context, "POLYLINE", style);
84
+ const text = context.text;
85
+ const vertexStyle = Object.assign(Object.assign({}, style), { lineType: undefined });
86
+ if (isModern(context)) {
87
+ text.pair("100", "AcDb3dPolyline");
88
+ }
89
+ text.pair("66", "1");
90
+ text.point(DXF_POINT_CODES, [0, 0, planar ? points[0][2] : 0]);
91
+ text.pair("70", String((closed ? DXF_CLOSED_FLAG : 0) + (planar ? 0 : DXF_POLYLINE_3D_FLAG)));
92
+ points.forEach((point, at) => {
93
+ var _a;
94
+ openEntity(context, "VERTEX", vertexStyle, owner);
95
+ if (isModern(context)) {
96
+ text.pair("100", "AcDbVertex");
97
+ text.pair("100", "AcDb3dPolylineVertex");
98
+ }
99
+ text.point(DXF_POINT_CODES, point);
100
+ const bulge = (_a = bulges[at]) !== null && _a !== void 0 ? _a : 0;
101
+ if (planar && bulge !== 0) {
102
+ text.real("42", bulge);
103
+ }
104
+ text.pair("70", planar ? "0" : VERTEX_3D_FLAG);
105
+ });
106
+ openEntity(context, "SEQEND", vertexStyle, owner);
107
+ };
108
+ const writePoints = (context, points, bulges, closed, style) => {
109
+ const planar = points.every(point => point[2] === points[0][2]);
110
+ if (planar && isModern(context)) {
111
+ writeLightPolyline(context, points, bulges, closed, style);
112
+ }
113
+ else {
114
+ writeHeavyPolyline(context, points, bulges, closed, planar, style);
115
+ }
116
+ };
117
+ const writePolyline = (context, polyline, style) => writePoints(context, polyline.points, polyline.bulges, polyline.closed, style);
118
+ const writeSamples = (context, segment, style) => {
119
+ const samples = segmentSamples(segment, context.curveTolerance, context.text.budget);
120
+ context.text.refuseWhenSpent();
121
+ const closed = samples.length > 2 && distance3(samples[0], samples[samples.length - 1]) <= SAME_POINT;
122
+ const points = closed ? samples.slice(0, -1) : samples;
123
+ writePoints(context, points, [], closed, style);
124
+ };
125
+ const writeSpline = (context, spline, style) => {
126
+ const curve = spline.curve;
127
+ const planar = curve.points.every(point => point[2] === curve.points[0][2]);
128
+ const rational = isRationalPiece(curve);
129
+ openEntity(context, "SPLINE", style);
130
+ const text = context.text;
131
+ text.pair("100", "AcDbSpline");
132
+ if (planar) {
133
+ text.point(DXF_EXTRUSION_CODES, PLUS_Z);
134
+ }
135
+ text.pair("70", String((planar ? PLANAR_FLAG : 0) + (rational ? DXF_RATIONAL_FLAG : 0)));
136
+ text.pair("71", String(curve.degree));
137
+ text.pair("72", String(curve.knots.length));
138
+ text.pair("73", String(curve.points.length));
139
+ text.pair("74", "0");
140
+ text.pair("42", DXF_KNOT_TOLERANCE);
141
+ text.pair("43", DXF_KNOT_TOLERANCE);
142
+ for (const knot of curve.knots) {
143
+ text.real("40", knot);
144
+ }
145
+ curve.points.forEach((point, at) => {
146
+ text.point(DXF_POINT_CODES, point);
147
+ if (rational) {
148
+ text.real("41", curve.weights[at]);
149
+ }
150
+ });
151
+ };
152
+ const writeEllipse = (context, ellipse, style) => {
153
+ openEntity(context, "ELLIPSE", style);
154
+ const text = context.text;
155
+ const isWhole = ellipse.end - ellipse.start >= 2 * Math.PI - DXF_TURN_SLACK;
156
+ text.pair("100", "AcDbEllipse");
157
+ text.point(DXF_POINT_CODES, ellipse.center);
158
+ text.point(DXF_OTHER_POINT_CODES, ellipse.majorAxis);
159
+ text.point(DXF_EXTRUSION_CODES, ellipse.normal);
160
+ text.real("40", ellipse.ratio);
161
+ text.real("41", isWhole ? 0 : angleWithinTurn(ellipse.start, 2 * Math.PI));
162
+ text.real("42", isWhole ? 2 * Math.PI : angleWithinTurn(ellipse.end, 2 * Math.PI));
163
+ };
164
+ export const writeSegment = (context, segment, style) => {
165
+ switch (segment.kind) {
166
+ case "line":
167
+ writeLine(context, segment, style);
168
+ break;
169
+ case "circle":
170
+ case "arc":
171
+ writeCircleOrArc(context, segment, style);
172
+ break;
173
+ case "polyline":
174
+ writePolyline(context, segment, style);
175
+ break;
176
+ case "spline":
177
+ if (isModern(context)) {
178
+ writeSpline(context, segment, style);
179
+ }
180
+ else {
181
+ writeSamples(context, segment, style);
182
+ }
183
+ break;
184
+ case "ellipse":
185
+ if (isModern(context)) {
186
+ writeEllipse(context, segment, style);
187
+ }
188
+ else {
189
+ writeSamples(context, segment, style);
190
+ }
191
+ break;
192
+ }
193
+ };
@@ -0,0 +1 @@
1
+ export declare const dxfTextOf: (data: unknown, property: string) => string;