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.
const nGon = require( "svg-n-gon" );
nGon( <center>, <numberOfSides>, <radius>, <startAngle>, <asPath>, <counterClockwise> );
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 |
|