-2

It's possible to generate polygon with random shape, filled and with outline? Something like this:

Link to image: https://image.ibb.co/kWAWk5/solid1.png

I mean what algorithm can be used? What programming language it uses doesn't matter.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Alex
  • 17
  • 2
  • 8

1 Answers1

0

Given a number of vertices v where v > 2,

  1. Draw a straight edge ex between vertices v0 and v1, and add it to a list of edges e.
  2. For each of the remaining vertices v2 through vn-1,
    1. Randomly select one of the edges (ey) from e.
    2. Randomly pick another point p that's not along ey.
    3. Replace ey with 2 new edges: 1 from e's starting point to p, and 1 from e's ending point to p.
  3. For the final vertex vn-1, add an edge from it to v0.
  4. Fill the path.
NRitH
  • 13,441
  • 4
  • 41
  • 44