@bitbybit-dev/base 1.6.2 → 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.
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +20 -7
- package/lib/api/inputs/base-inputs.js +10 -0
- package/lib/api/inputs/io-inputs.d.ts +527 -59
- package/lib/api/inputs/io-inputs.js +432 -40
- package/lib/api/inputs/line-inputs.d.ts +17 -0
- package/lib/api/inputs/line-inputs.js +15 -0
- package/lib/api/kernel-calls/index.d.ts +1 -0
- package/lib/api/kernel-calls/index.js +1 -0
- package/lib/api/kernel-calls/settings.d.ts +82 -0
- package/lib/api/kernel-calls/settings.js +123 -0
- 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 +22 -2
- 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 +24 -0
- package/lib/api/services/helpers/curves/conic-arcs.js +85 -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 +24 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +18 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +84 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +5 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.js +252 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +60 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +28 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +29 -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 +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +193 -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 +81 -523
- 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 +81 -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-types.d.ts +69 -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 +71 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +78 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +556 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +27 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +247 -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 +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +65 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +32 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +34 -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 +108 -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 +16 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +153 -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 +13 -0
- package/lib/api/services/helpers/files/svg/svg.constants.js +13 -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/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/io/drawing.d.ts +170 -0
- package/lib/api/services/io/drawing.js +212 -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 +64 -0
- package/lib/api/services/io/svg.js +102 -0
- package/lib/api/services/line.d.ts +17 -0
- package/lib/api/services/line.js +20 -1
- 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 +4 -1
- package/lib/api/services/text.d.ts +4 -1
- package/lib/api/services/text.js +8 -3
- 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,212 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import { resolveDto } from "../../kernel-calls";
|
|
3
|
+
/**
|
|
4
|
+
* Builds drawings as data, for any file format: segments of every kind, paths joined from segments,
|
|
5
|
+
* and parts that put paths on a layer with a color and a line type. `io.dxf.dxfCreate` writes the
|
|
6
|
+
* parts as DXF and `io.svg.svgCreate` as SVG; `svgToDxf` and `dxfToSvg` convert one file into the
|
|
7
|
+
* other through these parts.
|
|
8
|
+
*/
|
|
9
|
+
export class Drawing {
|
|
10
|
+
constructor(dxfOf, svgOf) {
|
|
11
|
+
this.dxfOf = dxfOf;
|
|
12
|
+
this.svgOf = svgOf;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Makes a straight segment of a drawing path, from `start` to `end`.
|
|
16
|
+
* @param inputs - The start and the end point
|
|
17
|
+
* @returns The line segment
|
|
18
|
+
* @group drawing
|
|
19
|
+
* @shortname line segment
|
|
20
|
+
* @drawable false
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
lineSegment(inputs) {
|
|
27
|
+
return inputs;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Makes a circular arc of a drawing path, running counterclockwise about its `center` from
|
|
31
|
+
* `startAngle` to `endAngle`, in degrees, in the XY plane unless a `normal` tilts it.
|
|
32
|
+
* @param inputs - The center, the radius, the start and end angles and the plane's normal
|
|
33
|
+
* @returns The arc segment
|
|
34
|
+
* @group drawing
|
|
35
|
+
* @shortname arc segment
|
|
36
|
+
* @drawable false
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [0, 0], radius: 10, startAngle: 0, endAngle: 90 });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
arcSegment(inputs) {
|
|
43
|
+
return inputs;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Makes a whole circle of a drawing path from its `center` and `radius`, in the XY plane unless a
|
|
47
|
+
* `normal` tilts it.
|
|
48
|
+
* @param inputs - The center, the radius and the plane's normal
|
|
49
|
+
* @returns The circle segment
|
|
50
|
+
* @group drawing
|
|
51
|
+
* @shortname circle segment
|
|
52
|
+
* @drawable false
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
circleSegment(inputs) {
|
|
59
|
+
return inputs;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Makes connected straight segments through `points`, which `bulges` can bend into arcs;
|
|
63
|
+
* `closed` joins the last point back to the first.
|
|
64
|
+
* @param inputs - The points, whether the polyline is closed, and the bulges
|
|
65
|
+
* @returns The polyline segment
|
|
66
|
+
* @group drawing
|
|
67
|
+
* @shortname polyline segment
|
|
68
|
+
* @drawable false
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const slot = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [30, 0], [30, 10], [0, 10]], closed: true, bulges: [0, 1, 0, 1] });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
polylineSegment(inputs) {
|
|
75
|
+
const resolved = resolveDto(Inputs.IO.DrawingPolylineSegmentDto, inputs);
|
|
76
|
+
return resolved;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Makes a B-spline or NURBS curve of a drawing path from its control points and degree, with
|
|
80
|
+
* its knots and weights when they are given.
|
|
81
|
+
* @param inputs - The control points, the degree, whether it is closed, the knots and the weights
|
|
82
|
+
* @returns The spline segment
|
|
83
|
+
* @group drawing
|
|
84
|
+
* @shortname spline segment
|
|
85
|
+
* @drawable false
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const wave = bitbybit.io.drawing.splineSegment({ controlPoints: [[0, 0], [10, 8], [20, -8], [30, 0]], degree: 3 });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
splineSegment(inputs) {
|
|
92
|
+
const resolved = resolveDto(Inputs.IO.DrawingSplineSegmentDto, inputs);
|
|
93
|
+
return resolved;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Makes an ellipse, or an arc of one, for a drawing path.
|
|
97
|
+
*
|
|
98
|
+
* The ellipse is given by its center, the vector to the end of its major axis and the minor to
|
|
99
|
+
* major ratio; parameters in radians pick the arc, running counterclockwise about the normal.
|
|
100
|
+
* @param inputs - The center, the major axis, the ratio, the start and end parameters and the plane's normal
|
|
101
|
+
* @returns The ellipse segment
|
|
102
|
+
* @group drawing
|
|
103
|
+
* @shortname ellipse segment
|
|
104
|
+
* @drawable false
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const lens = bitbybit.io.drawing.ellipseSegment({ center: [0, 0], majorAxis: [20, 0], ratio: 0.5, startParameter: 0, endParameter: Math.PI });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
ellipseSegment(inputs) {
|
|
111
|
+
const resolved = resolveDto(Inputs.IO.DrawingEllipseSegmentDto, inputs);
|
|
112
|
+
return resolved;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Joins segments into one path, drawn in order like the edges of a wire; segments that meet
|
|
116
|
+
* are drawn as one stroke in SVG.
|
|
117
|
+
* @param inputs - The segments, in order
|
|
118
|
+
* @returns The path
|
|
119
|
+
* @group drawing
|
|
120
|
+
* @shortname path
|
|
121
|
+
* @drawable false
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
125
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [40, 10], radius: 10, startAngle: 270, endAngle: 360 });
|
|
126
|
+
* const outline = bitbybit.io.drawing.path({ segments: [edge, corner] });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
path(inputs) {
|
|
130
|
+
return inputs;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Puts paths on a named layer with a color and a line type, making one part of a drawing.
|
|
134
|
+
*
|
|
135
|
+
* A drawing may hold several parts; `io.dxf.dxfCreate` writes them as DXF and `io.svg.svgCreate`
|
|
136
|
+
* as SVG.
|
|
137
|
+
* @param inputs - The layer name, the color, the paths and the line type
|
|
138
|
+
* @returns The part
|
|
139
|
+
* @group drawing
|
|
140
|
+
* @shortname part
|
|
141
|
+
* @drawable false
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const square = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
145
|
+
* const cut = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [square] }] });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
part(inputs) {
|
|
149
|
+
const resolved = resolveDto(Inputs.IO.DrawingPartDto, inputs);
|
|
150
|
+
return resolved;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Converts an SVG file into a DXF file, reading it as `io.svg.svgRead` does and writing it as
|
|
154
|
+
* `io.dxf.dxfCreate` does.
|
|
155
|
+
*
|
|
156
|
+
* Inkscape layers, stroke colors and dash patterns become DXF layers, colors and line types, and
|
|
157
|
+
* curves stay exact. With `unit` the drawing is read at true size and the DXF states that unit. A
|
|
158
|
+
* drawing too large to write throws.
|
|
159
|
+
* @param inputs - The SVG text, the unit, whether hidden elements are written, and the DXF's color format, version and curve tolerance
|
|
160
|
+
* @returns The DXF text and the reading's warnings
|
|
161
|
+
* @group convert
|
|
162
|
+
* @shortname svg to dxf
|
|
163
|
+
* @drawable false
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const converted = bitbybit.io.drawing.svgToDxf({ svg: svgText, unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
167
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: converted.dxf });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
svgToDxf(inputs) {
|
|
171
|
+
const resolved = resolveDto(Inputs.IO.SvgToDxfDto, inputs);
|
|
172
|
+
const drawing = this.svgOf().svgRead({ svg: resolved.svg, unit: resolved.unit, includeInvisible: resolved.includeInvisible });
|
|
173
|
+
const dxf = this.dxfOf().dxfCreate({
|
|
174
|
+
dxfPathsParts: drawing.parts,
|
|
175
|
+
colorFormat: resolved.colorFormat,
|
|
176
|
+
acadVersion: resolved.acadVersion,
|
|
177
|
+
unit: resolved.unit,
|
|
178
|
+
curveTolerance: resolved.curveTolerance,
|
|
179
|
+
});
|
|
180
|
+
return { dxf, warnings: drawing.warnings };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Converts a DXF file into an SVG file, reading it as `io.dxf.dxfRead` does and writing it as
|
|
184
|
+
* `io.svg.svgCreate` does.
|
|
185
|
+
*
|
|
186
|
+
* Layers become Inkscape layers and the SVG takes its true size from the unit the DXF states.
|
|
187
|
+
* Splines given only by fit points are left out and named in `warnings`; a drawing too large to
|
|
188
|
+
* write throws.
|
|
189
|
+
* @param inputs - The DXF file as text or bytes, whether hidden layers are written, and the SVG's line width, border and curve tolerance
|
|
190
|
+
* @returns The SVG text and the reading's warnings
|
|
191
|
+
* @group convert
|
|
192
|
+
* @shortname dxf to svg
|
|
193
|
+
* @drawable false
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const converted = bitbybit.io.drawing.dxfToSvg({ dxf: dxfText, includeHiddenLayers: true });
|
|
197
|
+
* const drawing = bitbybit.io.svg.svgRead({ svg: converted.svg });
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
dxfToSvg(inputs) {
|
|
201
|
+
const resolved = resolveDto(Inputs.IO.DxfToSvgDto, inputs);
|
|
202
|
+
const drawing = this.dxfOf().dxfRead({ dxf: resolved.dxf, includeHiddenLayers: resolved.includeHiddenLayers });
|
|
203
|
+
const svg = this.svgOf().svgCreate({
|
|
204
|
+
parts: drawing.parts,
|
|
205
|
+
unit: drawing.unit,
|
|
206
|
+
strokeWidth: resolved.strokeWidth,
|
|
207
|
+
margin: resolved.margin,
|
|
208
|
+
tolerance: resolved.tolerance,
|
|
209
|
+
});
|
|
210
|
+
return { svg, warnings: drawing.warnings };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -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 in the file's
|
|
120
|
+
* coordinates, block inserts expanded. Text, dimensions and hatches are left out and named in
|
|
121
|
+
* `warnings`; splines given only by fit points are read by `occt.io.loadDxf`.
|
|
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
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import { DxfGenerator } from "../helpers/files/dxf/dxf-generator";
|
|
3
|
+
import { resolveDto } from "../../kernel-calls";
|
|
4
|
+
import { readDxfDrawing } from "../helpers/files/dxf/dxf-reader";
|
|
5
|
+
import { dxfTextOf } from "../helpers/files/dxf/dxf-file-text";
|
|
6
|
+
import { drawingDtoOf } from "../helpers/files/dxf/dxf-reader-dtos";
|
|
7
|
+
/**
|
|
8
|
+
* Writes a drawing as a DXF file and reads a DXF file back into one. The drawing itself is built with
|
|
9
|
+
* `io.drawing`; the builders here are its former DXF-named copies.
|
|
10
|
+
*/
|
|
11
|
+
export class Dxf {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.dxfGenerator = new DxfGenerator();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Makes a straight segment for a drawing, under its former DXF name.
|
|
17
|
+
* @param inputs - The line segment definition
|
|
18
|
+
* @returns The line segment
|
|
19
|
+
* @group dxf
|
|
20
|
+
* @shortname line segment
|
|
21
|
+
* @drawable false
|
|
22
|
+
* @deprecated Use `io.drawing.lineSegment`, the same builder under the drawing's own name; this one is
|
|
23
|
+
* removed in the next major version.
|
|
24
|
+
*/
|
|
25
|
+
lineSegment(inputs) {
|
|
26
|
+
return inputs;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Makes a circular arc for a drawing, under its former DXF name.
|
|
30
|
+
* @param inputs - The arc segment definition
|
|
31
|
+
* @returns The arc segment
|
|
32
|
+
* @group dxf
|
|
33
|
+
* @shortname arc segment
|
|
34
|
+
* @drawable false
|
|
35
|
+
* @deprecated Use `io.drawing.arcSegment`, the same builder under the drawing's own name; this one is
|
|
36
|
+
* removed in the next major version.
|
|
37
|
+
*/
|
|
38
|
+
arcSegment(inputs) {
|
|
39
|
+
return inputs;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Makes a whole circle for a drawing, under its former DXF name.
|
|
43
|
+
* @param inputs - The circle segment definition
|
|
44
|
+
* @returns The circle segment
|
|
45
|
+
* @group dxf
|
|
46
|
+
* @shortname circle segment
|
|
47
|
+
* @drawable false
|
|
48
|
+
* @deprecated Use `io.drawing.circleSegment`, the same builder under the drawing's own name; this one is
|
|
49
|
+
* removed in the next major version.
|
|
50
|
+
*/
|
|
51
|
+
circleSegment(inputs) {
|
|
52
|
+
return inputs;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Makes connected straight segments for a drawing, under its former DXF name.
|
|
56
|
+
* @param inputs - The polyline segment definition
|
|
57
|
+
* @returns The polyline segment
|
|
58
|
+
* @group dxf
|
|
59
|
+
* @shortname polyline segment
|
|
60
|
+
* @drawable false
|
|
61
|
+
* @deprecated Use `io.drawing.polylineSegment`, the same builder under the drawing's own name; this one is
|
|
62
|
+
* removed in the next major version.
|
|
63
|
+
*/
|
|
64
|
+
polylineSegment(inputs) {
|
|
65
|
+
const resolved = resolveDto(Inputs.IO.DxfPolylineSegmentDto, inputs);
|
|
66
|
+
return resolved;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Makes a B-spline or NURBS curve for a drawing, under its former DXF name.
|
|
70
|
+
* @param inputs - The spline segment definition
|
|
71
|
+
* @returns The spline segment
|
|
72
|
+
* @group dxf
|
|
73
|
+
* @shortname spline segment
|
|
74
|
+
* @drawable false
|
|
75
|
+
* @deprecated Use `io.drawing.splineSegment`, the same builder under the drawing's own name; this one is
|
|
76
|
+
* removed in the next major version.
|
|
77
|
+
*/
|
|
78
|
+
splineSegment(inputs) {
|
|
79
|
+
const resolved = resolveDto(Inputs.IO.DxfSplineSegmentDto, inputs);
|
|
80
|
+
return resolved;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Makes an ellipse or an arc of one for a drawing, under its former DXF name.
|
|
84
|
+
* @param inputs - The ellipse segment definition
|
|
85
|
+
* @returns The ellipse segment
|
|
86
|
+
* @group dxf
|
|
87
|
+
* @shortname ellipse segment
|
|
88
|
+
* @drawable false
|
|
89
|
+
* @deprecated Use `io.drawing.ellipseSegment`, the same builder under the drawing's own name; this one is
|
|
90
|
+
* removed in the next major version.
|
|
91
|
+
*/
|
|
92
|
+
ellipseSegment(inputs) {
|
|
93
|
+
const resolved = resolveDto(Inputs.IO.DxfEllipseSegmentDto, inputs);
|
|
94
|
+
return resolved;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Makes a path joined from segments for a drawing, under its former DXF name.
|
|
98
|
+
* @param inputs - The path definition
|
|
99
|
+
* @returns The path
|
|
100
|
+
* @group dxf
|
|
101
|
+
* @shortname path
|
|
102
|
+
* @drawable false
|
|
103
|
+
* @deprecated Use `io.drawing.path`, the same builder under the drawing's own name; this one is
|
|
104
|
+
* removed in the next major version.
|
|
105
|
+
*/
|
|
106
|
+
path(inputs) {
|
|
107
|
+
return inputs;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Makes a part of a drawing on one layer for a drawing, under its former DXF name.
|
|
111
|
+
* @param inputs - The paths part definition
|
|
112
|
+
* @returns The paths part
|
|
113
|
+
* @group dxf
|
|
114
|
+
* @shortname paths part
|
|
115
|
+
* @drawable false
|
|
116
|
+
* @deprecated Use `io.drawing.part`, the same builder under the drawing's own name; this one is
|
|
117
|
+
* removed in the next major version.
|
|
118
|
+
*/
|
|
119
|
+
pathsPart(inputs) {
|
|
120
|
+
const resolved = resolveDto(Inputs.IO.DxfPathsPartDto, inputs);
|
|
121
|
+
return resolved;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Writes a DXF file from path parts, each on its layer with its color and line type.
|
|
125
|
+
*
|
|
126
|
+
* `AC1015` keeps every curve exact. `AC1009` (R12) writes splines and ellipses as polylines
|
|
127
|
+
* within `curveTolerance`, never finer than a millionth of the drawing. Points off one Z make a
|
|
128
|
+
* 3D polyline; a drawing too large to write throws.
|
|
129
|
+
* @param inputs DXF model definition
|
|
130
|
+
* @returns DXF file content as string
|
|
131
|
+
* @group dxf
|
|
132
|
+
* @shortname dxf create
|
|
133
|
+
* @drawable false
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
137
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
138
|
+
* const part = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [outline] }, { segments: [hole] }] });
|
|
139
|
+
* const dxf = bitbybit.io.dxf.dxfCreate({ dxfPathsParts: [part], unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
dxfCreate(inputs) {
|
|
143
|
+
const resolved = resolveDto(Inputs.IO.DxfModelDto, inputs);
|
|
144
|
+
return this.dxfGenerator.generateDxf(resolved);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Reads a DXF file into path parts by layer, color and line type, the model `dxfCreate` writes.
|
|
148
|
+
*
|
|
149
|
+
* Lines, arcs, circles, ellipses, polylines and splines are read exactly in the file's
|
|
150
|
+
* coordinates, block inserts expanded. Text, dimensions and hatches are left out and named in
|
|
151
|
+
* `warnings`; splines given only by fit points are read by `occt.io.loadDxf`.
|
|
152
|
+
* @param inputs - The DXF file, as text or bytes, and whether hidden layers are read
|
|
153
|
+
* @returns The drawing's parts, unit, version and warnings
|
|
154
|
+
* @group dxf
|
|
155
|
+
* @shortname dxf read
|
|
156
|
+
* @drawable false
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: dxfText });
|
|
160
|
+
* const svg = bitbybit.io.svg.svgCreate({ parts: drawing.parts, unit: drawing.unit });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
dxfRead(inputs) {
|
|
164
|
+
const resolved = resolveDto(Inputs.IO.DxfReadDto, inputs);
|
|
165
|
+
return drawingDtoOf(readDxfDrawing(dxfTextOf(resolved.dxf, "dxf"), resolved.includeHiddenLayers));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Drawing } from "./drawing";
|
|
2
|
+
import { Dxf } from "./dxf";
|
|
3
|
+
import { Svg } from "./svg";
|
|
4
|
+
/**
|
|
5
|
+
* Drawings as data, with no kernel: `drawing` builds one from segments, paths and layered parts and
|
|
6
|
+
* converts SVG files to DXF and back, `dxf` writes it as a DXF file and reads one back, and `svg` does
|
|
7
|
+
* the same for SVG.
|
|
8
|
+
*/
|
|
9
|
+
export declare class IoBitByBit {
|
|
10
|
+
drawing: Drawing;
|
|
11
|
+
dxf: Dxf;
|
|
12
|
+
svg: Svg;
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Drawing } from "./drawing";
|
|
2
|
+
import { Dxf } from "./dxf";
|
|
3
|
+
import { Svg } from "./svg";
|
|
4
|
+
/**
|
|
5
|
+
* Drawings as data, with no kernel: `drawing` builds one from segments, paths and layered parts and
|
|
6
|
+
* converts SVG files to DXF and back, `dxf` writes it as a DXF file and reads one back, and `svg` does
|
|
7
|
+
* the same for SVG.
|
|
8
|
+
*/
|
|
9
|
+
export class IoBitByBit {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.dxf = new Dxf();
|
|
12
|
+
this.svg = new Svg();
|
|
13
|
+
this.drawing = new Drawing(() => this.dxf, () => this.svg);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
/**
|
|
3
|
+
* Writes SVG drawings from the same path parts DXF files are made of: lines, arcs, circles, bulged
|
|
4
|
+
* polylines, splines and ellipses, kept exact wherever SVG can draw them. Reads SVG files back into
|
|
5
|
+
* those parts, by layer, color and line type.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Svg {
|
|
8
|
+
/**
|
|
9
|
+
* Writes an SVG file from path parts, each layer an Inkscape layer.
|
|
10
|
+
*
|
|
11
|
+
* Arcs, circles, ellipses and bulges stay exact arcs, unweighted splines up to degree 3 exact
|
|
12
|
+
* Beziers, others cubics within `tolerance` (at least a millionth of the drawing). Y points up, Z
|
|
13
|
+
* is dropped and `unit` gives the true size. A drawing too large to write throws.
|
|
14
|
+
* @param inputs - The path parts, the unit, the line width, the border and the curve tolerance
|
|
15
|
+
* @returns The SVG file as text
|
|
16
|
+
* @group svg
|
|
17
|
+
* @shortname svg create
|
|
18
|
+
* @drawable false
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const square = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
22
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
23
|
+
* const part = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [square] }, { segments: [hole] }] });
|
|
24
|
+
* const svg = bitbybit.io.svg.svgCreate({ parts: [part], unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
svgCreate(inputs: Inputs.IO.SvgModelDto): string;
|
|
28
|
+
/**
|
|
29
|
+
* Writes one drawing path as SVG path data, the text of a `path` element's `d` attribute.
|
|
30
|
+
*
|
|
31
|
+
* Segments that meet are drawn as one stroke, reversed where a segment ends where the stroke is,
|
|
32
|
+
* and a stroke that returns to its start is closed. Curves are kept exact as `svgCreate` keeps
|
|
33
|
+
* them.
|
|
34
|
+
* @param inputs - The path, whether Y is negated, and the curve tolerance
|
|
35
|
+
* @returns SVG path data
|
|
36
|
+
* @group svg
|
|
37
|
+
* @shortname path data
|
|
38
|
+
* @drawable false
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const slot = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [30, 0], [30, 10], [0, 10]], closed: true, bulges: [0, 1, 0, 1] });
|
|
42
|
+
* const data = bitbybit.io.svg.pathData({ path: { segments: [slot] }, flipY: false });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
pathData(inputs: Inputs.IO.SvgPathDataDto): string;
|
|
46
|
+
/**
|
|
47
|
+
* Reads an SVG file into path parts by layer, color and line type, the model `svgCreate` writes.
|
|
48
|
+
*
|
|
49
|
+
* Lines, arcs and Bezier curves are read exactly, transforms applied and Y turned up. Inkscape
|
|
50
|
+
* layers are layers, each stroke color (else fill) a color, each dash pattern a line type. Text
|
|
51
|
+
* and images are left out and named in `warnings`.
|
|
52
|
+
* @param inputs - The SVG text, the unit to read it in and whether hidden elements are read
|
|
53
|
+
* @returns The drawing's parts, unit, view box and warnings
|
|
54
|
+
* @group svg
|
|
55
|
+
* @shortname svg read
|
|
56
|
+
* @drawable false
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const drawing = bitbybit.io.svg.svgRead({ svg: svgText, unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
60
|
+
* const dxf = bitbybit.io.dxf.dxfCreate({ dxfPathsParts: drawing.parts, unit: drawing.unit });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
svgRead(inputs: Inputs.IO.SvgReadDto): Inputs.IO.SvgDrawingDto;
|
|
64
|
+
}
|