1 | # shape2path
|
2 | Convert SVG [shapes](https://developer.mozilla.org/en-US/docs/Web/SVG/Element#Basic_shapes) to SVG [paths](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path). Check out [this demo](https://bl.ocks.org/HarryStevens/944fc151f210ddf6bd6ebaeda12c3d05). [![Build Status](https://travis-ci.org/HarryStevens/shape2path.svg?branch=master)](https://travis-ci.org/HarryStevens/shape2path)
|
3 |
|
4 | ## Installation
|
5 | ### npm
|
6 | ```bash
|
7 | npm install shape2path --save
|
8 | ```
|
9 | ```js
|
10 | var shape2path = require("shape2path");
|
11 | ```
|
12 |
|
13 | ### Web browser
|
14 | You can use the CDN from unpkg.
|
15 | ```html
|
16 | <script src="https://unpkg.com/shape2path@2.0.5/build/shape2path.js"></script>
|
17 | <script src="https://unpkg.com/shape2path@2.0.5/build/shape2path.min.js"></script>
|
18 | ```
|
19 | If you'd rather host it yourself, download `shape2path.js` or `shape2path.min.js` from the [`build` directory](https://github.com/HarryStevens/shape2path/tree/master/build).
|
20 | ```html
|
21 | <script src="path/to/shape2path.js"></script>
|
22 | <script src="path/to/shape2path.min.js"></script>
|
23 | ```
|
24 |
|
25 | ## API
|
26 | shape2path's functions all take a single argument: an <em>options</em> object whose properties correspond to the attributes of an SVG shape. If you don't pass options, the attributes will default to 0. Likewise, all functions return a string representing an SVG path's `d` attribute.
|
27 |
|
28 | <a name="circle" href="#circle">#</a> shape2path.<b>circle</b>([<em>options</em>])
|
29 |
|
30 | Draw a path shaped like a [circle](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/circle).
|
31 |
|
32 | <a name="ellipse" href="#ellipse">#</a> shape2path.<b>ellipse</b>([<em>options</em>])
|
33 |
|
34 | Draw a path shaped like an [ellipse](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/ellipse).
|
35 |
|
36 | <a name="line" href="#line">#</a> shape2path.<b>line</b>([<em>options</em>])
|
37 |
|
38 | Draw a path shaped like a [line](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line).
|
39 |
|
40 | <a name="polygon" href="#polygon">#</a> shape2path.<b>polygon</b>([<em>options</em>])
|
41 |
|
42 | Draw a path shaped like a [polygon](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polygon).
|
43 |
|
44 | <a name="polyline" href="#polyline">#</a> shape2path.<b>polyline</b>([<em>options</em>])
|
45 |
|
46 | Draw a path shaped like a [polyline](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polyline).
|
47 |
|
48 | <a name="rect" href="#rect">#</a> shape2path.<b>rect</b>([<em>options</em>])
|
49 |
|
50 | Draw a path shaped like a [rectangle](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect). Add `rx` or `ry` properties to the options to round the corners. |
\ | No newline at end of file |