reorder-svg

1.0.3 • Public • Published

reorderSvg.js

This module currently accepts an array of stringified polygons. It then calculates the center point of each SVG polygon, after which it reorders the polygons on either the X or Y position it's center point. It accepts 8 ordering formats (see settings: order).

At this moment it only supports points. Svg shapes exported through Adobe Illustrator (points divided by spaces) and the W3C standard (X and Y point attached by comma and coordinates seperated through spaces) are both supported.

Installation

npm install reorder-svg

Usage

reorderSvg(shapes, order).then(result => console.log(result));

Settings

Shapes {array}
Accepts an array of stringified polygons

Order {number}
You can pick one of the following 8 formatting orders

startposition-endposition direction argument image example
lefttop-rightbottom horizontal 1 lt-rb-h
righttop-leftbottom horizontal 2 rt-lb-h
rightbottom-lefttop horizontal 3 rb-lt-h
leftbottom-righttop horizontal 4 lb-rt-h
lefttop-rightbottom vertical 5 lt-rb-v
righttop-leftbottom vertical 6 rt-lb-v
rightbottom-lefttop vertical 7 rb-lt-v
leftbottom-righttop vertical 8 lb-rt-v

Examples

Coming up

Readme

Keywords

Package Sidebar

Install

npm i reorder-svg

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

6.18 kB

Total Files

3

Last publish

Collaborators

  • ervazu