module:extras/randompolygon
### module:extras/randompolygon()
Contains a method to generate a simple polygon at random.
To import all symbols in this module, either of the following can be used:
import * from "extras/randompolygon.js"; // -- or -- import * as CustomModuleName from "extras/randompolygon.js";
Methods
- randomPolygon
Generates a simple polygon at random.
### (static) module:extras/randompolygon.randomPolygon(cx, cy, avgRadius, sides, [irregular], [spiky])
Generates a simple polygon at random. Inspired by a Stack Overflow question.
Parameters
cx
(Type: number)
X coordinate of the polygon’s approximate center.cy
(Type: number)
Y coordinate of the polygon’s approximate center.avgRadius
(Type: number)
Average distance of the polygon’s vertices from the center.sides
(Type: number)
Number of sides in the polygon.irregular
(Type: number) (optional)
Degree to which the angular distance from one vertex to the next is uneven. If 0, the vertices will be evenly spaced in terms of angular distance. Usually no more than half pi. If null, undefined, or omitted, the default is 0.spiky
(Type: number) (optional)
Degree of variation among distances of the polygon’s vertices from the center, in terms of a standard deviation from the average. If null, undefined, or omitted, the default is 0.
Return Value
The randomly generated polygon. (Type: GraphicsPath)