Writes an SVG file from path parts, each layer an Inkscape layer.
Arcs, circles, ellipses and bulges stay exact arcs, unweighted splines up to degree 3 exact
Beziers, others cubics within tolerance (at least a millionth of the drawing). Y points up, Z
is dropped and unit gives the true size. A drawing too large to write throws.
The path parts, the unit, the line width, the border and the curve tolerance
The SVG file as text
const square = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
const part = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [square] }, { segments: [hole] }] });
const svg = bitbybit.io.svg.svgCreate({ parts: [part], unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
Writes one drawing path as SVG path data, the text of a path element's d attribute.
Segments that meet are drawn as one stroke, reversed where a segment ends where the stroke is,
and a stroke that returns to its start is closed. Curves are kept exact as svgCreate keeps
them.
The path, whether Y is negated, and the curve tolerance
SVG path data
Reads an SVG file into path parts by layer, color and line type, the model svgCreate writes.
Lines, arcs and Bezier curves are read exactly, transforms applied and Y turned up. Inkscape
layers are layers, each stroke color (else fill) a color, each dash pattern a line type. Text
and images are left out and named in warnings.
The SVG text, the unit to read it in and whether hidden elements are read
The drawing's parts, unit, view box and warnings
Writes SVG drawings from the same path parts DXF files are made of: lines, arcs, circles, bulged polylines, splines and ellipses, kept exact wherever SVG can draw them. Reads SVG files back into those parts, by layer, color and line type.