Exemplo n.º 1
0
        private System.Drawing.Point GetPolygonCorner(System.Drawing.Point centerPoint, int corner, double cornerAngle, double angleOffset)
        {
            var angleDeg     = cornerAngle * corner + angleOffset;
            var angleRad     = Math.PI / 180 * angleDeg;
            var xPart        = CellWidth * Math.Cos(angleRad) * CellVertexDistance;
            var yPart        = CellWidth * Math.Sin(angleRad) * CellVertexDistance;
            var pointX       = Convert.ToInt32(centerPoint.X + xPart);
            var pointY       = Convert.ToInt32(centerPoint.Y + yPart);
            var drawingPoint = new System.Drawing.Point(pointX, pointY);

            return(drawingPoint);
        }
Exemplo n.º 2
0
        private Polygon MapPointToHexagon(Point point)
        {
            var centerPoint = GetHexagonCenterPoint(point);
            var points      = new System.Drawing.Point[6];

            for (var i = 0; i < points.Length; i++)
            {
                points[i] = GetPolygonCorner(centerPoint, i, 60, 30);
            }
            var polygon = new Polygon(points);

            return(polygon);
        }
Exemplo n.º 3
0
        private System.Drawing.Point GetHexagonCenterPoint(Point mapPoint)
        {
            var xPart = Convert.ToInt32(OffsetX + mapPoint[0] * CellWidth + CellWidth / 2);
            var yPart = Convert.ToInt32(OffsetY + mapPoint[1] * CellHeight + CellHeight / 2);

            if (mapPoint[1] % 2 == 0)
            {
                xPart += CellWidth / 2;
            }
            var centerPoint = new System.Drawing.Point(xPart, yPart);

            return(centerPoint);
        }
Exemplo n.º 4
0
        private Polygon MapPointToRectangle(Point point)
        {
            var centerPoint = GetRectangleCenterPoint(point);
            var points      = new System.Drawing.Point[4];

            for (var i = 0; i < points.Length; i++)
            {
                points[i] = GetPolygonCorner(centerPoint, i, 90, 45);
            }
            var polygon = new Polygon(points);

            return(polygon);
        }
Exemplo n.º 5
0
        private System.Drawing.Point GetRectangleCenterPoint(Point mapPoint)
        {
            var centerPoint = new System.Drawing.Point(OffsetX + mapPoint[0] * CellWidth + CellWidth / 2, OffsetY + mapPoint[1] * CellHeight + CellHeight / 2);

            return(centerPoint);
        }