Serializer of JSCAD geometries to SVG source (XML).
The serialization of the following geometries are possible.
- serialization of 2D geometry (geom2) to SVG path (a continous path containing the outlines of the geometry)
- serialization of 2D geometry (path2) to SVG path
Colors are added to SVG shapes when found on the geometry. Special attributes (id and class) are added to SVG shapes when found on the geometry.
- Source:
Example
const { serializer, mimeType } = require('@jscad/svg-serializer')
Methods
(static) serialize(options, …objects) → {Array}
Serialize the give objects to SVG code (XML).
Example
const geometry = primitives.square()
const svgData = serializer({unit: 'mm'}, geometry)
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for serialization, REQUIRED Properties
|
||||||||||||||||
objects |
Object | Array |
<repeatable> |
objects to serialize as SVG |
Returns:
serialized contents, SVG code (XML string)
- Type
- Array