SRPG is a library that generates well-formed random polygons using a regular grid consisting of square cells.
It starts with axis & grid-aligned basic rectangular shapes, but can systematically manipulate them through repeated corner-cutting and perturbations to create a variety of polygonal and curve-like shapes, both on the grid and with offset/rotated orientations.
This library is based on Martin Held's C implementation.
SRPG is available as Maven/Gradle artifact via Jitpack.
SRPG accepts a variety of input arguments that affect shape geometry, providing a good level of customisation over the output. The following illustrations provide an idea of how each argument visually affects the random polygon:
Hierarchy | Diagonal | Perturb+align | Smooth |
5x5 | 10x10 | 100x100 | 500x500 |