Skip to content

Commit 93126ff

Browse files
HandyS11claude
andcommitted
fix(map): clip the grid to the labelled cell block, not the whole image
Draw the grid lattice only over the labelled cells (A0 through the last ceil-count cell) instead of extending the lines across the entire image and its ocean margin. The anchoring (per grid style) and label placement are unchanged; the partial edge cell still bleeds past the world's south/east edge inside the block, so every labelled cell renders full-size. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 47f6f1c commit 93126ff

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/RustPlusBot.Features.Map/Rendering/MapRenderer.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ private static void DrawGrid(Image<Rgba32> image, MapProjection projection, MapG
117117
var cells = MapGrid.CellCount(projection.WorldSize);
118118

119119
// The lattice is anchored at the west edge and at the style's row anchor (the world's north
120-
// edge for the in-game style; 100 game-units south of it for Rust+/RustMaps), and spans the
121-
// whole image, ocean margin included — exactly how those maps draw it. The partial edge cell
122-
// sits at the south/east and simply bleeds past the world edge, so every rendered cell looks
123-
// full-size.
120+
// edge for the in-game style; 100 game-units south of it for Rust+/RustMaps), and is clipped
121+
// to the LABELLED cell block only (A0 … the last ceil-count cell) — no lines out over the
122+
// ocean margin. The partial edge cell sits at the south/east and simply bleeds past the world
123+
// edge, so every rendered cell looks full-size.
124124
var anchorWorldY = projection.WorldSize - MapGrid.RowInset(gridStyle);
125125
var (anchorX, anchorY) = projection.ToPixel(0f, anchorWorldY);
126126
var (cellEndX, cellEndY) = projection.ToPixel(MapGrid.CellSize, anchorWorldY - MapGrid.CellSize);
@@ -131,22 +131,21 @@ private static void DrawGrid(Image<Rgba32> image, MapProjection projection, MapG
131131
return; // Degenerate projection (no drawable world area).
132132
}
133133

134+
var right = anchorX + (cells * stepX);
135+
var bottom = anchorY + (cells * stepY);
136+
134137
image.Mutate(ctx =>
135138
{
136-
for (var k = (int)MathF.Ceiling(-anchorX / stepX); anchorX + (k * stepX) <= image.Width; k++)
139+
for (var k = 0; k <= cells; k++)
137140
{
138141
var x = anchorX + (k * stepX);
139-
ctx.DrawLine(lineColor, OutlinePenWidth, new PointF(x, 0f), new PointF(x, image.Height));
140-
}
141-
142-
for (var k = (int)MathF.Ceiling(-anchorY / stepY); anchorY + (k * stepY) <= image.Height; k++)
143-
{
142+
ctx.DrawLine(lineColor, OutlinePenWidth, new PointF(x, anchorY), new PointF(x, bottom));
144143
var y = anchorY + (k * stepY);
145-
ctx.DrawLine(lineColor, OutlinePenWidth, new PointF(0f, y), new PointF(image.Width, y));
144+
ctx.DrawLine(lineColor, OutlinePenWidth, new PointF(anchorX, y), new PointF(right, y));
146145
}
147146

148-
// Only the world's cells carry labels (A0 in the north-west corner), each just inside its
149-
// cell's top-left corner (companion-app placement).
147+
// Every labelled cell (A0 in the north-west corner), each label just inside its cell's
148+
// top-left corner (companion-app placement).
150149
for (var col = 0; col < cells; col++)
151150
{
152151
for (var row = 0; row < cells; row++)

0 commit comments

Comments
 (0)