Exemple #1
0
        /// <summary>
        /// Returns a polygon for a hexagon at the given point, with the given size.
        /// Assumes the given point to be in cartesian coordinates!
        /// </summary>
        /// <param name="size">The size of each of the hexagon's sides. </param>
        /// <param name="pointy">If true, assumes that the hexagon has a pointy top, otherwise assumes a flat top. </param>
        /// <returns></returns>
        public static IEnumerable <PointF> GetHexPoly(int size, bool pointyTop)
        {
            PointF[] points = new PointF[6];

            for (int corner = 0; corner < 6; corner++)
            {
                points[corner] = HexagonGrid.GetHexCorner(size, corner, pointyTop);
            }

            return(points);
        }
Exemple #2
0
        /// <summary>
        /// Returns the points of a hexagon at the given cube coordinates.
        /// </summary>
        /// <param name="cubeCoords">Cube coordinates of the hex to get. </param>
        /// <returns></returns>
        public IEnumerable <PointF> GetCellPoly(Point3I cubeCoords)
        {
            // Convert to cartesian coordinates.
            PointF cartesianCoords = this.GetCubeToCartesian(cubeCoords);

            // Get new hexagon at origin.
            IEnumerable <PointF> polyHex = HexagonGrid.GetHexPoly(this.SizeHexSide, this.PointyTop);

            // Move to cartesian position.
            polyHex = HexagonGrid.OffsetPoly(polyHex, cartesianCoords);

            return(polyHex);
        }