flatworld.extensions.hexagons.utils Class
Utility module, for making different calculations and tests when hexagon based grid map in use
Item Index
Methods
- _pointInPolygon static
 - calcLongDiagonal static
 - calcLongDiagonal static
 - calcSpecialDistance static
 - createHexagonGridCoordinates static
 - getClosestHexagonCenter static
 - getHexagonPoints static
 - hexaHitTest static
 - setRadius static
 
Methods
_pointInPolygon
        - 
                        
point - 
                        
hitCoords.x - 
                        
hitCoords.y - 
                        
vs 
credits to: https://github.com/substack/point-in-polygon Tests whether the given point / coordinate is inside the given points. Assuming the points form a polygon
Parameters:
- 
                        
pointObjectThe coordinates to test against
 - 
                        
hitCoords.xIntegerX coordinate
 - 
                        
hitCoords.yIntegerY coordinate
 - 
                        
vsIntegerThe points of the polygon to test [0] === x-point, [1] === y-point
 
Returns:
Is the coordinate inside the hexagon or not
calcLongDiagonal
        - 
                        
{} 
Calculates the hexagons: innerDiameter
- Vertical / Flat hexagons height
 - Horizontal / pointy hexagons width
 
calcLongDiagonal
        - 
                        
{} 
outerDiameter
- Vertical / Flat hexagons width
 - Horizontal / pointy hexagons height
 
calcSpecialDistance
        - 
                        
{} 
Parameters:
- 
                        
{}ObjectOPTIONAL
- 
                                    
radiusFloatUsually the radius of the hexagon
 
 - 
                                    
 
createHexagonGridCoordinates
        - 
                        
gridSize - 
                        
{} 
Create Array that holds the coordinates for the size of hexagon grid we want to create.
Returns:
Array that holds the coordinates for the hexagon grid, like [{x: ?, y: ?}]
getClosestHexagonCenter
        - 
                        
coordinates 
Calculates the closest hexagon center coordinates, for the given coordinates. So aligning the given coordinates to proper hexagon coordinates
Parameters:
- 
                        
coordinatesObjectThe coordinate where we want to find the closest hexagon center point
 
getHexagonPoints
        - 
                        
radius - 
                        
options 
Parameters:
- 
                        
radiusFloatradius of the hexagon
 - 
                        
optionsObjectextra options, like generating horizontal hexagon points and how many decimals to round
 
hexaHitTest
        - 
                        
points - 
                        
hitCoords - 
                        
offsetCoords 
Test do the given coordinates hit the hexagon, given by the points container / array
Parameters:
- 
                        
pointsPIXI.PointArray of PIXI.points
 - 
                        
hitCoordsObjectThe coordinates to test against
- 
                                    
xIntegerX coordinate
 - 
                                    
yIntegerY coordinate
 
 - 
                                    
 - 
                        
offsetCoordsObjectOPTIONAL offsetCoordinates that are added to the hitCoordinates. Separate because these are outside the given array.
- 
                                    
xIntegerX coordinate
 - 
                                    
yIntegerY coordinate
 
 - 
                                    
 
Returns:
Is the coordinate inside the hexagon or not
