Skip to content

josh-frank/svg-n-gon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Generates SVG paths for regular n-gons

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published