@bitbybit-dev/base 1.6.2 → 1.8.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/NOTICE +24 -0
- package/README.md +3 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +40 -7
- package/lib/api/inputs/base-inputs.js +32 -0
- package/lib/api/inputs/io-inputs.d.ts +927 -59
- package/lib/api/inputs/io-inputs.js +769 -40
- package/lib/api/inputs/line-inputs.d.ts +17 -0
- package/lib/api/inputs/line-inputs.js +15 -0
- package/lib/api/inputs/mesh-inputs.d.ts +20 -1
- package/lib/api/inputs/mesh-inputs.js +23 -0
- package/lib/api/inputs/recipes-inputs.d.ts +13 -5
- package/lib/api/inputs/recipes-inputs.js +10 -5
- package/lib/api/kernel-calls/index.d.ts +2 -0
- package/lib/api/kernel-calls/index.js +2 -0
- package/lib/api/kernel-calls/resolve-dto.d.ts +3 -1
- package/lib/api/kernel-calls/resolve-dto.js +7 -2
- package/lib/api/kernel-calls/settings.d.ts +101 -0
- package/lib/api/kernel-calls/settings.js +123 -0
- package/lib/api/kernel-calls/up-axis-aliases.d.ts +25 -0
- package/lib/api/kernel-calls/up-axis-aliases.js +70 -0
- package/lib/api/models/simplex.d.ts +2 -0
- package/lib/api/models/simplex.js +10 -1
- package/lib/api/recipes/surface-mesh.d.ts +2 -1
- package/lib/api/recipes/surface-mesh.js +5 -3
- package/lib/api/resolved-inputs/index.d.ts +32 -3
- package/lib/api/services/base-bitbybit.d.ts +12 -0
- package/lib/api/services/base-bitbybit.js +19 -3
- package/lib/api/services/color.js +2 -3
- package/lib/api/services/helpers/color/color-forms.constants.d.ts +3 -0
- package/lib/api/services/helpers/color/color-forms.constants.js +3 -0
- package/lib/api/services/helpers/color/color-forms.d.ts +1 -0
- package/lib/api/services/helpers/color/color-forms.js +4 -1
- package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
- package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
- package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
- package/lib/api/services/helpers/color/css-colors.js +61 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
- package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.d.ts +26 -0
- package/lib/api/services/helpers/curves/conic-arcs.js +87 -0
- package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
- package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
- package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
- package/lib/api/services/helpers/curves/nurbs.js +10 -9
- package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-budget.js +34 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.d.ts +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.js +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.d.ts +4 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.js +271 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +21 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +101 -0
- package/lib/api/services/helpers/files/drawing/drawing-hatch.d.ts +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-hatch.js +123 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.js +91 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.js +336 -0
- package/lib/api/services/helpers/files/drawing/drawing-scale.d.ts +2 -0
- package/lib/api/services/helpers/files/drawing/drawing-scale.js +47 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.d.ts +9 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.js +25 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +117 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +41 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +46 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.js +96 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +196 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
- package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
- package/lib/api/services/helpers/files/dxf/dxf-generator.js +97 -523
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.js +312 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +115 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.js +151 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +96 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +134 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +95 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +446 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +29 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +248 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +11 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +89 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +43 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +47 -1
- package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
- package/lib/api/services/helpers/files/file-bytes.js +15 -0
- package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
- package/lib/api/services/helpers/files/ground-axes.js +4 -0
- package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
- package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
- package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
- package/lib/api/services/helpers/files/stl-axes.js +22 -0
- package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
- package/lib/api/services/helpers/files/stl-types.js +1 -0
- package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/stl.constants.js +11 -0
- package/lib/api/services/helpers/files/stl.d.ts +3 -0
- package/lib/api/services/helpers/files/stl.js +93 -0
- package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
- package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
- package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
- package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.js +132 -0
- package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
- package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
- package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
- package/lib/api/services/helpers/files/svg/svg-writer.d.ts +18 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +230 -0
- package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
- package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
- package/lib/api/services/helpers/files/svg/svg.constants.d.ts +14 -0
- package/lib/api/services/helpers/files/svg/svg.constants.js +14 -0
- package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
- package/lib/api/services/helpers/files/work-budget.js +26 -0
- package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
- package/lib/api/services/helpers/geometry/affine2.js +18 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
- package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
- package/lib/api/services/helpers/geometry/loop-fill.d.ts +2 -0
- package/lib/api/services/helpers/geometry/loop-fill.js +37 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
- package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
- package/lib/api/services/helpers/geometry/vectors.js +6 -0
- package/lib/api/services/helpers/helper-types.d.ts +33 -0
- package/lib/api/services/helpers/text/stroke-font.d.ts +6 -0
- package/lib/api/services/helpers/text/stroke-font.js +177 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.d.ts +2 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.js +18 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.d.ts +14 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.js +34 -0
- package/lib/api/services/io/drawing.d.ts +368 -0
- package/lib/api/services/io/drawing.js +454 -0
- package/lib/api/services/io/dxf.d.ts +134 -0
- package/lib/api/services/io/dxf.js +167 -0
- package/lib/api/services/io/index.d.ts +4 -0
- package/lib/api/services/io/index.js +4 -0
- package/lib/api/services/io/io.d.ts +14 -0
- package/lib/api/services/io/io.js +15 -0
- package/lib/api/services/io/svg.d.ts +66 -0
- package/lib/api/services/io/svg.js +105 -0
- package/lib/api/services/line.d.ts +17 -0
- package/lib/api/services/line.js +20 -1
- package/lib/api/services/mesh.d.ts +19 -0
- package/lib/api/services/mesh.js +40 -0
- package/lib/api/services/point.d.ts +4 -1
- package/lib/api/services/point.js +9 -4
- package/lib/api/services/recipes.d.ts +3 -0
- package/lib/api/services/recipes.js +6 -2
- package/lib/api/services/text.d.ts +7 -4
- package/lib/api/services/text.js +14 -27
- package/package.json +1 -1
- package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
- package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
- package/lib/api/services/io.d.ts +0 -9
- package/lib/api/services/io.js +0 -10
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import { resolveDto } from "../../kernel-calls";
|
|
3
|
+
import { simplex } from "../../models/simplex";
|
|
4
|
+
import { clippedHatchLinesOf, hatchLinesOf, hatchOutlinesOf } from "../helpers/files/drawing/drawing-hatch";
|
|
5
|
+
import { drawingHatchOf, drawingTextOf, positiveNumber } from "../helpers/files/drawing/drawing-model";
|
|
6
|
+
import { scaledDrawingParts } from "../helpers/files/drawing/drawing-scale";
|
|
7
|
+
import { textStrokesOf } from "../helpers/files/drawing/drawing-text";
|
|
8
|
+
import { dimensionExtentOf, dimensionPictureOf } from "../helpers/files/drawing/drawing-dimension";
|
|
9
|
+
import { strokeFontInk } from "../helpers/text/stroke-font";
|
|
10
|
+
const HATCH_BOUNDS_TOLERANCE = 0.01;
|
|
11
|
+
const MEASURED_AT = [0, 0];
|
|
12
|
+
/**
|
|
13
|
+
* Builds drawings as data, for any file format: segments of every kind, paths joined from segments,
|
|
14
|
+
* and parts that put paths on a layer with a color and a line type. `io.dxf.dxfCreate` writes the
|
|
15
|
+
* parts as DXF and `io.svg.svgCreate` as SVG; `svgToDxf` and `dxfToSvg` convert one file into the
|
|
16
|
+
* other through these parts.
|
|
17
|
+
*/
|
|
18
|
+
export class Drawing {
|
|
19
|
+
constructor(dxfOf, svgOf) {
|
|
20
|
+
this.dxfOf = dxfOf;
|
|
21
|
+
this.svgOf = svgOf;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Makes a straight segment of a drawing path, from `start` to `end`.
|
|
25
|
+
* @param inputs - The start and the end point
|
|
26
|
+
* @returns The line segment
|
|
27
|
+
* @group drawing
|
|
28
|
+
* @shortname line segment
|
|
29
|
+
* @drawable false
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
lineSegment(inputs) {
|
|
36
|
+
return inputs;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Makes a circular arc of a drawing path, running counterclockwise about its `center` from
|
|
40
|
+
* `startAngle` to `endAngle`, in degrees, in the XY plane unless a `normal` tilts it.
|
|
41
|
+
* @param inputs - The center, the radius, the start and end angles and the plane's normal
|
|
42
|
+
* @returns The arc segment
|
|
43
|
+
* @group drawing
|
|
44
|
+
* @shortname arc segment
|
|
45
|
+
* @drawable false
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [0, 0], radius: 10, startAngle: 0, endAngle: 90 });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
arcSegment(inputs) {
|
|
52
|
+
return inputs;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Makes a whole circle of a drawing path from its `center` and `radius`, in the XY plane unless a
|
|
56
|
+
* `normal` tilts it.
|
|
57
|
+
* @param inputs - The center, the radius and the plane's normal
|
|
58
|
+
* @returns The circle segment
|
|
59
|
+
* @group drawing
|
|
60
|
+
* @shortname circle segment
|
|
61
|
+
* @drawable false
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
circleSegment(inputs) {
|
|
68
|
+
return inputs;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Makes connected straight segments through `points`, which `bulges` can bend into arcs;
|
|
72
|
+
* `closed` joins the last point back to the first.
|
|
73
|
+
* @param inputs - The points, whether the polyline is closed, and the bulges
|
|
74
|
+
* @returns The polyline segment
|
|
75
|
+
* @group drawing
|
|
76
|
+
* @shortname polyline segment
|
|
77
|
+
* @drawable false
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const slot = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [30, 0], [30, 10], [0, 10]], closed: true, bulges: [0, 1, 0, 1] });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
polylineSegment(inputs) {
|
|
84
|
+
const resolved = resolveDto(Inputs.IO.DrawingPolylineSegmentDto, inputs);
|
|
85
|
+
return resolved;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Makes a B-spline or NURBS curve of a drawing path from its control points and degree, with
|
|
89
|
+
* its knots and weights when they are given.
|
|
90
|
+
* @param inputs - The control points, the degree, whether it is closed, the knots and the weights
|
|
91
|
+
* @returns The spline segment
|
|
92
|
+
* @group drawing
|
|
93
|
+
* @shortname spline segment
|
|
94
|
+
* @drawable false
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const wave = bitbybit.io.drawing.splineSegment({ controlPoints: [[0, 0], [10, 8], [20, -8], [30, 0]], degree: 3 });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
splineSegment(inputs) {
|
|
101
|
+
const resolved = resolveDto(Inputs.IO.DrawingSplineSegmentDto, inputs);
|
|
102
|
+
return resolved;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Makes an ellipse, or an arc of one, for a drawing path.
|
|
106
|
+
*
|
|
107
|
+
* The ellipse is given by its center, the vector to the end of its major axis and the minor to
|
|
108
|
+
* major ratio; parameters in radians pick the arc, running counterclockwise about the normal.
|
|
109
|
+
* @param inputs - The center, the major axis, the ratio, the start and end parameters and the plane's normal
|
|
110
|
+
* @returns The ellipse segment
|
|
111
|
+
* @group drawing
|
|
112
|
+
* @shortname ellipse segment
|
|
113
|
+
* @drawable false
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const lens = bitbybit.io.drawing.ellipseSegment({ center: [0, 0], majorAxis: [20, 0], ratio: 0.5, startParameter: 0, endParameter: Math.PI });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
ellipseSegment(inputs) {
|
|
120
|
+
const resolved = resolveDto(Inputs.IO.DrawingEllipseSegmentDto, inputs);
|
|
121
|
+
return resolved;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Joins segments into one path, drawn in order like the edges of a wire; segments that meet
|
|
125
|
+
* are drawn as one stroke in SVG.
|
|
126
|
+
* @param inputs - The segments, in order
|
|
127
|
+
* @returns The path
|
|
128
|
+
* @group drawing
|
|
129
|
+
* @shortname path
|
|
130
|
+
* @drawable false
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
134
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [40, 10], radius: 10, startAngle: 270, endAngle: 360 });
|
|
135
|
+
* const outline = bitbybit.io.drawing.path({ segments: [edge, corner] });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
path(inputs) {
|
|
139
|
+
return inputs;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Puts paths on a named layer with a color and a line type, making one part of a drawing.
|
|
143
|
+
*
|
|
144
|
+
* A drawing may hold several parts; `io.dxf.dxfCreate` writes them as DXF and `io.svg.svgCreate`
|
|
145
|
+
* as SVG.
|
|
146
|
+
* @param inputs - The layer name, the color, the paths and the line type
|
|
147
|
+
* @returns The part
|
|
148
|
+
* @group drawing
|
|
149
|
+
* @shortname part
|
|
150
|
+
* @drawable false
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const square = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
154
|
+
* const cut = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [square] }] });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
part(inputs) {
|
|
158
|
+
const resolved = resolveDto(Inputs.IO.DrawingPartDto, inputs);
|
|
159
|
+
return resolved;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Scales drawing parts about the origin, returning new parts and leaving the given ones unchanged.
|
|
163
|
+
*
|
|
164
|
+
* Points, radii, axes, text heights, hatch spacings and line weights are multiplied by `factor`;
|
|
165
|
+
* angles, bulges, knots and weights stay. Scale before writing with `io.dxf.dxfCreate` or
|
|
166
|
+
* `io.svg.svgCreate`: their `unit` labels the drawing and never scales it. A factor not above 0
|
|
167
|
+
* throws.
|
|
168
|
+
* @param inputs - The parts and the factor
|
|
169
|
+
* @returns New parts, scaled
|
|
170
|
+
* @group drawing
|
|
171
|
+
* @shortname scale parts
|
|
172
|
+
* @drawable false
|
|
173
|
+
* @beta
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const plate = bitbybit.io.drawing.part({ layer: "cut", paths: [{ segments: [{ center: [0, 0], radius: 25.4 }] }], lineWeight: 0.5 });
|
|
177
|
+
* const inches = bitbybit.io.drawing.scaleParts({ parts: [plate], factor: 1 / 25.4 });
|
|
178
|
+
* const dxf = bitbybit.io.dxf.dxfCreate({ dxfPathsParts: inches, unit: Bit.Inputs.Base.unitOfLengthEnum.inch });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
scaleParts(inputs) {
|
|
182
|
+
const resolved = resolveDto(Inputs.IO.DrawingScalePartsDto, inputs);
|
|
183
|
+
return scaledDrawingParts(resolved.parts, resolved.factor, "parts");
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Makes a line of text for a drawing part's `texts`, in the single-line stroke font.
|
|
187
|
+
*
|
|
188
|
+
* The text is placed by a point on its baseline; `anchor` says whether that point is its start,
|
|
189
|
+
* middle or end, `rotation` turns it and `widthFactor` narrows or widens its letters.
|
|
190
|
+
* @param inputs - The text, its position and height, its anchor, its angle and its width factor
|
|
191
|
+
* @returns The text
|
|
192
|
+
* @group drawing
|
|
193
|
+
* @shortname text
|
|
194
|
+
* @drawable false
|
|
195
|
+
* @beta
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const title = bitbybit.io.drawing.text({ text: "BRACKET", position: [20, 10], height: 5 });
|
|
199
|
+
* const notes = bitbybit.io.drawing.part({ layer: "text", paths: [], texts: [title], lineWeight: 0.35 });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
text(inputs) {
|
|
203
|
+
const resolved = resolveDto(Inputs.IO.DrawingTextDto, inputs);
|
|
204
|
+
return resolved;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Makes a hatched region for a drawing part's `hatches`: what the boundaries enclose, filled with
|
|
208
|
+
* a pattern of lines or with solid ink.
|
|
209
|
+
*
|
|
210
|
+
* A boundary inside another cuts a hole, and a boundary whose ends do not meet is closed by a
|
|
211
|
+
* straight line.
|
|
212
|
+
* @param inputs - The boundary paths, the pattern, and the angle and spacing of its lines
|
|
213
|
+
* @returns The hatch
|
|
214
|
+
* @group drawing
|
|
215
|
+
* @shortname hatch
|
|
216
|
+
* @drawable false
|
|
217
|
+
* @beta
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
221
|
+
* const bore = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
222
|
+
* const cut = bitbybit.io.drawing.hatch({ boundaries: [{ segments: [outline] }, { segments: [bore] }], angle: 45, spacing: 3 });
|
|
223
|
+
* const section = bitbybit.io.drawing.part({ layer: "hatch", paths: [], hatches: [cut], lineWeight: 0.18 });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
hatch(inputs) {
|
|
227
|
+
const resolved = resolveDto(Inputs.IO.DrawingHatchDto, inputs);
|
|
228
|
+
return resolved;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Gives the lines of a hatch's pattern, each from side to side of the box around its
|
|
232
|
+
* boundaries, for a renderer that draws them itself and clips them to the region.
|
|
233
|
+
*
|
|
234
|
+
* The lines stand where `io.svg.svgCreate` and `io.dxf.dxfCreate` put them, each whole. `solid`
|
|
235
|
+
* gives none, and a spacing too fine for the region throws.
|
|
236
|
+
* @param inputs - The boundary paths, the pattern, and the angle and spacing of its lines
|
|
237
|
+
* @returns The lines, each a start and an end point
|
|
238
|
+
* @group drawing
|
|
239
|
+
* @shortname hatch lines
|
|
240
|
+
* @drawable false
|
|
241
|
+
* @beta
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
245
|
+
* const lines = bitbybit.io.drawing.hatchLines({ boundaries: [{ segments: [outline] }], angle: 45, spacing: 3 });
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
hatchLines(inputs) {
|
|
249
|
+
const resolved = resolveDto(Inputs.IO.DrawingHatchDto, inputs);
|
|
250
|
+
return hatchLinesOf(drawingHatchOf(resolved, ""), HATCH_BOUNDS_TOLERANCE, "spacing");
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Gives the lines of a hatch's pattern clipped to its region, for a renderer that draws them
|
|
254
|
+
* itself.
|
|
255
|
+
*
|
|
256
|
+
* Inside follows the even-odd rule over every boundary, as `io.svg.svgCreate` fills a hatch, and
|
|
257
|
+
* curves are followed within `tolerance`. The lines stand where `hatchLines` puts them. `solid`
|
|
258
|
+
* gives none; a spacing too fine for the region throws.
|
|
259
|
+
* @param inputs - The boundary paths, the pattern, the angle and spacing of its lines, and the tolerance for curves
|
|
260
|
+
* @returns The pieces of the lines inside the region, each a start and an end point
|
|
261
|
+
* @group drawing
|
|
262
|
+
* @shortname clipped hatch lines
|
|
263
|
+
* @drawable false
|
|
264
|
+
* @beta
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
268
|
+
* const bore = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
269
|
+
* const lines = bitbybit.io.drawing.clippedHatchLines({ boundaries: [{ segments: [outline] }, { segments: [bore] }], angle: 45, spacing: 3, tolerance: 0.01 });
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
clippedHatchLines(inputs) {
|
|
273
|
+
const resolved = resolveDto(Inputs.IO.DrawingHatchRegionDto, inputs);
|
|
274
|
+
const tolerance = positiveNumber(resolved.tolerance, "tolerance");
|
|
275
|
+
return clippedHatchLinesOf(drawingHatchOf(resolved, ""), tolerance, "spacing");
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Gives the outlines of a hatch's region as closed loops of points, curves followed within
|
|
279
|
+
* `tolerance`, for a renderer that fills the region itself.
|
|
280
|
+
*
|
|
281
|
+
* Each loop lists every corner once. Fill them under the even-odd rule, as
|
|
282
|
+
* `mesh.triangulateLoops` does, to keep the holes open.
|
|
283
|
+
* Example: a circle of radius 5 at tolerance 0.01 -> one loop of 50 points
|
|
284
|
+
* @param inputs - The boundary paths and the tolerance for curves; the pattern, angle and spacing play no part
|
|
285
|
+
* @returns The loops, each a list of points
|
|
286
|
+
* @group drawing
|
|
287
|
+
* @shortname hatch outlines
|
|
288
|
+
* @drawable false
|
|
289
|
+
* @beta
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
293
|
+
* const bore = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
294
|
+
* const loops = bitbybit.io.drawing.hatchOutlines({ boundaries: [{ segments: [outline] }, { segments: [bore] }], tolerance: 0.01 });
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
hatchOutlines(inputs) {
|
|
298
|
+
const resolved = resolveDto(Inputs.IO.DrawingHatchRegionDto, inputs);
|
|
299
|
+
const tolerance = positiveNumber(resolved.tolerance, "tolerance");
|
|
300
|
+
return hatchOutlinesOf(drawingHatchOf(resolved, ""), tolerance);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Measures a drawing text: its length along the baseline, and how far the font's ink reaches
|
|
304
|
+
* above and below it.
|
|
305
|
+
*
|
|
306
|
+
* The width is what `io.svg.svgCreate` draws and `io.dxf.dxfCreate` fits the text to; the
|
|
307
|
+
* position is not needed to measure it. A text that is not one line throws.
|
|
308
|
+
* Example: 'I' at height 21 -> width 8, above 25, below 7
|
|
309
|
+
* @param inputs - The text with its height and width factor
|
|
310
|
+
* @returns The width, and the reach of the font's ink above and below the baseline
|
|
311
|
+
* @group drawing
|
|
312
|
+
* @shortname text size
|
|
313
|
+
* @drawable false
|
|
314
|
+
* @beta
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* const size = bitbybit.io.drawing.textSize({ text: "SECTION A-A", position: [0, 0], height: 3.5 });
|
|
318
|
+
* const cellWidth = size.width + 2;
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
textSize(inputs) {
|
|
322
|
+
var _a;
|
|
323
|
+
const resolved = resolveDto(Inputs.IO.DrawingTextDto, inputs);
|
|
324
|
+
const text = drawingTextOf(Object.assign(Object.assign({}, resolved), { position: (_a = resolved.position) !== null && _a !== void 0 ? _a : MEASURED_AT }), "");
|
|
325
|
+
const ink = strokeFontInk(simplex);
|
|
326
|
+
return { width: text.width, above: ink.highest * text.height, below: -ink.lowest * text.height };
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Draws a drawing text as the strokes of its letters, each a list of points in the drawing's
|
|
330
|
+
* coordinates, placed, turned and narrowed as the text says.
|
|
331
|
+
*
|
|
332
|
+
* These are the strokes `io.svg.svgCreate` writes. A text that is not one line throws.
|
|
333
|
+
* Example: 'I' at height 21 from [10, 20] -> one stroke, [[14, 41, 0], [14, 20, 0]]
|
|
334
|
+
* @param inputs - The text, its position and height, its anchor, its angle and its width factor
|
|
335
|
+
* @returns The strokes, each a list of points
|
|
336
|
+
* @group drawing
|
|
337
|
+
* @shortname text strokes
|
|
338
|
+
* @drawable false
|
|
339
|
+
* @beta
|
|
340
|
+
* @example
|
|
341
|
+
* ```typescript
|
|
342
|
+
* const strokes = bitbybit.io.drawing.textStrokes({ text: "A-A", position: [0, 0], height: 5, anchor: "middle" });
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
textStrokes(inputs) {
|
|
346
|
+
const resolved = resolveDto(Inputs.IO.DrawingTextDto, inputs);
|
|
347
|
+
return textStrokesOf(drawingTextOf(resolved, ""));
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Draws a dimension in the drawing's plane: its dimension line or arc, its extension lines, filled
|
|
351
|
+
* arrowheads touching them, and its value in the stroke font.
|
|
352
|
+
*
|
|
353
|
+
* The text reads from left to right or from bottom to top, past the line's end when the line is
|
|
354
|
+
* too short for it; arrows go outside a span too short for them.
|
|
355
|
+
* @param inputs - What the dimension measures, its points, its tolerance and the size of its text and arrows
|
|
356
|
+
* @returns The lines, the arrowheads to fill, the text as strokes and as a drawing text, and the box they fill
|
|
357
|
+
* @group drawing
|
|
358
|
+
* @shortname dimension picture
|
|
359
|
+
* @drawable false
|
|
360
|
+
* @beta
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* const picture = bitbybit.io.drawing.dimensionPicture({ kind: Bit.Inputs.IO.dimensionKindEnum.linear, start: [0, 0], end: [60, 0], offset: 12, upperTolerance: 0.1, lowerTolerance: 0.1 });
|
|
364
|
+
* const edges = bitbybit.io.drawing.part({ layer: "dimensions", paths: [...picture.lines, ...picture.textStrokes].map(points => ({ segments: [{ points }] })) });
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
dimensionPicture(inputs) {
|
|
368
|
+
const resolved = resolveDto(Inputs.IO.DrawingDimensionDto, inputs);
|
|
369
|
+
return dimensionPictureOf(resolved);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Measures the box a dimension's picture fills, the box `dimensionPicture` gives, without drawing
|
|
373
|
+
* the letters.
|
|
374
|
+
*
|
|
375
|
+
* The box holds the whole height the stroke font's letters may reach, so a layout can make room
|
|
376
|
+
* before drawing.
|
|
377
|
+
* Example: a linear dimension from [0, 0] to [60, 0] at offset 12 -> min [0, 0.875], max [60, 17.04]
|
|
378
|
+
* @param inputs - What the dimension measures, its points, its tolerance and the size of its text and arrows
|
|
379
|
+
* @returns The lowest and highest corners of the box
|
|
380
|
+
* @group drawing
|
|
381
|
+
* @shortname dimension extent
|
|
382
|
+
* @drawable false
|
|
383
|
+
* @beta
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* const box = bitbybit.io.drawing.dimensionExtent({ kind: Bit.Inputs.IO.dimensionKindEnum.diameter, start: [0, 0], end: [5, 0] });
|
|
387
|
+
* const width = box.max[0] - box.min[0];
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
dimensionExtent(inputs) {
|
|
391
|
+
const resolved = resolveDto(Inputs.IO.DrawingDimensionDto, inputs);
|
|
392
|
+
return dimensionExtentOf(resolved);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Converts an SVG file into a DXF file, reading it as `io.svg.svgRead` does and writing it as
|
|
396
|
+
* `io.dxf.dxfCreate` does.
|
|
397
|
+
*
|
|
398
|
+
* Inkscape layers, stroke colors and dash patterns become DXF layers, colors and line types, and
|
|
399
|
+
* curves stay exact. With `unit` the drawing is read at true size and the DXF states that unit. A
|
|
400
|
+
* drawing too large to write throws.
|
|
401
|
+
* @param inputs - The SVG text, the unit, whether hidden elements are written, and the DXF's color format, version and curve tolerance
|
|
402
|
+
* @returns The DXF text and the reading's warnings
|
|
403
|
+
* @group convert
|
|
404
|
+
* @shortname svg to dxf
|
|
405
|
+
* @drawable false
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const converted = bitbybit.io.drawing.svgToDxf({ svg: svgText, unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
409
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: converted.dxf });
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
svgToDxf(inputs) {
|
|
413
|
+
const resolved = resolveDto(Inputs.IO.SvgToDxfDto, inputs);
|
|
414
|
+
const drawing = this.svgOf().svgRead({ svg: resolved.svg, unit: resolved.unit, includeInvisible: resolved.includeInvisible });
|
|
415
|
+
const dxf = this.dxfOf().dxfCreate({
|
|
416
|
+
dxfPathsParts: drawing.parts,
|
|
417
|
+
colorFormat: resolved.colorFormat,
|
|
418
|
+
acadVersion: resolved.acadVersion,
|
|
419
|
+
unit: resolved.unit,
|
|
420
|
+
curveTolerance: resolved.curveTolerance,
|
|
421
|
+
});
|
|
422
|
+
return { dxf, warnings: drawing.warnings };
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Converts a DXF file into an SVG file, reading it as `io.dxf.dxfRead` does and writing it as
|
|
426
|
+
* `io.svg.svgCreate` does.
|
|
427
|
+
*
|
|
428
|
+
* Layers become Inkscape layers and the SVG takes its true size from the unit the DXF states.
|
|
429
|
+
* Splines given only by fit points are left out and named in `warnings`; a drawing too large to
|
|
430
|
+
* write throws.
|
|
431
|
+
* @param inputs - The DXF file as text or bytes, whether hidden layers are written, and the SVG's line width, border and curve tolerance
|
|
432
|
+
* @returns The SVG text and the reading's warnings
|
|
433
|
+
* @group convert
|
|
434
|
+
* @shortname dxf to svg
|
|
435
|
+
* @drawable false
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* const converted = bitbybit.io.drawing.dxfToSvg({ dxf: dxfText, includeHiddenLayers: true });
|
|
439
|
+
* const drawing = bitbybit.io.svg.svgRead({ svg: converted.svg });
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
dxfToSvg(inputs) {
|
|
443
|
+
const resolved = resolveDto(Inputs.IO.DxfToSvgDto, inputs);
|
|
444
|
+
const drawing = this.dxfOf().dxfRead({ dxf: resolved.dxf, includeHiddenLayers: resolved.includeHiddenLayers });
|
|
445
|
+
const svg = this.svgOf().svgCreate({
|
|
446
|
+
parts: drawing.parts,
|
|
447
|
+
unit: drawing.unit,
|
|
448
|
+
strokeWidth: resolved.strokeWidth,
|
|
449
|
+
margin: resolved.margin,
|
|
450
|
+
tolerance: resolved.tolerance,
|
|
451
|
+
});
|
|
452
|
+
return { svg, warnings: drawing.warnings };
|
|
453
|
+
}
|
|
454
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
/**
|
|
3
|
+
* Writes a drawing as a DXF file and reads a DXF file back into one. The drawing itself is built with
|
|
4
|
+
* `io.drawing`; the builders here are its former DXF-named copies.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Dxf {
|
|
7
|
+
private readonly dxfGenerator;
|
|
8
|
+
/**
|
|
9
|
+
* Makes a straight segment for a drawing, under its former DXF name.
|
|
10
|
+
* @param inputs - The line segment definition
|
|
11
|
+
* @returns The line segment
|
|
12
|
+
* @group dxf
|
|
13
|
+
* @shortname line segment
|
|
14
|
+
* @drawable false
|
|
15
|
+
* @deprecated Use `io.drawing.lineSegment`, the same builder under the drawing's own name; this one is
|
|
16
|
+
* removed in the next major version.
|
|
17
|
+
*/
|
|
18
|
+
lineSegment(inputs: Inputs.IO.DxfLineSegmentDto): Inputs.IO.DxfLineSegmentDto;
|
|
19
|
+
/**
|
|
20
|
+
* Makes a circular arc for a drawing, under its former DXF name.
|
|
21
|
+
* @param inputs - The arc segment definition
|
|
22
|
+
* @returns The arc segment
|
|
23
|
+
* @group dxf
|
|
24
|
+
* @shortname arc segment
|
|
25
|
+
* @drawable false
|
|
26
|
+
* @deprecated Use `io.drawing.arcSegment`, the same builder under the drawing's own name; this one is
|
|
27
|
+
* removed in the next major version.
|
|
28
|
+
*/
|
|
29
|
+
arcSegment(inputs: Inputs.IO.DxfArcSegmentDto): Inputs.IO.DxfArcSegmentDto;
|
|
30
|
+
/**
|
|
31
|
+
* Makes a whole circle for a drawing, under its former DXF name.
|
|
32
|
+
* @param inputs - The circle segment definition
|
|
33
|
+
* @returns The circle segment
|
|
34
|
+
* @group dxf
|
|
35
|
+
* @shortname circle segment
|
|
36
|
+
* @drawable false
|
|
37
|
+
* @deprecated Use `io.drawing.circleSegment`, the same builder under the drawing's own name; this one is
|
|
38
|
+
* removed in the next major version.
|
|
39
|
+
*/
|
|
40
|
+
circleSegment(inputs: Inputs.IO.DxfCircleSegmentDto): Inputs.IO.DxfCircleSegmentDto;
|
|
41
|
+
/**
|
|
42
|
+
* Makes connected straight segments for a drawing, under its former DXF name.
|
|
43
|
+
* @param inputs - The polyline segment definition
|
|
44
|
+
* @returns The polyline segment
|
|
45
|
+
* @group dxf
|
|
46
|
+
* @shortname polyline segment
|
|
47
|
+
* @drawable false
|
|
48
|
+
* @deprecated Use `io.drawing.polylineSegment`, the same builder under the drawing's own name; this one is
|
|
49
|
+
* removed in the next major version.
|
|
50
|
+
*/
|
|
51
|
+
polylineSegment(inputs: Inputs.IO.DxfPolylineSegmentDto): Inputs.IO.DxfPolylineSegmentDto;
|
|
52
|
+
/**
|
|
53
|
+
* Makes a B-spline or NURBS curve for a drawing, under its former DXF name.
|
|
54
|
+
* @param inputs - The spline segment definition
|
|
55
|
+
* @returns The spline segment
|
|
56
|
+
* @group dxf
|
|
57
|
+
* @shortname spline segment
|
|
58
|
+
* @drawable false
|
|
59
|
+
* @deprecated Use `io.drawing.splineSegment`, the same builder under the drawing's own name; this one is
|
|
60
|
+
* removed in the next major version.
|
|
61
|
+
*/
|
|
62
|
+
splineSegment(inputs: Inputs.IO.DxfSplineSegmentDto): Inputs.IO.DxfSplineSegmentDto;
|
|
63
|
+
/**
|
|
64
|
+
* Makes an ellipse or an arc of one for a drawing, under its former DXF name.
|
|
65
|
+
* @param inputs - The ellipse segment definition
|
|
66
|
+
* @returns The ellipse segment
|
|
67
|
+
* @group dxf
|
|
68
|
+
* @shortname ellipse segment
|
|
69
|
+
* @drawable false
|
|
70
|
+
* @deprecated Use `io.drawing.ellipseSegment`, the same builder under the drawing's own name; this one is
|
|
71
|
+
* removed in the next major version.
|
|
72
|
+
*/
|
|
73
|
+
ellipseSegment(inputs: Inputs.IO.DxfEllipseSegmentDto): Inputs.IO.DxfEllipseSegmentDto;
|
|
74
|
+
/**
|
|
75
|
+
* Makes a path joined from segments for a drawing, under its former DXF name.
|
|
76
|
+
* @param inputs - The path definition
|
|
77
|
+
* @returns The path
|
|
78
|
+
* @group dxf
|
|
79
|
+
* @shortname path
|
|
80
|
+
* @drawable false
|
|
81
|
+
* @deprecated Use `io.drawing.path`, the same builder under the drawing's own name; this one is
|
|
82
|
+
* removed in the next major version.
|
|
83
|
+
*/
|
|
84
|
+
path(inputs: Inputs.IO.DxfPathDto): Inputs.IO.DxfPathDto;
|
|
85
|
+
/**
|
|
86
|
+
* Makes a part of a drawing on one layer for a drawing, under its former DXF name.
|
|
87
|
+
* @param inputs - The paths part definition
|
|
88
|
+
* @returns The paths part
|
|
89
|
+
* @group dxf
|
|
90
|
+
* @shortname paths part
|
|
91
|
+
* @drawable false
|
|
92
|
+
* @deprecated Use `io.drawing.part`, the same builder under the drawing's own name; this one is
|
|
93
|
+
* removed in the next major version.
|
|
94
|
+
*/
|
|
95
|
+
pathsPart(inputs: Inputs.IO.DxfPathsPartDto): Inputs.IO.DxfPathsPartDto;
|
|
96
|
+
/**
|
|
97
|
+
* Writes a DXF file from path parts, each on its layer with its color and line type.
|
|
98
|
+
*
|
|
99
|
+
* `AC1015` keeps every curve exact. `AC1009` (R12) writes splines and ellipses as polylines
|
|
100
|
+
* within `curveTolerance`, never finer than a millionth of the drawing. Points off one Z make a
|
|
101
|
+
* 3D polyline; a drawing too large to write throws.
|
|
102
|
+
* @param inputs DXF model definition
|
|
103
|
+
* @returns DXF file content as string
|
|
104
|
+
* @group dxf
|
|
105
|
+
* @shortname dxf create
|
|
106
|
+
* @drawable false
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
110
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
111
|
+
* const part = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [outline] }, { segments: [hole] }] });
|
|
112
|
+
* const dxf = bitbybit.io.dxf.dxfCreate({ dxfPathsParts: [part], unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
dxfCreate(inputs: Inputs.IO.DxfModelDto): string;
|
|
116
|
+
/**
|
|
117
|
+
* Reads a DXF file into path parts by layer, color and line type, the model `dxfCreate` writes.
|
|
118
|
+
*
|
|
119
|
+
* Lines, arcs, circles, ellipses, polylines and splines are read exactly, block inserts
|
|
120
|
+
* expanded, with single-line texts and hatches. Multi-line text and dimensions are named in
|
|
121
|
+
* `warnings`; `occt.io.loadDxf` reads splines given only by fit points.
|
|
122
|
+
* @param inputs - The DXF file, as text or bytes, and whether hidden layers are read
|
|
123
|
+
* @returns The drawing's parts, unit, version and warnings
|
|
124
|
+
* @group dxf
|
|
125
|
+
* @shortname dxf read
|
|
126
|
+
* @drawable false
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: dxfText });
|
|
130
|
+
* const svg = bitbybit.io.svg.svgCreate({ parts: drawing.parts, unit: drawing.unit });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
dxfRead(inputs: Inputs.IO.DxfReadDto): Inputs.IO.DxfDrawingDto;
|
|
134
|
+
}
|