• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert SVG path data to a Swift 3 UIBezierPath

swiftvg

Convert SVG path data to a Swift 3 UIBezierPath

Build Status npm codecov

Why?

As an iOS developer, you have to support at least three different pixel densities. Why waste your time managing a million image assets for different resolutions and states?

swiftvg is a small little tool written in javascript to help you convert your vector SVG images into UIBezierPath shapes. It provides both CLI and JS apis, so you can use it however you'd like.

Installing

There are two ways to use swiftvg: through the CLI or through your code.

CLI

To install the tool, use npm (or another npm package manager like yarn). It's recommended that you install it globally, have node_modules/.bin in your path, or use it with an npm run-script.

npm install -g swiftvg

JS API

To add swiftvg to your project, install it to your dependencies.

npm install -S swiftvg

Usage

CLI

After it's installed and avilable somewhere in your path, run the command with your svg data string.

Unless something went wrong, the command should exit with a 0 status and print the swift code line by line to your terminal's STDOUT.

swiftvg "M37,17 L37,25 Z"

# output
let shape = UIBezierPath()
shape.move(to: CGPoint(x: 37, y: 17))
shape.addLine(to: CGPoint(x: 37, y: 25))
shape.close()

JS API

After it's installed, require or import it into your code and run the exported function.

You can expect the function to return an array, where each element is a line of swift code. You can console.log(join(output, '\n')) or anything else you can imagine.

// CommonJS
const swiftvg = require("swiftvg");

// ES2015
import swiftvg from "swiftvg";

const pathData = "M37,17 L37,25 Z";

swiftvg(pathData); // Array<String>

Contributing

As the project is pretty small, you only need to run npm install to get up and running. From there, standard is used for code style.

This is a functional project, so please try to keep it that way—avoid side affects, mutations, and imperative code when you can.

There are four testing commands:

npm run build:browser – build a UMD file for a browser to consume
npm run build:site – build the JS bundle for the public site
npm run test – run all tests
npm run test:coverage - get a coverage report
npm run test:lint – lint the project using standard
npm run test:unit – run only unit tests with no coverage or linting

Code of Conduct

License

More Repositories

1

jwt-cli

A super fast CLI tool to decode and encode JWTs built in Rust
Rust
1,066
star
2

a11y-css-reset

A small set of global rules to make things accessible and reset default styling
CSS
261
star
3

styled-typography

Typograpy components for react and styled-components
TypeScript
128
star
4

babel-plugin-bucklescript

Write ReasonML and Bucklescript in your existing babel projects
JavaScript
77
star
5

bkmrkd

Bkmrkd is a self-hosted, lightweight bookmarking service run on node.js and rethinkdb
JavaScript
51
star
6

Barnacal

A simple menu bar app for viewing a calendar
JavaScript
37
star
7

floating-label-react

A floating-label component using react without any dependencies
CSS
26
star
8

preact-cli-typescript-sample

An example of how to use typescript with preact-cli and all its goodies
TypeScript
17
star
9

gistcard

Show better gist previews in twitter with a code snippet and a link to the gist
TypeScript
13
star
10

accept-language-rs

A tiny library for parsing the Accept-Language header from browsers
Rust
12
star
11

now-importer

Easily import your static websites into ZEIT's now platform
Rust
8
star
12

locale

A polyfill to understand your users' preferred languages
Rust
7
star
13

homebrew-jwt-cli

The official homebrew tap for jwt-cli. Because it's not popular enough on its own.
Ruby
5
star
14

hyper-base16-ocean-dark

A Base 16 Ocean Hypeterm theme plugin
JavaScript
4
star
15

split-view-test

Test case for odd split view behavior in SwiftUI
Swift
2
star
16

gotham-router-composition

A small example demonstrating one way to compose a router in gotham
Rust
1
star
17

vimfiles

My .vim directory and .vimrc
Vim Script
1
star
18

mike-engel.com

source for mike-engel.com
SCSS
1
star
19

passablewords-js

A password validation library which checks a password against a million of the most common as well as it's ability to be cracked
JavaScript
1
star
20

vscode-simple-ocean

A minimal syntax theme based off of Base16 Ocean for VS Code
1
star
21

atom-simple-base16-ocean

A simplified base16 ocean theme. 4 colors and that's it.
CSS
1
star