Skip to content

Latest commit

 

History

History
60 lines (54 loc) · 1.73 KB

README.md

File metadata and controls

60 lines (54 loc) · 1.73 KB

svg-n-gon

A dumb simple tool to generate simple versatile SVG paths/vertices of regular polygons. Useful for situations where transform() is not ideal or for defining evenly-spaced stopping points around a circular path... or for when you just need a regular polygon.

Use

const nGon = require( "svg-n-gon" );

nGon( <center>, <numberOfSides>, <radius>, <startAngle>, <asPath>, <counterClockwise> );

API

props type description default
center [ number, number ] Must be a valid SVG cartesian coordinate in the form of [ x, y ]
numberOfSides integer Must be greater than 3
radius number Distance from center to each vertex
startAngle number Rotates the n-gon
asPath boolean Returns an SVG path string when true and an array of SVG coordinates otherwise false
counterClockwise When true, nGonVertices[ 1 ] corresponds to the vertex immediately to the left of the top (starting) vertex - otherwise it corresponds to the vertex immediately to the right of the starting vertex (and so on) true