Ejemplo n.º 1
0
        public override Point2F FromAxialToPixel(HexAxialCoordinates axial)
        {
            var x     = Size * (1.5f * axial.Q);
            var y     = (float)(Size * (Constants.HalfOfSquareRootOf3 * axial.Q + Constants.SquareRootOf3 * axial.R));
            var pixel = new Point2F(x, y);

            return(pixel);
        }
Ejemplo n.º 2
0
        protected Point2F GetCorner(Direction direction)
        {
            var degrees = GetDegreesForHexCorner(direction);
            var radians = degrees.ToRadians();
            var v       = new Point2F((float)(Size * Math.Cos(radians)), (float)(Size * Math.Sin(radians)));

            return(v);
        }
Ejemplo n.º 3
0
        public override Point2F[] GetCorners()
        {
            var corners = new Point2F[6];

            corners[0] = GetCorner(Direction.NorthEast);
            corners[1] = GetCorner(Direction.East);
            corners[2] = GetCorner(Direction.SouthEast);
            corners[3] = GetCorner(Direction.SouthWest);
            corners[4] = GetCorner(Direction.West);
            corners[5] = GetCorner(Direction.NorthWest);

            return(corners);
        }
Ejemplo n.º 4
0
        public override Point2F FromOffsetCoordinatesToPixel(HexOffsetCoordinates offset)
        {
            var x = Size * (1.5f * offset.Col);
            var y = Size;

            y *= OffsetCoordinatesType switch
            {
                OffsetCoordinatesType.Even => (float)(Constants.SquareRootOf3 * (offset.Row - 0.5f * (offset.Col & 1))),
                OffsetCoordinatesType.Odd => (float)(Constants.SquareRootOf3 * (offset.Row + 0.5f * (offset.Col & 1))),
                _ => throw new ArgumentOutOfRangeException(nameof(OffsetCoordinatesType), OffsetCoordinatesType, $"OffsetCoordinatesType {OffsetCoordinatesType} is not supported.")
            };

            var pixel = new Point2F(x, y);

            return(pixel);
        }