Cadova 0.5.0
SVG Import
Cadova 0.5 adds support for importing SVG as 2D geometry via Pelagos. Import is now generic over Dimensionality. Importing 3D models works as before, but new initializers for SVG have been added. These take the path or URL to an SVG file and two options:
scale:
.physical: The default. SVGs are imported according to standard SVG conversions. Physical units are preserved, so "1mm" in SVG becomes an actual millimeter in your model. Pixel units are scaled correspondingly: 1 pixel becomes ~0.265 mm (96 pixels per inch)..pixels: Pixels are converted to millimeters and physical units are scaled correspondingly. This can be more convenient when dealing with graphics designed for screens.
Regardless of the scale option, you can scale the result however you'd like after import.
origin:
.flipped: The default. The SVG is flipped along the Y axis so it appears the same way it normally would. This is needed because SVG starts Y at the top and Cadova starts it at the bottom..native: Preserves SVG coordinates as-is, which can look incorrect but can be easier to deal with in some cases.
The easiest way to embed an SVG into your Swift package is to create a resource directory and reference it in your target in Package.swift:
resources: [.embedInCode("resources")],You will get generated code in a struct called PackageResources. Pass these data arrays to Import:
Import(svg: PackageResources.snake_svg)A corresponding DataProtocol initializer has been added for Import<D3> so you can use the same approach for embedded 3D models as well.
Bug Fixes
- Fixed
wrappedAroundCirclecalculating incorrect radius when inferring from geometry bounds, causing geometry to only wrap halfway around the circle