Merge pull request 'Revert BoardTemplateBuilderPage hex polygon changes' (#1) from claude/nifty-galileo into main
Reviewed-on: dingo/SOR#1
This commit is contained in:
@@ -284,8 +284,7 @@ else
|
||||
const double HexR = 16.0;
|
||||
const double HexPad = 12.0;
|
||||
// hexN = radius + 1 (for HexGrid coordinate math)
|
||||
int hexN = _template.HexSides > 0 ? _template.HexSides : (_pendingHexRadius + 1);
|
||||
int hexPoly = _template.HexPolygonSides > 0 ? _template.HexPolygonSides : _pendingHexPolySides;
|
||||
int hexN = _template.HexSides > 0 ? _template.HexSides : (_pendingHexRadius + 1);
|
||||
int hexDim = 2 * hexN - 1;
|
||||
double svgW = HexR * Math.Sqrt(3) * (hexDim - 1) + 2 * HexR + 2 * HexPad;
|
||||
double svgH = HexR * 1.5 * (hexDim - 1) + 2 * HexR + 2 * HexPad;
|
||||
@@ -304,7 +303,7 @@ else
|
||||
var hr = row; var hc = col;
|
||||
double cx = HexCellX(hc, hr, hexN, HexR, HexPad);
|
||||
double cy = HexCellY(hr, hexN, HexR, HexPad);
|
||||
<polygon points="@HexPolygonPoints(cx, cy, HexR - 1.0, hexPoly)"
|
||||
<polygon points="@HexPolygonPoints(cx, cy, HexR - 1.0)"
|
||||
fill="@GetCellColor(hc, hr)"
|
||||
stroke="rgba(0,0,0,0.25)" stroke-width="1"
|
||||
title="@GetCellTooltip(hc, hr)"
|
||||
@@ -710,14 +709,12 @@ else
|
||||
return pad + R * 1.5 * (N - 1) + R * 1.5 * r;
|
||||
}
|
||||
|
||||
private static string HexPolygonPoints(double cx, double cy, double R, int sides = 6)
|
||||
private static string HexPolygonPoints(double cx, double cy, double R)
|
||||
{
|
||||
var sb = new System.Text.StringBuilder();
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
// Start at top (-90°) and go clockwise; for 6 sides this matches the
|
||||
// original pointy-top hexagon orientation used by the hex grid layout.
|
||||
double angle = -Math.PI / 2.0 + 2.0 * Math.PI * i / sides;
|
||||
double angle = Math.PI / 180.0 * (60.0 * i - 30.0); // pointy-top
|
||||
if (i > 0) sb.Append(' ');
|
||||
sb.Append(FormattableString.Invariant(
|
||||
$"{cx + R * Math.Cos(angle):F1},{cy + R * Math.Sin(angle):F1}"));
|
||||
|
||||
Reference in New Issue
Block a user