BDS Software

Hex vs. Square - Page 13



Which Hex Has Been Clicked (My Method - continued)


Here's an 841x841 pixel grid with its central 641x641 pixel space outlined in purple:


841x841 pixel grid

Blowing this layout up ten times reveals its arrangement. The yellow lines are hairline guides; the blue dots are Hex centers; and the red dots are Hex corners. The purple lines are a portion of the 641 by 641 croplines:


641x641 croplines

Now, let's isolate hex number 0000. Below, we see it blown up ten times, with the two blue pixels being the Upper-Left Corner Pixels which are part of this hex number 0000, and the four red pixels being members of other neighboring hexagons. Also, the three aqua-colored lines are the Upper-Left Edge Lines which are part of this hex number 0000, and the three pink lines are members of other neighboring hexagons.

NOTE that we specifically do NOT anti-alias these lines. My method here requires that EVERY pixel associated with a given hex be EXACTLY the same color:


641x641 croplines

Having drawn the outline of hex number 0000, we now fill it with RGB Color "#027024". Notice that the member Corner Pixels and Edge Lines are also colored "#027024" while the neighboring corner pixels and edge lines are not::


641x641 croplines

In addition to color-coding the 483 hexagone in this fashion, I also color-coded the borders (based on fractional hexagons) so that I would know when the mouse was clicked outside of any valid hexagon.

Continue to the next page to check out how this works.




                                                                                                                                                                M.D.J. 2022/08/27