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); }
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); }
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); }
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); }