android - Randomly Generating Patterns Using Hexagonal Images -
okay have these images:
basically i'm trying create "mosaic" of 5 12 hexagons, of them centralised, , of lines meet up.
for example:
i'm aware brute-force it, i'm developing android need faster, more efficient , less processor-intensive way of doing it.
can provide me solution, or point me in right direction?
a random idea had go deepak said defining class tracks state of each of 6 edges (say, in int[] neighbor
in neighbor[0] states if top edge has neighbor, neighbor[1] states if top-right edge has neighbor, , on going clockwise)
then each hexagon on screen, convert array integer via binary. based on integer, use lookup table determine hexagon image use + how should oriented/flipped, assign hexagon object image.
for instance, let's take central hexagon 4 neighbors in first screenshot. array [1, 0, 1, 1, 0, 1]
based on scheme mentioned above. take neighbor[0] least-significant bit (2^0) , neighbor[5] most-significant bit (2^5), , have [1, 0, 1, 1, 0, 1] --> 45
. somewhere in lookup table have defined 45 mean the 5th hexagon image, flipped horizontally*, among 7 base hexagon icons you've posted.
yes, brute-force involved, it's "smarter" brute-force since you're not rotating see if hexagon fit. rather, involves more efficient look-up table.
*or rotated 120 degrees clockwise if prefer ;)
Comments
Post a Comment