The above image is called a hexa-glyph. Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class. Here's how you make one:
- Consider the following set of points, shaped like a regular hexagram. The inner hexagon is what will contain the final glyph, while the outer 6 points form a star and are where we will start drawing our lines.
- From the outer six points, randomly select a pair. For efficiency, there should be at least one other point between the two selected points (otherwise, it would have no effect on the final figure). Then, from each of the two points, cast a ray towards the other. This ray is blocked by previous lines.
- Repeat this process until all 9 edges have been formed, as shown in the next few images.
- Here is an example of rays being blocked. The ends of the ray segment are still visible, but the middle portion is occluded by the first two segments we drew.
- These two rays are also "blocked," but this doesn't cause any visible difference because they are blocked by the same other line.
- Fast-forwarding until all 9 lines are drawn. If you want a more detailed explanation of these skipped steps, I can expound.
- Finally, remove the points of the star. To make it look prettier, the thick dots are also removed.
The challenge
You challenge is to output a visual representation of a random hexa-glyph. This is code-golf, fewest bytes wins.
All possible hexa-glyphs should appear with some positive probability. Different hexa-glyphs are generated by changing the order in which the 9 edges are drawn.
Furthermore, all images output by your program must be valid hexa-glyphs. Certain patterns (like a complete outline of the inner hexagon) cannot possibly appear as a hexa-glyph, and so you program mustn't output these.
The output should be a graphical image (printed to screen or file).
The hexagon must be regular, but can appear in any orientation.
Reflections / rotations are not considered unique. (This might make requirement 1 easier to follow).
I made up while doodling during my DiffEq class
. The way all great discoveries happen... :P \$\endgroup\$'01'
with space interleaved instead of' *'
. \$\endgroup\$