1.0.3 • Published 6 years ago

reorder-svg v1.0.3

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

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-endpositiondirectionargumentimage example
lefttop-rightbottomhorizontal1lt-rb-h
righttop-leftbottomhorizontal2rt-lb-h
rightbottom-lefttophorizontal3rb-lt-h
leftbottom-righttophorizontal4lb-rt-h
lefttop-rightbottomvertical5lt-rb-v
righttop-leftbottomvertical6rt-lb-v
rightbottom-lefttopvertical7rb-lt-v
leftbottom-righttopvertical8lb-rt-v

Examples

Coming up

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago