GitXplorerGitXplorer
e

element-to-path

public
53 stars
3 forks
5 issues

Commits

List of commits on branch master.
Unverified
114d8ee8e3344459a0ddb4511b3dc28f83f0be3a

1.2.1

eelrumordelaluz committed 3 years ago
Unverified
38d3e110f633200543862faa2a9cd8e355618854

Merge branch 'master' of github.com:elrumordelaluz/element-to-path

eelrumordelaluz committed 3 years ago
Unverified
632bb52e335a325453844dad6b24beddc145c8f9

Fix issue generating empty point in polygon.

eelrumordelaluz committed 3 years ago
Verified
56a57c9a8d4c5d6bbb0a2fe86b05feea3412a0a6

Update README.md

eelrumordelaluz committed 3 years ago
Unverified
ec7a43796e0957374b89d6ee86bc0f5220bd30de

Update dependencies

eelrumordelaluz committed 6 years ago
Unverified
9ef650d16a464873bbf0ee23192742998c16adf0

Update rollup. Fix options renamed

eelrumordelaluz committed 6 years ago

README

The README file for this repository.

Element to Path

Sometimes is useful to have an svg done with paths instead of elements
such as rect, circle, ellipse, line, polyline or polygon.
Like when you apply Compound Path in Adobe Illustrator.

Install

yarn add element-to-path

Usage

const toPath = require('element-to-path')

const circle = {
  type: 'element',
  name: 'circle',
  attributes: {
    cx: 10,
    cy: 10,
    r: 5,
  },
}

const path = toPath(circle)
// 'M15 10 A5 5 0 0 1 10 15 A5 5 0 0 1 5 10 A5 5 0 0 1 15 10 z'

API

toPath(elem,[options])

elem

Type: Object Element to convert. Default notation is svgson based:

{
  type: 'element', // could be ignored
  name: 'rect|circle|ellipse|line|polyline|polygon|path'
  attributes: {
    // depends on each element
  }
}

options

Type: Object

nodeName

Type: string
Default: name

Use custom name key in elem input

nodeAttrs

Type: string
Default: attributes

Use custom attributes key in elem input

Related

path-that-svg! Convert an entire SVG using paths

All calculations are based on W3C Spec

License

MIT © Lionel Tzatzkin