MCPcopy
hub / github.com/tdewolff/canvas / RegularPolygon

Function RegularPolygon

shapes.go:123–125  ·  view source on GitHub ↗

RegularPolygon returns a regular polygon with radius r. It uses n vertices/edges, so when n approaches infinity this will return a path that approximates a circle. n must be 3 or more. The up boolean defines whether the first point will point upwards or downwards.

(n int, r float64, up bool)

Source from the content-addressed store, hash-verified

121
122// RegularPolygon returns a regular polygon with radius r. It uses n vertices/edges, so when n approaches infinity this will return a path that approximates a circle. n must be 3 or more. The up boolean defines whether the first point will point upwards or downwards.
123func RegularPolygon(n int, r float64, up bool) *Path {
124 return RegularStarPolygon(n, 1, r, up)
125}
126
127// RegularStarPolygon returns a regular star polygon with radius r. It uses n vertices of density d. This will result in a self-intersection star in counter clockwise direction. If n/2 < d the star will be clockwise and if n and d are not coprime a regular polygon will be obtained, possible with multiple windings. n must be 3 or more and d 2 or more. The up boolean defines whether the first point will point upwards or downwards.
128func RegularStarPolygon(n, d int, r float64, up bool) *Path {

Callers 4

rhombitrihexagonalTilingFunction · 0.92
mainFunction · 0.92
TestShapesFunction · 0.85
TriangleFunction · 0.85

Calls 1

RegularStarPolygonFunction · 0.85

Tested by 1

TestShapesFunction · 0.68