https://github.com/richardpiazza/vectorplus
A utility & library for converting SVG paths to Core Graphics images.
https://github.com/richardpiazza/vectorplus
coregraphics svg swift
Last synced: 4 months ago
JSON representation
A utility & library for converting SVG paths to Core Graphics images.
- Host: GitHub
- URL: https://github.com/richardpiazza/vectorplus
- Owner: richardpiazza
- License: mit
- Created: 2020-05-12T12:44:20.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T15:51:02.000Z (almost 2 years ago)
- Last Synced: 2025-08-12T00:55:26.180Z (11 months ago)
- Topics: coregraphics, svg, swift
- Language: Swift
- Homepage:
- Size: 173 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VectorPlus
A library & utility for interacting with SVG documents.
[](https://swiftpackageindex.com/richardpiazza/VectorPlus)
[](https://swiftpackageindex.com/richardpiazza/VectorPlus)
## Packages
### VectorPlus
**VectorPlus** acts primarily as a wrapper over `SwiftSVG` providing extensions for interacting with:
* `CoreGraphics`
* `UIKit`
* `AppKit`
* `SwiftUI`
When linked to a target that supports one of these frameworks, multiple options become available.
#### CoreGraphics
* `CGMutablePath.addCommand(_:from:to:)`: Adds a `Path.Command` to the mutable path. The addition of the `Rect`s allow for correct placement and scaling.
* `CGContext.render(path:from:to:) throws`: Rendered a `Path` in the given context. Uses information about _fills_ and _strokes_ to fill and/or stroke the path.
#### UIKit
* `SVG.uiImage(size:) -> UIImage?`: A `CoreGraphics` rendered `UIImage` representation of the SVG paths.
* `SVG.pngData(size:) -> Data?`: A `Data` representation of the `UIImage`.
* **`SVGImageView`**: A `UIImageView` subclass that supports the assignment of an `SVG` object. The `.image` will automatically be generated using the view `bounds`.
#### AppKit
* `SVG.nsImage(size:) -> NSImage?`: A `CoreGraphics` rendered `NSImage` representation of the SVG paths.
* `SVG.pngData(size:) -> Data?`: A `Data` representation of the `NSImage`.
#### SwiftUI
* `SVGView(svg:)`: A `SwiftUI.View` that renders a `SVG` document.
## Command Line Interface
### Inspect
Parses an SVG document and prints out the document description.
### Convert
Parses an SVG document and creates a PNG rendered version of the `Command`s.
Supported conversion options are:
* **absolute**: Translates all elements to 'absolute' paths.
* **symbols**: Generates an Apple Symbols compatible SVG.
* **uikit**: A `UIImageView` subclass that supports dynamic sizing.
### Preview
_macOS only_
Parses an SVG document displaying the results in an Application window. Do to limitations, this sub-command is only available when the `AppKit` framework is present.
### Render
_macOS only_
Parses an SVG document and creates a PNG rendered version of the `Command`s. Do to limitations, this sub-command is only available when the `AppKit` framework is present.