Giter VIP home page Giter VIP logo

vectorplus's Introduction

VectorPlus

A utility & library for interacting with SVG documents.

Twitter: @richardpiazza

Usage

VectorPlus is distributed using the Swift Package Manager. To install it into a project, add it as a dependency within your Package.swift manifest:

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/richardpiazza/VectorPlus.git", from: "0.3.0")
    ],
    ...
)

Then import the VectorPlus packages wherever you'd like to use it:

import 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 Rects 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 Commands.

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 Commands. Do to limitations, this sub-command is only available when the AppKit framework is present.

vectorplus's People

Contributors

richardpiazza avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.